From 7b7e898c2ba0736cc7ea628eca74e7630eab5038 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 20 Jun 2024 13:38:00 +0200 Subject: [PATCH 1/3] byacc: import version 20240109 --- LICENSE | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..c21f9f78a6d --- /dev/null +++ b/LICENSE @@ -0,0 +1,10 @@ + Berkeley Yacc is distributed with no warranty whatever. The author +and any other contributors take no responsibility for the consequences of +its use. + + Berkeley Yacc is in the public domain. The data structures and algorithms +used in Berkeley Yacc are all either taken from documents available to the +general public or are inventions of the author. Anyone may freely distribute +source or binary forms of Berkeley Yacc whether unchanged or modified. +Distributers may charge whatever fees they can obtain for Berkeley Yacc. +Programs generated by Berkeley Yacc may be distributed freely. From 0b234d7a89df4780e9d2ea9817afd5d3dfaf4d27 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 20 Jun 2024 13:46:15 +0200 Subject: [PATCH 2/3] byacc: actually import version 20240109 --- CHANGES | 150 ++ MANIFEST | 5 +- VERSION | 2 +- aclocal.m4 | 396 +++- config.guess | 63 +- config.sub | 222 +- configure | 1380 +++++++----- configure.in | 6 +- defs.h | 55 +- error.c | 73 +- main.c | 6 +- makefile.in | 8 +- mstring.c | 14 +- output.c | 16 +- package/byacc.spec | 119 - package/debian/changelog | 519 ----- package/debian/control | 28 - package/debian/copyright | 129 -- package/debian/rules | 29 - package/debian/source/format | 1 - package/debian/watch | 20 - package/mingw-byacc.spec | 68 - package/pkgsrc/DESCR | 6 - package/pkgsrc/Makefile | 19 - package/pkgsrc/PLIST | 3 - package/pkgsrc/distinfo | 6 - reader.c | 345 ++- test/README | 4 - test/btyacc/big_b.error | 30 - test/btyacc/big_b.output | 0 test/btyacc/big_l.error | 30 - test/btyacc/big_l.output | 0 test/btyacc/btyacc_calc1.error | 1 - test/btyacc/btyacc_calc1.output | 949 -------- test/btyacc/btyacc_calc1.tab.c | 1803 --------------- test/btyacc/btyacc_calc1.tab.h | 22 - test/btyacc/btyacc_demo.error | 1 - test/btyacc/btyacc_demo.output | 1298 ----------- test/btyacc/btyacc_demo.tab.c | 2400 -------------------- test/btyacc/btyacc_demo.tab.h | 51 - test/btyacc/btyacc_destroy1.error | 0 test/btyacc/btyacc_destroy1.output | 247 -- test/btyacc/btyacc_destroy1.tab.c | 1477 ------------ test/btyacc/btyacc_destroy1.tab.h | 25 - test/btyacc/btyacc_destroy2.error | 0 test/btyacc/btyacc_destroy2.output | 247 -- test/btyacc/btyacc_destroy2.tab.c | 1477 ------------ test/btyacc/btyacc_destroy2.tab.h | 25 - test/btyacc/btyacc_destroy3.error | 0 test/btyacc/btyacc_destroy3.output | 247 -- test/btyacc/btyacc_destroy3.tab.c | 1477 ------------ test/btyacc/btyacc_destroy3.tab.h | 25 - test/btyacc/calc.error | 0 test/btyacc/calc.output | 485 ---- test/btyacc/calc.tab.c | 1489 ------------ test/btyacc/calc.tab.h | 8 - test/btyacc/calc1.error | 2 - test/btyacc/calc1.output | 900 -------- test/btyacc/calc1.tab.c | 1746 -------------- test/btyacc/calc1.tab.h | 23 - test/btyacc/calc2.error | 0 test/btyacc/calc2.output | 485 ---- test/btyacc/calc2.tab.c | 1502 ------------ test/btyacc/calc2.tab.h | 8 - test/btyacc/calc3.error | 0 test/btyacc/calc3.output | 485 ---- test/btyacc/calc3.tab.c | 1516 ------------- test/btyacc/calc3.tab.h | 8 - test/btyacc/calc_code_all.error | 0 test/btyacc/calc_code_all.output | 485 ---- test/btyacc/calc_code_all.tab.c | 1517 ------------- test/btyacc/calc_code_all.tab.h | 18 - test/btyacc/calc_code_default.error | 0 test/btyacc/calc_code_default.output | 485 ---- test/btyacc/calc_code_default.tab.c | 1497 ------------ test/btyacc/calc_code_default.tab.h | 8 - test/btyacc/calc_code_imports.error | 0 test/btyacc/calc_code_imports.output | 485 ---- test/btyacc/calc_code_imports.tab.c | 1489 ------------ test/btyacc/calc_code_imports.tab.h | 8 - test/btyacc/calc_code_provides.error | 0 test/btyacc/calc_code_provides.output | 485 ---- test/btyacc/calc_code_provides.tab.c | 1497 ------------ test/btyacc/calc_code_provides.tab.h | 14 - test/btyacc/calc_code_requires.error | 0 test/btyacc/calc_code_requires.output | 485 ---- test/btyacc/calc_code_requires.tab.c | 1497 ------------ test/btyacc/calc_code_requires.tab.h | 14 - test/btyacc/calc_code_top.error | 0 test/btyacc/calc_code_top.output | 485 ---- test/btyacc/calc_code_top.tab.c | 1497 ------------ test/btyacc/calc_code_top.tab.h | 8 - test/btyacc/code_calc.code.c | 1362 ----------- test/btyacc/code_calc.error | 0 test/btyacc/code_calc.output | 485 ---- test/btyacc/code_calc.tab.c | 165 -- test/btyacc/code_calc.tab.h | 10 - test/btyacc/code_error.code.c | 1256 ----------- test/btyacc/code_error.error | 0 test/btyacc/code_error.output | 34 - test/btyacc/code_error.tab.c | 61 - test/btyacc/code_error.tab.h | 5 - test/btyacc/defines1.calc.c | 1396 ------------ test/btyacc/defines1.calc.h | 8 - test/btyacc/defines1.error | 0 test/btyacc/defines1.output | 0 test/btyacc/defines2.calc.c | 1396 ------------ test/btyacc/defines2.calc.h | 8 - test/btyacc/defines2.error | 0 test/btyacc/defines2.output | 0 test/btyacc/defines3.calc.c | 1396 ------------ test/btyacc/defines3.calc.h | 8 - test/btyacc/defines3.error | 0 test/btyacc/defines3.output | 0 test/btyacc/empty.error | 0 test/btyacc/empty.output | 28 - test/btyacc/empty.tab.c | 1275 ----------- test/btyacc/empty.tab.h | 5 - test/btyacc/err_inherit1.error | 3 - test/btyacc/err_inherit1.output | 0 test/btyacc/err_inherit1.tab.c | 15 - test/btyacc/err_inherit1.tab.h | 0 test/btyacc/err_inherit2.error | 5 - test/btyacc/err_inherit2.output | 0 test/btyacc/err_inherit2.tab.c | 15 - test/btyacc/err_inherit2.tab.h | 0 test/btyacc/err_inherit3.error | 23 - test/btyacc/err_inherit3.output | 216 -- test/btyacc/err_inherit3.tab.c | 1445 ------------ test/btyacc/err_inherit3.tab.h | 25 - test/btyacc/err_inherit4.error | 13 - test/btyacc/err_inherit4.output | 165 -- test/btyacc/err_inherit4.tab.c | 1433 ------------ test/btyacc/err_inherit4.tab.h | 40 - test/btyacc/err_inherit5.error | 1 - test/btyacc/err_inherit5.output | 0 test/btyacc/err_inherit5.tab.c | 15 - test/btyacc/err_inherit5.tab.h | 0 test/btyacc/err_syntax1.error | 3 - test/btyacc/err_syntax1.output | 0 test/btyacc/err_syntax1.tab.c | 15 - test/btyacc/err_syntax1.tab.h | 0 test/btyacc/err_syntax10.error | 3 - test/btyacc/err_syntax10.output | 37 - test/btyacc/err_syntax10.tab.c | 1274 ----------- test/btyacc/err_syntax10.tab.h | 5 - test/btyacc/err_syntax11.error | 1 - test/btyacc/err_syntax11.output | 35 - test/btyacc/err_syntax11.tab.c | 1280 ----------- test/btyacc/err_syntax11.tab.h | 5 - test/btyacc/err_syntax12.error | 1 - test/btyacc/err_syntax12.output | 35 - test/btyacc/err_syntax12.tab.c | 1286 ----------- test/btyacc/err_syntax12.tab.h | 6 - test/btyacc/err_syntax13.error | 1 - test/btyacc/err_syntax13.output | 0 test/btyacc/err_syntax13.tab.c | 15 - test/btyacc/err_syntax13.tab.h | 0 test/btyacc/err_syntax14.error | 2 - test/btyacc/err_syntax14.output | 0 test/btyacc/err_syntax14.tab.c | 15 - test/btyacc/err_syntax14.tab.h | 0 test/btyacc/err_syntax15.error | 1 - test/btyacc/err_syntax15.output | 0 test/btyacc/err_syntax15.tab.c | 15 - test/btyacc/err_syntax15.tab.h | 0 test/btyacc/err_syntax16.error | 1 - test/btyacc/err_syntax16.output | 0 test/btyacc/err_syntax16.tab.c | 15 - test/btyacc/err_syntax16.tab.h | 0 test/btyacc/err_syntax17.error | 3 - test/btyacc/err_syntax17.output | 0 test/btyacc/err_syntax17.tab.c | 15 - test/btyacc/err_syntax17.tab.h | 0 test/btyacc/err_syntax18.error | 1 - test/btyacc/err_syntax18.output | 52 - test/btyacc/err_syntax18.tab.c | 1289 ----------- test/btyacc/err_syntax18.tab.h | 5 - test/btyacc/err_syntax19.error | 3 - test/btyacc/err_syntax19.output | 0 test/btyacc/err_syntax19.tab.c | 15 - test/btyacc/err_syntax19.tab.h | 0 test/btyacc/err_syntax2.error | 3 - test/btyacc/err_syntax2.output | 0 test/btyacc/err_syntax2.tab.c | 15 - test/btyacc/err_syntax2.tab.h | 0 test/btyacc/err_syntax20.error | 1 - test/btyacc/err_syntax20.output | 51 - test/btyacc/err_syntax20.tab.c | 1284 ----------- test/btyacc/err_syntax20.tab.h | 6 - test/btyacc/err_syntax21.error | 1 - test/btyacc/err_syntax21.output | 0 test/btyacc/err_syntax21.tab.c | 15 - test/btyacc/err_syntax21.tab.h | 0 test/btyacc/err_syntax22.error | 1 - test/btyacc/err_syntax22.output | 0 test/btyacc/err_syntax22.tab.c | 15 - test/btyacc/err_syntax22.tab.h | 0 test/btyacc/err_syntax23.error | 1 - test/btyacc/err_syntax23.output | 0 test/btyacc/err_syntax23.tab.c | 15 - test/btyacc/err_syntax23.tab.h | 0 test/btyacc/err_syntax24.error | 2 - test/btyacc/err_syntax24.output | 0 test/btyacc/err_syntax24.tab.c | 15 - test/btyacc/err_syntax24.tab.h | 0 test/btyacc/err_syntax25.error | 3 - test/btyacc/err_syntax25.output | 0 test/btyacc/err_syntax25.tab.c | 15 - test/btyacc/err_syntax25.tab.h | 0 test/btyacc/err_syntax26.error | 1 - test/btyacc/err_syntax26.output | 0 test/btyacc/err_syntax26.tab.c | 15 - test/btyacc/err_syntax26.tab.h | 0 test/btyacc/err_syntax27.error | 1 - test/btyacc/err_syntax27.output | 0 test/btyacc/err_syntax27.tab.c | 15 - test/btyacc/err_syntax27.tab.h | 0 test/btyacc/err_syntax3.error | 3 - test/btyacc/err_syntax3.output | 0 test/btyacc/err_syntax3.tab.c | 15 - test/btyacc/err_syntax3.tab.h | 0 test/btyacc/err_syntax4.error | 3 - test/btyacc/err_syntax4.output | 0 test/btyacc/err_syntax4.tab.c | 15 - test/btyacc/err_syntax4.tab.h | 0 test/btyacc/err_syntax5.error | 3 - test/btyacc/err_syntax5.output | 0 test/btyacc/err_syntax5.tab.c | 15 - test/btyacc/err_syntax5.tab.h | 0 test/btyacc/err_syntax6.error | 3 - test/btyacc/err_syntax6.output | 0 test/btyacc/err_syntax6.tab.c | 15 - test/btyacc/err_syntax6.tab.h | 0 test/btyacc/err_syntax7.error | 3 - test/btyacc/err_syntax7.output | 0 test/btyacc/err_syntax7.tab.c | 15 - test/btyacc/err_syntax7.tab.h | 0 test/btyacc/err_syntax7a.error | 3 - test/btyacc/err_syntax7a.output | 0 test/btyacc/err_syntax7a.tab.c | 15 - test/btyacc/err_syntax7a.tab.h | 0 test/btyacc/err_syntax7b.error | 3 - test/btyacc/err_syntax7b.output | 0 test/btyacc/err_syntax7b.tab.c | 15 - test/btyacc/err_syntax7b.tab.h | 0 test/btyacc/err_syntax8.error | 1 - test/btyacc/err_syntax8.output | 0 test/btyacc/err_syntax8.tab.c | 15 - test/btyacc/err_syntax8.tab.h | 0 test/btyacc/err_syntax8a.error | 1 - test/btyacc/err_syntax8a.output | 0 test/btyacc/err_syntax8a.tab.c | 15 - test/btyacc/err_syntax8a.tab.h | 0 test/btyacc/err_syntax9.error | 1 - test/btyacc/err_syntax9.output | 0 test/btyacc/err_syntax9.tab.c | 15 - test/btyacc/err_syntax9.tab.h | 0 test/btyacc/error.error | 0 test/btyacc/error.output | 34 - test/btyacc/error.tab.c | 1279 ----------- test/btyacc/error.tab.h | 5 - test/btyacc/expr.oxout.error | 1 - test/btyacc/expr.oxout.output | 227 -- test/btyacc/expr.oxout.tab.c | 2768 ----------------------- test/btyacc/expr.oxout.tab.h | 20 - test/btyacc/grammar.dot | 906 -------- test/btyacc/grammar.error | 1 - test/btyacc/grammar.output | 2304 ------------------- test/btyacc/grammar.tab.c | 3010 ------------------------- test/btyacc/grammar.tab.h | 40 - test/btyacc/help.error | 31 - test/btyacc/help.output | 0 test/btyacc/inherit0.error | 0 test/btyacc/inherit0.output | 165 -- test/btyacc/inherit0.tab.c | 1354 ----------- test/btyacc/inherit0.tab.h | 10 - test/btyacc/inherit1.error | 0 test/btyacc/inherit1.output | 165 -- test/btyacc/inherit1.tab.c | 1379 ----------- test/btyacc/inherit1.tab.h | 25 - test/btyacc/inherit2.error | 0 test/btyacc/inherit2.output | 186 -- test/btyacc/inherit2.tab.c | 1439 ------------ test/btyacc/inherit2.tab.h | 25 - test/btyacc/no_b_opt.error | 31 - test/btyacc/no_b_opt.output | 0 test/btyacc/no_b_opt1.error | 1 - test/btyacc/no_b_opt1.output | 0 test/btyacc/no_code_c.error | 1 - test/btyacc/no_code_c.output | 0 test/btyacc/no_defines.error | 1 - test/btyacc/no_defines.output | 0 test/btyacc/no_graph.error | 1 - test/btyacc/no_graph.output | 0 test/btyacc/no_include.error | 1 - test/btyacc/no_include.output | 0 test/btyacc/no_opts.error | 1 - test/btyacc/no_opts.output | 0 test/btyacc/no_output.error | 1 - test/btyacc/no_output.output | 0 test/btyacc/no_output1.error | 1 - test/btyacc/no_output1.output | 0 test/btyacc/no_output2.error | 31 - test/btyacc/no_output2.output | 0 test/btyacc/no_p_opt.error | 31 - test/btyacc/no_p_opt.output | 0 test/btyacc/no_p_opt1.error | 1 - test/btyacc/no_p_opt1.output | 0 test/btyacc/no_verbose.error | 1 - test/btyacc/no_verbose.output | 0 test/btyacc/nostdin.error | 30 - test/btyacc/nostdin.output | 0 test/btyacc/ok_syntax1.error | 0 test/btyacc/ok_syntax1.output | 511 ----- test/btyacc/ok_syntax1.tab.c | 1539 ------------- test/btyacc/ok_syntax1.tab.h | 34 - test/btyacc/pure_calc.error | 0 test/btyacc/pure_calc.output | 485 ---- test/btyacc/pure_calc.tab.c | 1512 ------------- test/btyacc/pure_calc.tab.h | 8 - test/btyacc/pure_error.error | 0 test/btyacc/pure_error.output | 34 - test/btyacc/pure_error.tab.c | 1304 ----------- test/btyacc/pure_error.tab.h | 5 - test/btyacc/quote_calc-s.error | 1 - test/btyacc/quote_calc-s.output | 593 ----- test/btyacc/quote_calc-s.tab.c | 1507 ------------- test/btyacc/quote_calc-s.tab.h | 14 - test/btyacc/quote_calc.error | 1 - test/btyacc/quote_calc.output | 593 ----- test/btyacc/quote_calc.tab.c | 1513 ------------- test/btyacc/quote_calc.tab.h | 20 - test/btyacc/quote_calc2-s.error | 1 - test/btyacc/quote_calc2-s.output | 593 ----- test/btyacc/quote_calc2-s.tab.c | 1507 ------------- test/btyacc/quote_calc2-s.tab.h | 14 - test/btyacc/quote_calc2.error | 1 - test/btyacc/quote_calc2.output | 593 ----- test/btyacc/quote_calc2.tab.c | 1513 ------------- test/btyacc/quote_calc2.tab.h | 20 - test/btyacc/quote_calc3-s.error | 1 - test/btyacc/quote_calc3-s.output | 593 ----- test/btyacc/quote_calc3-s.tab.c | 1508 ------------- test/btyacc/quote_calc3-s.tab.h | 14 - test/btyacc/quote_calc3.error | 1 - test/btyacc/quote_calc3.output | 593 ----- test/btyacc/quote_calc3.tab.c | 1508 ------------- test/btyacc/quote_calc3.tab.h | 14 - test/btyacc/quote_calc4-s.error | 1 - test/btyacc/quote_calc4-s.output | 593 ----- test/btyacc/quote_calc4-s.tab.c | 1508 ------------- test/btyacc/quote_calc4-s.tab.h | 14 - test/btyacc/quote_calc4.error | 1 - test/btyacc/quote_calc4.output | 593 ----- test/btyacc/quote_calc4.tab.c | 1508 ------------- test/btyacc/quote_calc4.tab.h | 14 - test/btyacc/rename_debug.c | 1142 ---------- test/btyacc/rename_debug.error | 0 test/btyacc/rename_debug.h | 6 - test/btyacc/rename_debug.i | 71 - test/btyacc/rename_debug.output | 34 - test/btyacc/stdin1.calc.c | 1396 ------------ test/btyacc/stdin1.error | 0 test/btyacc/stdin1.output | 0 test/btyacc/stdin2.calc.c | 1396 ------------ test/btyacc/stdin2.error | 0 test/btyacc/stdin2.output | 0 test/btyacc/varsyntax_calc1.error | 2 - test/btyacc/varsyntax_calc1.output | 900 -------- test/btyacc/varsyntax_calc1.tab.c | 1747 -------------- test/btyacc/varsyntax_calc1.tab.h | 23 - test/btyacc_calc1.y | 324 --- test/btyacc_demo.y | 226 -- test/btyacc_destroy1.y | 91 - test/btyacc_destroy2.y | 91 - test/btyacc_destroy3.y | 94 - test/calc.y | 106 - test/calc1.y | 305 --- test/calc2.y | 124 - test/calc3.y | 127 -- test/calc_code_all.y | 113 - test/calc_code_default.y | 109 - test/calc_code_imports.y | 109 - test/calc_code_provides.y | 109 - test/calc_code_requires.y | 109 - test/calc_code_top.y | 109 - test/code_calc.y | 114 - test/code_debug.y | 36 - test/code_error.y | 36 - test/empty.y | 24 - test/err_inherit1.y | 64 - test/err_inherit2.y | 80 - test/err_inherit3.y | 80 - test/err_inherit4.y | 82 - test/err_inherit5.y | 80 - test/err_syntax1.y | 28 - test/err_syntax10.y | 32 - test/err_syntax11.y | 32 - test/err_syntax12.y | 32 - test/err_syntax13.y | 32 - test/err_syntax14.y | 32 - test/err_syntax15.y | 32 - test/err_syntax16.y | 40 - test/err_syntax17.y | 30 - test/err_syntax18.y | 33 - test/err_syntax19.y | 33 - test/err_syntax2.y | 28 - test/err_syntax20.y | 36 - test/err_syntax21.y | 36 - test/err_syntax22.y | 44 - test/err_syntax23.y | 46 - test/err_syntax24.y | 46 - test/err_syntax25.y | 51 - test/err_syntax26.y | 6 - test/err_syntax27.y | 127 -- test/err_syntax3.y | 31 - test/err_syntax4.y | 28 - test/err_syntax5.y | 33 - test/err_syntax6.y | 31 - test/err_syntax7.y | 31 - test/err_syntax7a.y | 31 - test/err_syntax7b.y | 31 - test/err_syntax8.y | 31 - test/err_syntax8a.y | 31 - test/err_syntax9.y | 32 - test/error.y | 28 - test/expr.oxout.y | 1446 ------------ test/grammar.y | 1184 ---------- test/inherit0.y | 48 - test/inherit1.y | 76 - test/inherit2.y | 80 - test/ok_syntax1.y | 155 -- test/pure_calc.y | 116 - test/pure_error.y | 41 - test/quote_calc.y | 112 - test/quote_calc2.y | 112 - test/quote_calc3.y | 112 - test/quote_calc4.y | 112 - test/run_lint.sh | 29 - test/run_make.sh | 196 -- test/run_test.sh | 311 --- test/varsyntax_calc1.y | 307 --- test/yacc/big_b.error | 31 - test/yacc/big_b.output | 0 test/yacc/big_l.error | 31 - test/yacc/big_l.output | 0 test/yacc/calc.error | 0 test/yacc/calc.output | 461 ---- test/yacc/calc.tab.c | 686 ------ test/yacc/calc.tab.h | 3 - test/yacc/calc1.error | 2 - test/yacc/calc1.output | 877 ------- test/yacc/calc1.tab.c | 936 -------- test/yacc/calc1.tab.h | 18 - test/yacc/calc2.error | 0 test/yacc/calc2.output | 461 ---- test/yacc/calc2.tab.c | 699 ------ test/yacc/calc2.tab.h | 3 - test/yacc/calc3.error | 0 test/yacc/calc3.output | 461 ---- test/yacc/calc3.tab.c | 707 ------ test/yacc/calc3.tab.h | 3 - test/yacc/calc_code_all.error | 0 test/yacc/calc_code_all.output | 461 ---- test/yacc/calc_code_all.tab.c | 714 ------ test/yacc/calc_code_all.tab.h | 13 - test/yacc/calc_code_default.error | 0 test/yacc/calc_code_default.output | 461 ---- test/yacc/calc_code_default.tab.c | 694 ------ test/yacc/calc_code_default.tab.h | 3 - test/yacc/calc_code_imports.error | 0 test/yacc/calc_code_imports.output | 461 ---- test/yacc/calc_code_imports.tab.c | 686 ------ test/yacc/calc_code_imports.tab.h | 3 - test/yacc/calc_code_provides.error | 0 test/yacc/calc_code_provides.output | 461 ---- test/yacc/calc_code_provides.tab.c | 694 ------ test/yacc/calc_code_provides.tab.h | 9 - test/yacc/calc_code_requires.error | 0 test/yacc/calc_code_requires.output | 461 ---- test/yacc/calc_code_requires.tab.c | 694 ------ test/yacc/calc_code_requires.tab.h | 9 - test/yacc/calc_code_top.error | 0 test/yacc/calc_code_top.output | 461 ---- test/yacc/calc_code_top.tab.c | 694 ------ test/yacc/calc_code_top.tab.h | 3 - test/yacc/code_calc.code.c | 595 ----- test/yacc/code_calc.error | 0 test/yacc/code_calc.output | 461 ---- test/yacc/code_calc.tab.c | 119 - test/yacc/code_calc.tab.h | 5 - test/yacc/code_error.code.c | 489 ---- test/yacc/code_error.error | 0 test/yacc/code_error.output | 27 - test/yacc/code_error.tab.c | 44 - test/yacc/code_error.tab.h | 0 test/yacc/defines1.calc.c | 610 ----- test/yacc/defines1.calc.h | 3 - test/yacc/defines1.error | 0 test/yacc/defines1.output | 0 test/yacc/defines2.calc.c | 610 ----- test/yacc/defines2.calc.h | 3 - test/yacc/defines2.error | 0 test/yacc/defines2.output | 0 test/yacc/defines3.calc.c | 610 ----- test/yacc/defines3.calc.h | 3 - test/yacc/defines3.error | 0 test/yacc/defines3.output | 0 test/yacc/empty.error | 0 test/yacc/empty.output | 21 - test/yacc/empty.tab.c | 500 ---- test/yacc/empty.tab.h | 0 test/yacc/err_syntax1.error | 3 - test/yacc/err_syntax1.output | 0 test/yacc/err_syntax1.tab.c | 15 - test/yacc/err_syntax1.tab.h | 0 test/yacc/err_syntax10.error | 3 - test/yacc/err_syntax10.output | 27 - test/yacc/err_syntax10.tab.c | 499 ---- test/yacc/err_syntax10.tab.h | 0 test/yacc/err_syntax11.error | 1 - test/yacc/err_syntax11.output | 27 - test/yacc/err_syntax11.tab.c | 505 ----- test/yacc/err_syntax11.tab.h | 0 test/yacc/err_syntax12.error | 1 - test/yacc/err_syntax12.output | 27 - test/yacc/err_syntax12.tab.c | 511 ----- test/yacc/err_syntax12.tab.h | 1 - test/yacc/err_syntax13.error | 1 - test/yacc/err_syntax13.output | 0 test/yacc/err_syntax13.tab.c | 15 - test/yacc/err_syntax13.tab.h | 0 test/yacc/err_syntax14.error | 2 - test/yacc/err_syntax14.output | 0 test/yacc/err_syntax14.tab.c | 15 - test/yacc/err_syntax14.tab.h | 0 test/yacc/err_syntax15.error | 1 - test/yacc/err_syntax15.output | 0 test/yacc/err_syntax15.tab.c | 15 - test/yacc/err_syntax15.tab.h | 0 test/yacc/err_syntax16.error | 1 - test/yacc/err_syntax16.output | 0 test/yacc/err_syntax16.tab.c | 15 - test/yacc/err_syntax16.tab.h | 0 test/yacc/err_syntax17.error | 3 - test/yacc/err_syntax17.output | 0 test/yacc/err_syntax17.tab.c | 15 - test/yacc/err_syntax17.tab.h | 0 test/yacc/err_syntax18.error | 1 - test/yacc/err_syntax18.output | 43 - test/yacc/err_syntax18.tab.c | 513 ----- test/yacc/err_syntax18.tab.h | 0 test/yacc/err_syntax19.error | 3 - test/yacc/err_syntax19.output | 0 test/yacc/err_syntax19.tab.c | 15 - test/yacc/err_syntax19.tab.h | 0 test/yacc/err_syntax2.error | 3 - test/yacc/err_syntax2.output | 0 test/yacc/err_syntax2.tab.c | 15 - test/yacc/err_syntax2.tab.h | 0 test/yacc/err_syntax20.error | 1 - test/yacc/err_syntax20.output | 41 - test/yacc/err_syntax20.tab.c | 509 ----- test/yacc/err_syntax20.tab.h | 1 - test/yacc/err_syntax21.error | 1 - test/yacc/err_syntax21.output | 0 test/yacc/err_syntax21.tab.c | 15 - test/yacc/err_syntax21.tab.h | 0 test/yacc/err_syntax22.error | 1 - test/yacc/err_syntax22.output | 0 test/yacc/err_syntax22.tab.c | 15 - test/yacc/err_syntax22.tab.h | 0 test/yacc/err_syntax23.error | 1 - test/yacc/err_syntax23.output | 0 test/yacc/err_syntax23.tab.c | 15 - test/yacc/err_syntax23.tab.h | 0 test/yacc/err_syntax24.error | 2 - test/yacc/err_syntax24.output | 0 test/yacc/err_syntax24.tab.c | 15 - test/yacc/err_syntax24.tab.h | 0 test/yacc/err_syntax25.error | 3 - test/yacc/err_syntax25.output | 0 test/yacc/err_syntax25.tab.c | 15 - test/yacc/err_syntax25.tab.h | 0 test/yacc/err_syntax26.error | 1 - test/yacc/err_syntax26.output | 0 test/yacc/err_syntax26.tab.c | 15 - test/yacc/err_syntax26.tab.h | 0 test/yacc/err_syntax27.error | 1 - test/yacc/err_syntax27.output | 0 test/yacc/err_syntax27.tab.c | 15 - test/yacc/err_syntax27.tab.h | 0 test/yacc/err_syntax3.error | 3 - test/yacc/err_syntax3.output | 0 test/yacc/err_syntax3.tab.c | 15 - test/yacc/err_syntax3.tab.h | 0 test/yacc/err_syntax4.error | 3 - test/yacc/err_syntax4.output | 0 test/yacc/err_syntax4.tab.c | 15 - test/yacc/err_syntax4.tab.h | 0 test/yacc/err_syntax5.error | 3 - test/yacc/err_syntax5.output | 0 test/yacc/err_syntax5.tab.c | 15 - test/yacc/err_syntax5.tab.h | 0 test/yacc/err_syntax6.error | 3 - test/yacc/err_syntax6.output | 0 test/yacc/err_syntax6.tab.c | 15 - test/yacc/err_syntax6.tab.h | 0 test/yacc/err_syntax7.error | 3 - test/yacc/err_syntax7.output | 0 test/yacc/err_syntax7.tab.c | 15 - test/yacc/err_syntax7.tab.h | 0 test/yacc/err_syntax7a.error | 3 - test/yacc/err_syntax7a.output | 0 test/yacc/err_syntax7a.tab.c | 15 - test/yacc/err_syntax7a.tab.h | 0 test/yacc/err_syntax7b.error | 3 - test/yacc/err_syntax7b.output | 0 test/yacc/err_syntax7b.tab.c | 15 - test/yacc/err_syntax7b.tab.h | 0 test/yacc/err_syntax8.error | 1 - test/yacc/err_syntax8.output | 0 test/yacc/err_syntax8.tab.c | 15 - test/yacc/err_syntax8.tab.h | 0 test/yacc/err_syntax8a.error | 1 - test/yacc/err_syntax8a.output | 0 test/yacc/err_syntax8a.tab.c | 15 - test/yacc/err_syntax8a.tab.h | 0 test/yacc/err_syntax9.error | 1 - test/yacc/err_syntax9.output | 0 test/yacc/err_syntax9.tab.c | 15 - test/yacc/err_syntax9.tab.h | 0 test/yacc/error.error | 0 test/yacc/error.output | 27 - test/yacc/error.tab.c | 505 ----- test/yacc/error.tab.h | 0 test/yacc/expr.oxout.error | 1 - test/yacc/expr.oxout.output | 209 -- test/yacc/expr.oxout.tab.c | 1970 ---------------- test/yacc/expr.oxout.tab.h | 15 - test/yacc/grammar.dot | 906 -------- test/yacc/grammar.error | 1 - test/yacc/grammar.output | 2214 ------------------ test/yacc/grammar.tab.c | 2106 ----------------- test/yacc/grammar.tab.h | 35 - test/yacc/help.error | 31 - test/yacc/help.output | 0 test/yacc/no_b_opt.error | 31 - test/yacc/no_b_opt.output | 0 test/yacc/no_b_opt1.error | 1 - test/yacc/no_b_opt1.output | 0 test/yacc/no_code_c.error | 1 - test/yacc/no_code_c.output | 0 test/yacc/no_defines.error | 1 - test/yacc/no_defines.output | 0 test/yacc/no_graph.error | 1 - test/yacc/no_graph.output | 0 test/yacc/no_include.error | 1 - test/yacc/no_include.output | 0 test/yacc/no_opts.error | 1 - test/yacc/no_opts.output | 0 test/yacc/no_output.error | 1 - test/yacc/no_output.output | 0 test/yacc/no_output1.error | 1 - test/yacc/no_output1.output | 0 test/yacc/no_output2.error | 31 - test/yacc/no_output2.output | 0 test/yacc/no_p_opt.error | 31 - test/yacc/no_p_opt.output | 0 test/yacc/no_p_opt1.error | 1 - test/yacc/no_p_opt1.output | 0 test/yacc/no_verbose.error | 1 - test/yacc/no_verbose.output | 0 test/yacc/nostdin.error | 30 - test/yacc/nostdin.output | 0 test/yacc/ok_syntax1.error | 0 test/yacc/ok_syntax1.output | 461 ---- test/yacc/ok_syntax1.tab.c | 731 ------ test/yacc/ok_syntax1.tab.h | 29 - test/yacc/pure_calc.error | 0 test/yacc/pure_calc.output | 461 ---- test/yacc/pure_calc.tab.c | 703 ------ test/yacc/pure_calc.tab.h | 3 - test/yacc/pure_error.error | 0 test/yacc/pure_error.output | 27 - test/yacc/pure_error.tab.c | 524 ----- test/yacc/pure_error.tab.h | 0 test/yacc/quote_calc-s.error | 1 - test/yacc/quote_calc-s.output | 557 ----- test/yacc/quote_calc-s.tab.c | 701 ------ test/yacc/quote_calc-s.tab.h | 9 - test/yacc/quote_calc.error | 1 - test/yacc/quote_calc.output | 557 ----- test/yacc/quote_calc.tab.c | 707 ------ test/yacc/quote_calc.tab.h | 15 - test/yacc/quote_calc2-s.error | 1 - test/yacc/quote_calc2-s.output | 557 ----- test/yacc/quote_calc2-s.tab.c | 701 ------ test/yacc/quote_calc2-s.tab.h | 9 - test/yacc/quote_calc2.error | 1 - test/yacc/quote_calc2.output | 557 ----- test/yacc/quote_calc2.tab.c | 707 ------ test/yacc/quote_calc2.tab.h | 15 - test/yacc/quote_calc3-s.error | 1 - test/yacc/quote_calc3-s.output | 557 ----- test/yacc/quote_calc3-s.tab.c | 702 ------ test/yacc/quote_calc3-s.tab.h | 9 - test/yacc/quote_calc3.error | 1 - test/yacc/quote_calc3.output | 557 ----- test/yacc/quote_calc3.tab.c | 702 ------ test/yacc/quote_calc3.tab.h | 9 - test/yacc/quote_calc4-s.error | 1 - test/yacc/quote_calc4-s.output | 557 ----- test/yacc/quote_calc4-s.tab.c | 702 ------ test/yacc/quote_calc4-s.tab.h | 9 - test/yacc/quote_calc4.error | 1 - test/yacc/quote_calc4.output | 557 ----- test/yacc/quote_calc4.tab.c | 702 ------ test/yacc/quote_calc4.tab.h | 9 - test/yacc/rename_debug.c | 385 ---- test/yacc/rename_debug.error | 0 test/yacc/rename_debug.h | 1 - test/yacc/rename_debug.i | 66 - test/yacc/rename_debug.output | 27 - test/yacc/stdin1.calc.c | 610 ----- test/yacc/stdin1.error | 0 test/yacc/stdin1.output | 0 test/yacc/stdin2.calc.c | 610 ----- test/yacc/stdin2.error | 0 test/yacc/stdin2.output | 0 test/yacc/varsyntax_calc1.error | 2 - test/yacc/varsyntax_calc1.output | 877 ------- test/yacc/varsyntax_calc1.tab.c | 937 -------- test/yacc/varsyntax_calc1.tab.h | 18 - yacc.1 | 57 +- 736 files changed, 1958 insertions(+), 150941 deletions(-) delete mode 100644 package/byacc.spec delete mode 100644 package/debian/changelog delete mode 100644 package/debian/control delete mode 100644 package/debian/copyright delete mode 100755 package/debian/rules delete mode 100644 package/debian/source/format delete mode 100644 package/debian/watch delete mode 100644 package/mingw-byacc.spec delete mode 100644 package/pkgsrc/DESCR delete mode 100644 package/pkgsrc/Makefile delete mode 100644 package/pkgsrc/PLIST delete mode 100644 package/pkgsrc/distinfo delete mode 100644 test/README delete mode 100644 test/btyacc/big_b.error delete mode 100644 test/btyacc/big_b.output delete mode 100644 test/btyacc/big_l.error delete mode 100644 test/btyacc/big_l.output delete mode 100644 test/btyacc/btyacc_calc1.error delete mode 100644 test/btyacc/btyacc_calc1.output delete mode 100644 test/btyacc/btyacc_calc1.tab.c delete mode 100644 test/btyacc/btyacc_calc1.tab.h delete mode 100644 test/btyacc/btyacc_demo.error delete mode 100644 test/btyacc/btyacc_demo.output delete mode 100644 test/btyacc/btyacc_demo.tab.c delete mode 100644 test/btyacc/btyacc_demo.tab.h delete mode 100644 test/btyacc/btyacc_destroy1.error delete mode 100644 test/btyacc/btyacc_destroy1.output delete mode 100644 test/btyacc/btyacc_destroy1.tab.c delete mode 100644 test/btyacc/btyacc_destroy1.tab.h delete mode 100644 test/btyacc/btyacc_destroy2.error delete mode 100644 test/btyacc/btyacc_destroy2.output delete mode 100644 test/btyacc/btyacc_destroy2.tab.c delete mode 100644 test/btyacc/btyacc_destroy2.tab.h delete mode 100644 test/btyacc/btyacc_destroy3.error delete mode 100644 test/btyacc/btyacc_destroy3.output delete mode 100644 test/btyacc/btyacc_destroy3.tab.c delete mode 100644 test/btyacc/btyacc_destroy3.tab.h delete mode 100644 test/btyacc/calc.error delete mode 100644 test/btyacc/calc.output delete mode 100644 test/btyacc/calc.tab.c delete mode 100644 test/btyacc/calc.tab.h delete mode 100644 test/btyacc/calc1.error delete mode 100644 test/btyacc/calc1.output delete mode 100644 test/btyacc/calc1.tab.c delete mode 100644 test/btyacc/calc1.tab.h delete mode 100644 test/btyacc/calc2.error delete mode 100644 test/btyacc/calc2.output delete mode 100644 test/btyacc/calc2.tab.c delete mode 100644 test/btyacc/calc2.tab.h delete mode 100644 test/btyacc/calc3.error delete mode 100644 test/btyacc/calc3.output delete mode 100644 test/btyacc/calc3.tab.c delete mode 100644 test/btyacc/calc3.tab.h delete mode 100644 test/btyacc/calc_code_all.error delete mode 100644 test/btyacc/calc_code_all.output delete mode 100644 test/btyacc/calc_code_all.tab.c delete mode 100644 test/btyacc/calc_code_all.tab.h delete mode 100644 test/btyacc/calc_code_default.error delete mode 100644 test/btyacc/calc_code_default.output delete mode 100644 test/btyacc/calc_code_default.tab.c delete mode 100644 test/btyacc/calc_code_default.tab.h delete mode 100644 test/btyacc/calc_code_imports.error delete mode 100644 test/btyacc/calc_code_imports.output delete mode 100644 test/btyacc/calc_code_imports.tab.c delete mode 100644 test/btyacc/calc_code_imports.tab.h delete mode 100644 test/btyacc/calc_code_provides.error delete mode 100644 test/btyacc/calc_code_provides.output delete mode 100644 test/btyacc/calc_code_provides.tab.c delete mode 100644 test/btyacc/calc_code_provides.tab.h delete mode 100644 test/btyacc/calc_code_requires.error delete mode 100644 test/btyacc/calc_code_requires.output delete mode 100644 test/btyacc/calc_code_requires.tab.c delete mode 100644 test/btyacc/calc_code_requires.tab.h delete mode 100644 test/btyacc/calc_code_top.error delete mode 100644 test/btyacc/calc_code_top.output delete mode 100644 test/btyacc/calc_code_top.tab.c delete mode 100644 test/btyacc/calc_code_top.tab.h delete mode 100644 test/btyacc/code_calc.code.c delete mode 100644 test/btyacc/code_calc.error delete mode 100644 test/btyacc/code_calc.output delete mode 100644 test/btyacc/code_calc.tab.c delete mode 100644 test/btyacc/code_calc.tab.h delete mode 100644 test/btyacc/code_error.code.c delete mode 100644 test/btyacc/code_error.error delete mode 100644 test/btyacc/code_error.output delete mode 100644 test/btyacc/code_error.tab.c delete mode 100644 test/btyacc/code_error.tab.h delete mode 100644 test/btyacc/defines1.calc.c delete mode 100644 test/btyacc/defines1.calc.h delete mode 100644 test/btyacc/defines1.error delete mode 100644 test/btyacc/defines1.output delete mode 100644 test/btyacc/defines2.calc.c delete mode 100644 test/btyacc/defines2.calc.h delete mode 100644 test/btyacc/defines2.error delete mode 100644 test/btyacc/defines2.output delete mode 100644 test/btyacc/defines3.calc.c delete mode 100644 test/btyacc/defines3.calc.h delete mode 100644 test/btyacc/defines3.error delete mode 100644 test/btyacc/defines3.output delete mode 100644 test/btyacc/empty.error delete mode 100644 test/btyacc/empty.output delete mode 100644 test/btyacc/empty.tab.c delete mode 100644 test/btyacc/empty.tab.h delete mode 100644 test/btyacc/err_inherit1.error delete mode 100644 test/btyacc/err_inherit1.output delete mode 100644 test/btyacc/err_inherit1.tab.c delete mode 100644 test/btyacc/err_inherit1.tab.h delete mode 100644 test/btyacc/err_inherit2.error delete mode 100644 test/btyacc/err_inherit2.output delete mode 100644 test/btyacc/err_inherit2.tab.c delete mode 100644 test/btyacc/err_inherit2.tab.h delete mode 100644 test/btyacc/err_inherit3.error delete mode 100644 test/btyacc/err_inherit3.output delete mode 100644 test/btyacc/err_inherit3.tab.c delete mode 100644 test/btyacc/err_inherit3.tab.h delete mode 100644 test/btyacc/err_inherit4.error delete mode 100644 test/btyacc/err_inherit4.output delete mode 100644 test/btyacc/err_inherit4.tab.c delete mode 100644 test/btyacc/err_inherit4.tab.h delete mode 100644 test/btyacc/err_inherit5.error delete mode 100644 test/btyacc/err_inherit5.output delete mode 100644 test/btyacc/err_inherit5.tab.c delete mode 100644 test/btyacc/err_inherit5.tab.h delete mode 100644 test/btyacc/err_syntax1.error delete mode 100644 test/btyacc/err_syntax1.output delete mode 100644 test/btyacc/err_syntax1.tab.c delete mode 100644 test/btyacc/err_syntax1.tab.h delete mode 100644 test/btyacc/err_syntax10.error delete mode 100644 test/btyacc/err_syntax10.output delete mode 100644 test/btyacc/err_syntax10.tab.c delete mode 100644 test/btyacc/err_syntax10.tab.h delete mode 100644 test/btyacc/err_syntax11.error delete mode 100644 test/btyacc/err_syntax11.output delete mode 100644 test/btyacc/err_syntax11.tab.c delete mode 100644 test/btyacc/err_syntax11.tab.h delete mode 100644 test/btyacc/err_syntax12.error delete mode 100644 test/btyacc/err_syntax12.output delete mode 100644 test/btyacc/err_syntax12.tab.c delete mode 100644 test/btyacc/err_syntax12.tab.h delete mode 100644 test/btyacc/err_syntax13.error delete mode 100644 test/btyacc/err_syntax13.output delete mode 100644 test/btyacc/err_syntax13.tab.c delete mode 100644 test/btyacc/err_syntax13.tab.h delete mode 100644 test/btyacc/err_syntax14.error delete mode 100644 test/btyacc/err_syntax14.output delete mode 100644 test/btyacc/err_syntax14.tab.c delete mode 100644 test/btyacc/err_syntax14.tab.h delete mode 100644 test/btyacc/err_syntax15.error delete mode 100644 test/btyacc/err_syntax15.output delete mode 100644 test/btyacc/err_syntax15.tab.c delete mode 100644 test/btyacc/err_syntax15.tab.h delete mode 100644 test/btyacc/err_syntax16.error delete mode 100644 test/btyacc/err_syntax16.output delete mode 100644 test/btyacc/err_syntax16.tab.c delete mode 100644 test/btyacc/err_syntax16.tab.h delete mode 100644 test/btyacc/err_syntax17.error delete mode 100644 test/btyacc/err_syntax17.output delete mode 100644 test/btyacc/err_syntax17.tab.c delete mode 100644 test/btyacc/err_syntax17.tab.h delete mode 100644 test/btyacc/err_syntax18.error delete mode 100644 test/btyacc/err_syntax18.output delete mode 100644 test/btyacc/err_syntax18.tab.c delete mode 100644 test/btyacc/err_syntax18.tab.h delete mode 100644 test/btyacc/err_syntax19.error delete mode 100644 test/btyacc/err_syntax19.output delete mode 100644 test/btyacc/err_syntax19.tab.c delete mode 100644 test/btyacc/err_syntax19.tab.h delete mode 100644 test/btyacc/err_syntax2.error delete mode 100644 test/btyacc/err_syntax2.output delete mode 100644 test/btyacc/err_syntax2.tab.c delete mode 100644 test/btyacc/err_syntax2.tab.h delete mode 100644 test/btyacc/err_syntax20.error delete mode 100644 test/btyacc/err_syntax20.output delete mode 100644 test/btyacc/err_syntax20.tab.c delete mode 100644 test/btyacc/err_syntax20.tab.h delete mode 100644 test/btyacc/err_syntax21.error delete mode 100644 test/btyacc/err_syntax21.output delete mode 100644 test/btyacc/err_syntax21.tab.c delete mode 100644 test/btyacc/err_syntax21.tab.h delete mode 100644 test/btyacc/err_syntax22.error delete mode 100644 test/btyacc/err_syntax22.output delete mode 100644 test/btyacc/err_syntax22.tab.c delete mode 100644 test/btyacc/err_syntax22.tab.h delete mode 100644 test/btyacc/err_syntax23.error delete mode 100644 test/btyacc/err_syntax23.output delete mode 100644 test/btyacc/err_syntax23.tab.c delete mode 100644 test/btyacc/err_syntax23.tab.h delete mode 100644 test/btyacc/err_syntax24.error delete mode 100644 test/btyacc/err_syntax24.output delete mode 100644 test/btyacc/err_syntax24.tab.c delete mode 100644 test/btyacc/err_syntax24.tab.h delete mode 100644 test/btyacc/err_syntax25.error delete mode 100644 test/btyacc/err_syntax25.output delete mode 100644 test/btyacc/err_syntax25.tab.c delete mode 100644 test/btyacc/err_syntax25.tab.h delete mode 100644 test/btyacc/err_syntax26.error delete mode 100644 test/btyacc/err_syntax26.output delete mode 100644 test/btyacc/err_syntax26.tab.c delete mode 100644 test/btyacc/err_syntax26.tab.h delete mode 100644 test/btyacc/err_syntax27.error delete mode 100644 test/btyacc/err_syntax27.output delete mode 100644 test/btyacc/err_syntax27.tab.c delete mode 100644 test/btyacc/err_syntax27.tab.h delete mode 100644 test/btyacc/err_syntax3.error delete mode 100644 test/btyacc/err_syntax3.output delete mode 100644 test/btyacc/err_syntax3.tab.c delete mode 100644 test/btyacc/err_syntax3.tab.h delete mode 100644 test/btyacc/err_syntax4.error delete mode 100644 test/btyacc/err_syntax4.output delete mode 100644 test/btyacc/err_syntax4.tab.c delete mode 100644 test/btyacc/err_syntax4.tab.h delete mode 100644 test/btyacc/err_syntax5.error delete mode 100644 test/btyacc/err_syntax5.output delete mode 100644 test/btyacc/err_syntax5.tab.c delete mode 100644 test/btyacc/err_syntax5.tab.h delete mode 100644 test/btyacc/err_syntax6.error delete mode 100644 test/btyacc/err_syntax6.output delete mode 100644 test/btyacc/err_syntax6.tab.c delete mode 100644 test/btyacc/err_syntax6.tab.h delete mode 100644 test/btyacc/err_syntax7.error delete mode 100644 test/btyacc/err_syntax7.output delete mode 100644 test/btyacc/err_syntax7.tab.c delete mode 100644 test/btyacc/err_syntax7.tab.h delete mode 100644 test/btyacc/err_syntax7a.error delete mode 100644 test/btyacc/err_syntax7a.output delete mode 100644 test/btyacc/err_syntax7a.tab.c delete mode 100644 test/btyacc/err_syntax7a.tab.h delete mode 100644 test/btyacc/err_syntax7b.error delete mode 100644 test/btyacc/err_syntax7b.output delete mode 100644 test/btyacc/err_syntax7b.tab.c delete mode 100644 test/btyacc/err_syntax7b.tab.h delete mode 100644 test/btyacc/err_syntax8.error delete mode 100644 test/btyacc/err_syntax8.output delete mode 100644 test/btyacc/err_syntax8.tab.c delete mode 100644 test/btyacc/err_syntax8.tab.h delete mode 100644 test/btyacc/err_syntax8a.error delete mode 100644 test/btyacc/err_syntax8a.output delete mode 100644 test/btyacc/err_syntax8a.tab.c delete mode 100644 test/btyacc/err_syntax8a.tab.h delete mode 100644 test/btyacc/err_syntax9.error delete mode 100644 test/btyacc/err_syntax9.output delete mode 100644 test/btyacc/err_syntax9.tab.c delete mode 100644 test/btyacc/err_syntax9.tab.h delete mode 100644 test/btyacc/error.error delete mode 100644 test/btyacc/error.output delete mode 100644 test/btyacc/error.tab.c delete mode 100644 test/btyacc/error.tab.h delete mode 100644 test/btyacc/expr.oxout.error delete mode 100644 test/btyacc/expr.oxout.output delete mode 100644 test/btyacc/expr.oxout.tab.c delete mode 100644 test/btyacc/expr.oxout.tab.h delete mode 100644 test/btyacc/grammar.dot delete mode 100644 test/btyacc/grammar.error delete mode 100644 test/btyacc/grammar.output delete mode 100644 test/btyacc/grammar.tab.c delete mode 100644 test/btyacc/grammar.tab.h delete mode 100644 test/btyacc/help.error delete mode 100644 test/btyacc/help.output delete mode 100644 test/btyacc/inherit0.error delete mode 100644 test/btyacc/inherit0.output delete mode 100644 test/btyacc/inherit0.tab.c delete mode 100644 test/btyacc/inherit0.tab.h delete mode 100644 test/btyacc/inherit1.error delete mode 100644 test/btyacc/inherit1.output delete mode 100644 test/btyacc/inherit1.tab.c delete mode 100644 test/btyacc/inherit1.tab.h delete mode 100644 test/btyacc/inherit2.error delete mode 100644 test/btyacc/inherit2.output delete mode 100644 test/btyacc/inherit2.tab.c delete mode 100644 test/btyacc/inherit2.tab.h delete mode 100644 test/btyacc/no_b_opt.error delete mode 100644 test/btyacc/no_b_opt.output delete mode 100644 test/btyacc/no_b_opt1.error delete mode 100644 test/btyacc/no_b_opt1.output delete mode 100644 test/btyacc/no_code_c.error delete mode 100644 test/btyacc/no_code_c.output delete mode 100644 test/btyacc/no_defines.error delete mode 100644 test/btyacc/no_defines.output delete mode 100644 test/btyacc/no_graph.error delete mode 100644 test/btyacc/no_graph.output delete mode 100644 test/btyacc/no_include.error delete mode 100644 test/btyacc/no_include.output delete mode 100644 test/btyacc/no_opts.error delete mode 100644 test/btyacc/no_opts.output delete mode 100644 test/btyacc/no_output.error delete mode 100644 test/btyacc/no_output.output delete mode 100644 test/btyacc/no_output1.error delete mode 100644 test/btyacc/no_output1.output delete mode 100644 test/btyacc/no_output2.error delete mode 100644 test/btyacc/no_output2.output delete mode 100644 test/btyacc/no_p_opt.error delete mode 100644 test/btyacc/no_p_opt.output delete mode 100644 test/btyacc/no_p_opt1.error delete mode 100644 test/btyacc/no_p_opt1.output delete mode 100644 test/btyacc/no_verbose.error delete mode 100644 test/btyacc/no_verbose.output delete mode 100644 test/btyacc/nostdin.error delete mode 100644 test/btyacc/nostdin.output delete mode 100644 test/btyacc/ok_syntax1.error delete mode 100644 test/btyacc/ok_syntax1.output delete mode 100644 test/btyacc/ok_syntax1.tab.c delete mode 100644 test/btyacc/ok_syntax1.tab.h delete mode 100644 test/btyacc/pure_calc.error delete mode 100644 test/btyacc/pure_calc.output delete mode 100644 test/btyacc/pure_calc.tab.c delete mode 100644 test/btyacc/pure_calc.tab.h delete mode 100644 test/btyacc/pure_error.error delete mode 100644 test/btyacc/pure_error.output delete mode 100644 test/btyacc/pure_error.tab.c delete mode 100644 test/btyacc/pure_error.tab.h delete mode 100644 test/btyacc/quote_calc-s.error delete mode 100644 test/btyacc/quote_calc-s.output delete mode 100644 test/btyacc/quote_calc-s.tab.c delete mode 100644 test/btyacc/quote_calc-s.tab.h delete mode 100644 test/btyacc/quote_calc.error delete mode 100644 test/btyacc/quote_calc.output delete mode 100644 test/btyacc/quote_calc.tab.c delete mode 100644 test/btyacc/quote_calc.tab.h delete mode 100644 test/btyacc/quote_calc2-s.error delete mode 100644 test/btyacc/quote_calc2-s.output delete mode 100644 test/btyacc/quote_calc2-s.tab.c delete mode 100644 test/btyacc/quote_calc2-s.tab.h delete mode 100644 test/btyacc/quote_calc2.error delete mode 100644 test/btyacc/quote_calc2.output delete mode 100644 test/btyacc/quote_calc2.tab.c delete mode 100644 test/btyacc/quote_calc2.tab.h delete mode 100644 test/btyacc/quote_calc3-s.error delete mode 100644 test/btyacc/quote_calc3-s.output delete mode 100644 test/btyacc/quote_calc3-s.tab.c delete mode 100644 test/btyacc/quote_calc3-s.tab.h delete mode 100644 test/btyacc/quote_calc3.error delete mode 100644 test/btyacc/quote_calc3.output delete mode 100644 test/btyacc/quote_calc3.tab.c delete mode 100644 test/btyacc/quote_calc3.tab.h delete mode 100644 test/btyacc/quote_calc4-s.error delete mode 100644 test/btyacc/quote_calc4-s.output delete mode 100644 test/btyacc/quote_calc4-s.tab.c delete mode 100644 test/btyacc/quote_calc4-s.tab.h delete mode 100644 test/btyacc/quote_calc4.error delete mode 100644 test/btyacc/quote_calc4.output delete mode 100644 test/btyacc/quote_calc4.tab.c delete mode 100644 test/btyacc/quote_calc4.tab.h delete mode 100644 test/btyacc/rename_debug.c delete mode 100644 test/btyacc/rename_debug.error delete mode 100644 test/btyacc/rename_debug.h delete mode 100644 test/btyacc/rename_debug.i delete mode 100644 test/btyacc/rename_debug.output delete mode 100644 test/btyacc/stdin1.calc.c delete mode 100644 test/btyacc/stdin1.error delete mode 100644 test/btyacc/stdin1.output delete mode 100644 test/btyacc/stdin2.calc.c delete mode 100644 test/btyacc/stdin2.error delete mode 100644 test/btyacc/stdin2.output delete mode 100644 test/btyacc/varsyntax_calc1.error delete mode 100644 test/btyacc/varsyntax_calc1.output delete mode 100644 test/btyacc/varsyntax_calc1.tab.c delete mode 100644 test/btyacc/varsyntax_calc1.tab.h delete mode 100644 test/btyacc_calc1.y delete mode 100644 test/btyacc_demo.y delete mode 100644 test/btyacc_destroy1.y delete mode 100644 test/btyacc_destroy2.y delete mode 100644 test/btyacc_destroy3.y delete mode 100644 test/calc.y delete mode 100644 test/calc1.y delete mode 100644 test/calc2.y delete mode 100644 test/calc3.y delete mode 100644 test/calc_code_all.y delete mode 100644 test/calc_code_default.y delete mode 100644 test/calc_code_imports.y delete mode 100644 test/calc_code_provides.y delete mode 100644 test/calc_code_requires.y delete mode 100644 test/calc_code_top.y delete mode 100644 test/code_calc.y delete mode 100644 test/code_debug.y delete mode 100644 test/code_error.y delete mode 100644 test/empty.y delete mode 100644 test/err_inherit1.y delete mode 100644 test/err_inherit2.y delete mode 100644 test/err_inherit3.y delete mode 100644 test/err_inherit4.y delete mode 100644 test/err_inherit5.y delete mode 100644 test/err_syntax1.y delete mode 100644 test/err_syntax10.y delete mode 100644 test/err_syntax11.y delete mode 100644 test/err_syntax12.y delete mode 100644 test/err_syntax13.y delete mode 100644 test/err_syntax14.y delete mode 100644 test/err_syntax15.y delete mode 100644 test/err_syntax16.y delete mode 100644 test/err_syntax17.y delete mode 100644 test/err_syntax18.y delete mode 100644 test/err_syntax19.y delete mode 100644 test/err_syntax2.y delete mode 100644 test/err_syntax20.y delete mode 100644 test/err_syntax21.y delete mode 100644 test/err_syntax22.y delete mode 100644 test/err_syntax23.y delete mode 100644 test/err_syntax24.y delete mode 100644 test/err_syntax25.y delete mode 100644 test/err_syntax26.y delete mode 100644 test/err_syntax27.y delete mode 100644 test/err_syntax3.y delete mode 100644 test/err_syntax4.y delete mode 100644 test/err_syntax5.y delete mode 100644 test/err_syntax6.y delete mode 100644 test/err_syntax7.y delete mode 100644 test/err_syntax7a.y delete mode 100644 test/err_syntax7b.y delete mode 100644 test/err_syntax8.y delete mode 100644 test/err_syntax8a.y delete mode 100644 test/err_syntax9.y delete mode 100644 test/error.y delete mode 100644 test/expr.oxout.y delete mode 100644 test/grammar.y delete mode 100644 test/inherit0.y delete mode 100644 test/inherit1.y delete mode 100644 test/inherit2.y delete mode 100644 test/ok_syntax1.y delete mode 100644 test/pure_calc.y delete mode 100644 test/pure_error.y delete mode 100644 test/quote_calc.y delete mode 100644 test/quote_calc2.y delete mode 100644 test/quote_calc3.y delete mode 100644 test/quote_calc4.y delete mode 100755 test/run_lint.sh delete mode 100755 test/run_make.sh delete mode 100755 test/run_test.sh delete mode 100644 test/varsyntax_calc1.y delete mode 100644 test/yacc/big_b.error delete mode 100644 test/yacc/big_b.output delete mode 100644 test/yacc/big_l.error delete mode 100644 test/yacc/big_l.output delete mode 100644 test/yacc/calc.error delete mode 100644 test/yacc/calc.output delete mode 100644 test/yacc/calc.tab.c delete mode 100644 test/yacc/calc.tab.h delete mode 100644 test/yacc/calc1.error delete mode 100644 test/yacc/calc1.output delete mode 100644 test/yacc/calc1.tab.c delete mode 100644 test/yacc/calc1.tab.h delete mode 100644 test/yacc/calc2.error delete mode 100644 test/yacc/calc2.output delete mode 100644 test/yacc/calc2.tab.c delete mode 100644 test/yacc/calc2.tab.h delete mode 100644 test/yacc/calc3.error delete mode 100644 test/yacc/calc3.output delete mode 100644 test/yacc/calc3.tab.c delete mode 100644 test/yacc/calc3.tab.h delete mode 100644 test/yacc/calc_code_all.error delete mode 100644 test/yacc/calc_code_all.output delete mode 100644 test/yacc/calc_code_all.tab.c delete mode 100644 test/yacc/calc_code_all.tab.h delete mode 100644 test/yacc/calc_code_default.error delete mode 100644 test/yacc/calc_code_default.output delete mode 100644 test/yacc/calc_code_default.tab.c delete mode 100644 test/yacc/calc_code_default.tab.h delete mode 100644 test/yacc/calc_code_imports.error delete mode 100644 test/yacc/calc_code_imports.output delete mode 100644 test/yacc/calc_code_imports.tab.c delete mode 100644 test/yacc/calc_code_imports.tab.h delete mode 100644 test/yacc/calc_code_provides.error delete mode 100644 test/yacc/calc_code_provides.output delete mode 100644 test/yacc/calc_code_provides.tab.c delete mode 100644 test/yacc/calc_code_provides.tab.h delete mode 100644 test/yacc/calc_code_requires.error delete mode 100644 test/yacc/calc_code_requires.output delete mode 100644 test/yacc/calc_code_requires.tab.c delete mode 100644 test/yacc/calc_code_requires.tab.h delete mode 100644 test/yacc/calc_code_top.error delete mode 100644 test/yacc/calc_code_top.output delete mode 100644 test/yacc/calc_code_top.tab.c delete mode 100644 test/yacc/calc_code_top.tab.h delete mode 100644 test/yacc/code_calc.code.c delete mode 100644 test/yacc/code_calc.error delete mode 100644 test/yacc/code_calc.output delete mode 100644 test/yacc/code_calc.tab.c delete mode 100644 test/yacc/code_calc.tab.h delete mode 100644 test/yacc/code_error.code.c delete mode 100644 test/yacc/code_error.error delete mode 100644 test/yacc/code_error.output delete mode 100644 test/yacc/code_error.tab.c delete mode 100644 test/yacc/code_error.tab.h delete mode 100644 test/yacc/defines1.calc.c delete mode 100644 test/yacc/defines1.calc.h delete mode 100644 test/yacc/defines1.error delete mode 100644 test/yacc/defines1.output delete mode 100644 test/yacc/defines2.calc.c delete mode 100644 test/yacc/defines2.calc.h delete mode 100644 test/yacc/defines2.error delete mode 100644 test/yacc/defines2.output delete mode 100644 test/yacc/defines3.calc.c delete mode 100644 test/yacc/defines3.calc.h delete mode 100644 test/yacc/defines3.error delete mode 100644 test/yacc/defines3.output delete mode 100644 test/yacc/empty.error delete mode 100644 test/yacc/empty.output delete mode 100644 test/yacc/empty.tab.c delete mode 100644 test/yacc/empty.tab.h delete mode 100644 test/yacc/err_syntax1.error delete mode 100644 test/yacc/err_syntax1.output delete mode 100644 test/yacc/err_syntax1.tab.c delete mode 100644 test/yacc/err_syntax1.tab.h delete mode 100644 test/yacc/err_syntax10.error delete mode 100644 test/yacc/err_syntax10.output delete mode 100644 test/yacc/err_syntax10.tab.c delete mode 100644 test/yacc/err_syntax10.tab.h delete mode 100644 test/yacc/err_syntax11.error delete mode 100644 test/yacc/err_syntax11.output delete mode 100644 test/yacc/err_syntax11.tab.c delete mode 100644 test/yacc/err_syntax11.tab.h delete mode 100644 test/yacc/err_syntax12.error delete mode 100644 test/yacc/err_syntax12.output delete mode 100644 test/yacc/err_syntax12.tab.c delete mode 100644 test/yacc/err_syntax12.tab.h delete mode 100644 test/yacc/err_syntax13.error delete mode 100644 test/yacc/err_syntax13.output delete mode 100644 test/yacc/err_syntax13.tab.c delete mode 100644 test/yacc/err_syntax13.tab.h delete mode 100644 test/yacc/err_syntax14.error delete mode 100644 test/yacc/err_syntax14.output delete mode 100644 test/yacc/err_syntax14.tab.c delete mode 100644 test/yacc/err_syntax14.tab.h delete mode 100644 test/yacc/err_syntax15.error delete mode 100644 test/yacc/err_syntax15.output delete mode 100644 test/yacc/err_syntax15.tab.c delete mode 100644 test/yacc/err_syntax15.tab.h delete mode 100644 test/yacc/err_syntax16.error delete mode 100644 test/yacc/err_syntax16.output delete mode 100644 test/yacc/err_syntax16.tab.c delete mode 100644 test/yacc/err_syntax16.tab.h delete mode 100644 test/yacc/err_syntax17.error delete mode 100644 test/yacc/err_syntax17.output delete mode 100644 test/yacc/err_syntax17.tab.c delete mode 100644 test/yacc/err_syntax17.tab.h delete mode 100644 test/yacc/err_syntax18.error delete mode 100644 test/yacc/err_syntax18.output delete mode 100644 test/yacc/err_syntax18.tab.c delete mode 100644 test/yacc/err_syntax18.tab.h delete mode 100644 test/yacc/err_syntax19.error delete mode 100644 test/yacc/err_syntax19.output delete mode 100644 test/yacc/err_syntax19.tab.c delete mode 100644 test/yacc/err_syntax19.tab.h delete mode 100644 test/yacc/err_syntax2.error delete mode 100644 test/yacc/err_syntax2.output delete mode 100644 test/yacc/err_syntax2.tab.c delete mode 100644 test/yacc/err_syntax2.tab.h delete mode 100644 test/yacc/err_syntax20.error delete mode 100644 test/yacc/err_syntax20.output delete mode 100644 test/yacc/err_syntax20.tab.c delete mode 100644 test/yacc/err_syntax20.tab.h delete mode 100644 test/yacc/err_syntax21.error delete mode 100644 test/yacc/err_syntax21.output delete mode 100644 test/yacc/err_syntax21.tab.c delete mode 100644 test/yacc/err_syntax21.tab.h delete mode 100644 test/yacc/err_syntax22.error delete mode 100644 test/yacc/err_syntax22.output delete mode 100644 test/yacc/err_syntax22.tab.c delete mode 100644 test/yacc/err_syntax22.tab.h delete mode 100644 test/yacc/err_syntax23.error delete mode 100644 test/yacc/err_syntax23.output delete mode 100644 test/yacc/err_syntax23.tab.c delete mode 100644 test/yacc/err_syntax23.tab.h delete mode 100644 test/yacc/err_syntax24.error delete mode 100644 test/yacc/err_syntax24.output delete mode 100644 test/yacc/err_syntax24.tab.c delete mode 100644 test/yacc/err_syntax24.tab.h delete mode 100644 test/yacc/err_syntax25.error delete mode 100644 test/yacc/err_syntax25.output delete mode 100644 test/yacc/err_syntax25.tab.c delete mode 100644 test/yacc/err_syntax25.tab.h delete mode 100644 test/yacc/err_syntax26.error delete mode 100644 test/yacc/err_syntax26.output delete mode 100644 test/yacc/err_syntax26.tab.c delete mode 100644 test/yacc/err_syntax26.tab.h delete mode 100644 test/yacc/err_syntax27.error delete mode 100644 test/yacc/err_syntax27.output delete mode 100644 test/yacc/err_syntax27.tab.c delete mode 100644 test/yacc/err_syntax27.tab.h delete mode 100644 test/yacc/err_syntax3.error delete mode 100644 test/yacc/err_syntax3.output delete mode 100644 test/yacc/err_syntax3.tab.c delete mode 100644 test/yacc/err_syntax3.tab.h delete mode 100644 test/yacc/err_syntax4.error delete mode 100644 test/yacc/err_syntax4.output delete mode 100644 test/yacc/err_syntax4.tab.c delete mode 100644 test/yacc/err_syntax4.tab.h delete mode 100644 test/yacc/err_syntax5.error delete mode 100644 test/yacc/err_syntax5.output delete mode 100644 test/yacc/err_syntax5.tab.c delete mode 100644 test/yacc/err_syntax5.tab.h delete mode 100644 test/yacc/err_syntax6.error delete mode 100644 test/yacc/err_syntax6.output delete mode 100644 test/yacc/err_syntax6.tab.c delete mode 100644 test/yacc/err_syntax6.tab.h delete mode 100644 test/yacc/err_syntax7.error delete mode 100644 test/yacc/err_syntax7.output delete mode 100644 test/yacc/err_syntax7.tab.c delete mode 100644 test/yacc/err_syntax7.tab.h delete mode 100644 test/yacc/err_syntax7a.error delete mode 100644 test/yacc/err_syntax7a.output delete mode 100644 test/yacc/err_syntax7a.tab.c delete mode 100644 test/yacc/err_syntax7a.tab.h delete mode 100644 test/yacc/err_syntax7b.error delete mode 100644 test/yacc/err_syntax7b.output delete mode 100644 test/yacc/err_syntax7b.tab.c delete mode 100644 test/yacc/err_syntax7b.tab.h delete mode 100644 test/yacc/err_syntax8.error delete mode 100644 test/yacc/err_syntax8.output delete mode 100644 test/yacc/err_syntax8.tab.c delete mode 100644 test/yacc/err_syntax8.tab.h delete mode 100644 test/yacc/err_syntax8a.error delete mode 100644 test/yacc/err_syntax8a.output delete mode 100644 test/yacc/err_syntax8a.tab.c delete mode 100644 test/yacc/err_syntax8a.tab.h delete mode 100644 test/yacc/err_syntax9.error delete mode 100644 test/yacc/err_syntax9.output delete mode 100644 test/yacc/err_syntax9.tab.c delete mode 100644 test/yacc/err_syntax9.tab.h delete mode 100644 test/yacc/error.error delete mode 100644 test/yacc/error.output delete mode 100644 test/yacc/error.tab.c delete mode 100644 test/yacc/error.tab.h delete mode 100644 test/yacc/expr.oxout.error delete mode 100644 test/yacc/expr.oxout.output delete mode 100644 test/yacc/expr.oxout.tab.c delete mode 100644 test/yacc/expr.oxout.tab.h delete mode 100644 test/yacc/grammar.dot delete mode 100644 test/yacc/grammar.error delete mode 100644 test/yacc/grammar.output delete mode 100644 test/yacc/grammar.tab.c delete mode 100644 test/yacc/grammar.tab.h delete mode 100644 test/yacc/help.error delete mode 100644 test/yacc/help.output delete mode 100644 test/yacc/no_b_opt.error delete mode 100644 test/yacc/no_b_opt.output delete mode 100644 test/yacc/no_b_opt1.error delete mode 100644 test/yacc/no_b_opt1.output delete mode 100644 test/yacc/no_code_c.error delete mode 100644 test/yacc/no_code_c.output delete mode 100644 test/yacc/no_defines.error delete mode 100644 test/yacc/no_defines.output delete mode 100644 test/yacc/no_graph.error delete mode 100644 test/yacc/no_graph.output delete mode 100644 test/yacc/no_include.error delete mode 100644 test/yacc/no_include.output delete mode 100644 test/yacc/no_opts.error delete mode 100644 test/yacc/no_opts.output delete mode 100644 test/yacc/no_output.error delete mode 100644 test/yacc/no_output.output delete mode 100644 test/yacc/no_output1.error delete mode 100644 test/yacc/no_output1.output delete mode 100644 test/yacc/no_output2.error delete mode 100644 test/yacc/no_output2.output delete mode 100644 test/yacc/no_p_opt.error delete mode 100644 test/yacc/no_p_opt.output delete mode 100644 test/yacc/no_p_opt1.error delete mode 100644 test/yacc/no_p_opt1.output delete mode 100644 test/yacc/no_verbose.error delete mode 100644 test/yacc/no_verbose.output delete mode 100644 test/yacc/nostdin.error delete mode 100644 test/yacc/nostdin.output delete mode 100644 test/yacc/ok_syntax1.error delete mode 100644 test/yacc/ok_syntax1.output delete mode 100644 test/yacc/ok_syntax1.tab.c delete mode 100644 test/yacc/ok_syntax1.tab.h delete mode 100644 test/yacc/pure_calc.error delete mode 100644 test/yacc/pure_calc.output delete mode 100644 test/yacc/pure_calc.tab.c delete mode 100644 test/yacc/pure_calc.tab.h delete mode 100644 test/yacc/pure_error.error delete mode 100644 test/yacc/pure_error.output delete mode 100644 test/yacc/pure_error.tab.c delete mode 100644 test/yacc/pure_error.tab.h delete mode 100644 test/yacc/quote_calc-s.error delete mode 100644 test/yacc/quote_calc-s.output delete mode 100644 test/yacc/quote_calc-s.tab.c delete mode 100644 test/yacc/quote_calc-s.tab.h delete mode 100644 test/yacc/quote_calc.error delete mode 100644 test/yacc/quote_calc.output delete mode 100644 test/yacc/quote_calc.tab.c delete mode 100644 test/yacc/quote_calc.tab.h delete mode 100644 test/yacc/quote_calc2-s.error delete mode 100644 test/yacc/quote_calc2-s.output delete mode 100644 test/yacc/quote_calc2-s.tab.c delete mode 100644 test/yacc/quote_calc2-s.tab.h delete mode 100644 test/yacc/quote_calc2.error delete mode 100644 test/yacc/quote_calc2.output delete mode 100644 test/yacc/quote_calc2.tab.c delete mode 100644 test/yacc/quote_calc2.tab.h delete mode 100644 test/yacc/quote_calc3-s.error delete mode 100644 test/yacc/quote_calc3-s.output delete mode 100644 test/yacc/quote_calc3-s.tab.c delete mode 100644 test/yacc/quote_calc3-s.tab.h delete mode 100644 test/yacc/quote_calc3.error delete mode 100644 test/yacc/quote_calc3.output delete mode 100644 test/yacc/quote_calc3.tab.c delete mode 100644 test/yacc/quote_calc3.tab.h delete mode 100644 test/yacc/quote_calc4-s.error delete mode 100644 test/yacc/quote_calc4-s.output delete mode 100644 test/yacc/quote_calc4-s.tab.c delete mode 100644 test/yacc/quote_calc4-s.tab.h delete mode 100644 test/yacc/quote_calc4.error delete mode 100644 test/yacc/quote_calc4.output delete mode 100644 test/yacc/quote_calc4.tab.c delete mode 100644 test/yacc/quote_calc4.tab.h delete mode 100644 test/yacc/rename_debug.c delete mode 100644 test/yacc/rename_debug.error delete mode 100644 test/yacc/rename_debug.h delete mode 100644 test/yacc/rename_debug.i delete mode 100644 test/yacc/rename_debug.output delete mode 100644 test/yacc/stdin1.calc.c delete mode 100644 test/yacc/stdin1.error delete mode 100644 test/yacc/stdin1.output delete mode 100644 test/yacc/stdin2.calc.c delete mode 100644 test/yacc/stdin2.error delete mode 100644 test/yacc/stdin2.output delete mode 100644 test/yacc/varsyntax_calc1.error delete mode 100644 test/yacc/varsyntax_calc1.output delete mode 100644 test/yacc/varsyntax_calc1.tab.c delete mode 100644 test/yacc/varsyntax_calc1.tab.h diff --git a/CHANGES b/CHANGES index 49c3d84a882..eb96d72f0b2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,153 @@ +2024-01-09 Thomas E. Dickey + + * yacc.1: minor cleanup + + * package/debian/copyright: bump + + * configure: regen + + * VERSION, package/byacc.spec, package/debian/changelog, + package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2023-12-01 Thomas E. Dickey + + * aclocal.m4: + resync with my-autoconf: CF_CONST_X_STRING CF_MKSTEMP CF_WITH_MAN2HTML CF_XOPEN_SOURCE + +2023-09-15 Thomas E. Dickey + + * config.sub: 2023-09-15 + +2023-08-22 Thomas E. Dickey + + * config.guess: 2023-08-22 + +2023-05-21 Thomas E. Dickey + + * VERSION, package/byacc.spec, package/debian/changelog, + package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * configure: regen + + * aclocal.m4: + updates for CF_INSTALL_MAN from reflex, which needs the symbolic link feature + + * aclocal.m4: + improve install-man by adding sed commands for --program-transform-name + +2023-05-19 Thomas E. Dickey + + * makefile.in: use CF_INSTALL_MAN + + * aclocal.m4: + add CF_INSTALL_MAN, to begin refactoring install rule for manpage + + * configure: regen + + * configure.in: use CF_INSTALL_MAN + +2023-05-18 Thomas E. Dickey + + * error.c, defs.h, reader.c: + allow @1 or $@ with a warning if no %locations was given + +2023-05-17 Thomas E. Dickey + + * reader.c: clear pointer in end_ainfo() after freeing it. + +2023-05-16 Thomas E. Dickey + + * reader.c: report errors in %define as "unexpected value" + + * reader.c: + add/use macros begin_ainfo() and end_ainfo() to reduce clutter + + * defs.h, error.c: add function unexpected_value() + + * reader.c: + recognize bison's "%define api.pure" as an alternative to "%pure-parser" + + * reader.c: + add %nterm as an alias for %type, since bison made that confusion. + + * reader.c: + ensure that filler_buf and prefix_buf are initialized for the special case + where they are empty (report by Martin Jansa, cf: 20230219) + + * output.c: + make test-differences smaller when compiling with YY_NO_LEAKS by replacing + a blank line with the generated #define rather than adding 3 lines. + + * reader.c: gcc-warnings + +2023-05-15 Thomas E. Dickey + + * VERSION, package/byacc.spec, package/debian/changelog, + package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * reader.c: + when copying parameters, check for a case where the last token is not a + name, e.g., "foo [1]" would have "[1]". In this case, scan back to find + the actual parameter name. + + * reader.c: + correct a use-after-free in more_curly, which could occur if a %lex-param + or %parse-param was multi-line (Redhat #2183006). + +2023-05-11 Thomas E. Dickey + + * main.c: rename no_space() to on_error() + + * error.c: rename no_space() to no_error(), handling any errno + + * defs.h: rename no_space() to on_error() + +2023-04-03 Thomas E. Dickey + + * aclocal.m4: resync with my-autoconf: CF_GCC_VERSION CF_XOPEN_SOURCE + +2023-02-26 Thomas E. Dickey + + * mstring.c, reader.c: yak-indent + +2023-02-26 mingodad + + * reader.c: + patch for byacc #6: Segmentation fault when trying to parse bison-3.8.2 grammar + +2023-02-26 Thomas E. Dickey + + * VERSION, package/byacc.spec, package/debian/changelog, + package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2023-02-20 Thomas E. Dickey + + * configure: regen + + * aclocal.m4: resync with my-autoconf + +2023-02-19 Thomas E. Dickey + + * test/yacc/ok_syntax1.tab.h, test/yacc/ok_syntax1.tab.c, + test/btyacc/ok_syntax1.tab.h, test/btyacc/ok_syntax1.tab.c: + regen + + * test/ok_syntax1.y: + modify test for %union to add tag for testing reader.c + + * reader.c: + provide for a named union, e.g., "%union foo" by detecting the name and + deferring the typedef in that case until the end of copying the union + definition (report by Dag-Erling Smørgrav). + + * VERSION, package/byacc.spec, package/debian/changelog, + package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + 2023-02-01 Thomas E. Dickey * configure: regen diff --git a/MANIFEST b/MANIFEST index 88bc14260a5..a5c792d6de5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,8 +1,9 @@ -MANIFEST for byacc, version t20230201 +MANIFEST for byacc, version t20240109 -------------------------------------------------------------------------------- MANIFEST this file ACKNOWLEDGEMENTS original version of byacc - 1993 AUTHORS nicknames for some contributors (see CHANGES for details) +CHANGES generated changelog LICENSE summary of byacc's license Makefile.old renamed from Makefile NEW_FEATURES original version of byacc - 1993 @@ -63,7 +64,7 @@ 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/README summary of "test" directory test/btyacc subdirectory test/btyacc/big_b.error exercise -L/-B options test/btyacc/big_b.output exercise -L/-B options diff --git a/VERSION b/VERSION index f295cfe77a7..e55f042e203 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -20230201 +20240109 diff --git a/aclocal.m4 b/aclocal.m4 index 832d0c89b2e..7ae519084e7 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl $Id: aclocal.m4,v 1.59 2023/01/05 22:53:11 tom Exp $ +dnl $Id: aclocal.m4,v 1.65 2023/12/01 22:22:50 tom Exp $ dnl Macros for byacc configure script (Thomas E. Dickey) dnl --------------------------------------------------------------------------- dnl Copyright 2004-2022,2023 Thomas E. Dickey @@ -207,7 +207,7 @@ ifelse([$3],,[ :]dnl ])dnl ])])dnl dnl --------------------------------------------------------------------------- -dnl CF_C11_NORETURN version: 3 updated: 2021/03/28 11:36:23 +dnl CF_C11_NORETURN version: 4 updated: 2023/02/18 17:41:25 dnl --------------- AC_DEFUN([CF_C11_NORETURN], [ @@ -221,8 +221,7 @@ AC_MSG_RESULT($enable_stdnoreturn) if test $enable_stdnoreturn = yes; then AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn, [AC_TRY_COMPILE([ -#include -#include +$ac_includes_default #include static _Noreturn void giveup(void) { exit(0); } ], @@ -246,7 +245,7 @@ AC_SUBST(HAVE_STDNORETURN_H) AC_SUBST(STDC_NORETURN) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_CC_ENV_FLAGS version: 10 updated: 2020/12/31 18:40:20 +dnl CF_CC_ENV_FLAGS version: 11 updated: 2023/02/20 11:15:46 dnl --------------- dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content dnl into CC. This will not help with broken scripts that wrap the compiler @@ -287,7 +286,7 @@ case "$CC" in AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options) # humor him... cf_prog=`echo "$CC" | sed -e 's/ / /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'` - cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'` + cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"` CC="$cf_prog" for cf_arg in $cf_flags do @@ -345,7 +344,7 @@ if test ".$system_name" != ".$cf_cv_system_name" ; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_CLANG_COMPILER version: 8 updated: 2021/01/01 13:31:04 +dnl CF_CLANG_COMPILER version: 9 updated: 2023/02/18 17:41:25 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 @@ -367,7 +366,7 @@ if test "$ifelse([$1],,[$1],GCC)" = yes ; then AC_TRY_COMPILE([],[ #ifdef __clang__ #else -make an error +#error __clang__ is not defined #endif ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes ],[]) @@ -413,7 +412,7 @@ if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then fi ]) dnl --------------------------------------------------------------------------- -dnl CF_CONST_X_STRING version: 7 updated: 2021/06/07 17:39:17 +dnl CF_CONST_X_STRING version: 8 updated: 2023/12/01 17:22:50 dnl ----------------- dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most dnl character-strings. @@ -448,6 +447,7 @@ AC_TRY_COMPILE( AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[ AC_TRY_COMPILE( [ +#undef _CONST_X_STRING #define _CONST_X_STRING /* X11R7.8 (perhaps) */ #undef XTSTRINGDEFINES /* X11R5 and later */ #include @@ -718,7 +718,7 @@ rm -rf ./conftest* fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36 +dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13 dnl -------------- dnl Find version of gcc, and (because icc/clang pretend to be gcc without being dnl compatible), attempt to determine if icc/clang is actually used. @@ -727,7 +727,7 @@ AC_REQUIRE([AC_PROG_CC]) GCC_VERSION=none if test "$GCC" = yes ; then AC_MSG_CHECKING(version of $CC) - 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.]].*//'`" + GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" test -z "$GCC_VERSION" && GCC_VERSION=unknown AC_MSG_RESULT($GCC_VERSION) fi @@ -986,7 +986,152 @@ if test x$cf_cv_gnu_library = xyes; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_INTEL_COMPILER version: 8 updated: 2021/01/01 16:53:59 +dnl CF_INSTALL_MAN version: 5 updated: 2023/05/21 15:53:07 +dnl -------------- +dnl Call this to generate a script "install-man" which uses the detected +dnl manpage-format to compress the resulting manpage. Providing this as a +dnl macro simplifies including the script in different programs. +dnl +dnl The generated script assumes that the program can be renamed, using two +dnl symbols in the manpage, e.g., +dnl .ds N Yacc +dnl .ds n yacc +dnl which are later used as \*N and \*n, as well as a special case in the +dnl synopsis to work around limitations of makewhatis. +dnl +dnl Script parameters: +dnl $1 = input file +dnl $2 = output filename +dnl +dnl or (uninstall): +dnl $1 = output filename +AC_DEFUN([CF_INSTALL_MAN], +[ +AC_REQUIRE([AC_ARG_PROGRAM]) +AC_REQUIRE([AC_PROG_INSTALL]) +AC_REQUIRE([AC_LN_S]) +AC_REQUIRE([CF_MANPAGE_FORMAT]) +cf_install_man=install-man +ac_config_files="$ac_config_files $cf_install_man" +cf_install_man=$cf_install_man.in +echo [$]as_me: creating $cf_install_man +cat >[$]cf_install_man <<"CF_EOF" +#!/bin/sh +# generated by CF_INSTALL_MAN + +LANG=C; export LANG +LC_ALL=C; export LC_ALL +LC_CTYPE=C; export LC_CTYPE +LANGUAGE=C; export LANGUAGE + +INSTALL="@INSTALL@" +INSTALL_DATA="@INSTALL_DATA@" + +usage() { + cat <&2 + exit 1 +} + +test [$]# != 0 || usage +OPTS= +case "x[$]1" in +(x-l) + OPTS="link" + shift + ;; +(x-*) + usage + ;; +esac + +source= +if test [$]# = 2 ; then + source=[$]1; shift + target=[$]1 +elif test [$]# = 1 ; then + test -n "$OPTS" && usage + target=[$]1 +else + usage +fi + +origin_name=`echo "$source" |sed -e 's%^.*/%%' -e 's%\..*%%'` +actual_name=`echo "$origin_name" |sed '@program_transform_name@'` +leading_cap=`echo "$actual_name" | sed -e 's%^\(.\).*$%\1%' | tr a-z A-Z``echo "$actual_name" | sed -e 's%^.%%'` +capitalized=`echo "$actual_name" | tr a-z A-Z` + +cf_tmpdir=`mktemp -d` +trap 'rm -rf "$cf_tmpdir"; exit 1' 1 2 3 15 +trap 'rm -rf "$cf_tmpdir"; exit 0' 0 + +if test -n "$source" ; then + suffix= + test -n "@cf_manpage_so_strip" && suffix=".@cf_manpage_so_strip@" + if test "x$OPTS" = xlink ; then + source_dir=`echo "$source" | sed -e "s%/[[^/]]*$%%"` + target_dir=`echo "$target" | sed -e "s%/[[^/]]*$%%"` + sourcelink="${source}${suffix}" + targetfile="${target}${suffix}" + targetlink="${target_dir}/${sourcelink}" + if test ! -d "$target_dir" ; then + failed "target directory does not exist: $target_dir" + elif test ! -f "$targetfile" ; then + failed "target file does not exist: $targetfile" + elif test "$source" != "$source_dir" ; then + failed "unexpected directory for source-link: $source_dir" + fi + test -f "$targetlink" && failed "already exists $targetlink" + ( cd "$target_dir" && @LN_S@ "`echo "$targetfile" | sed -e 's%^.*/%%'`" "$sourcelink" ) + test -f "$targetlink" || failed "cannot create $targetlink" + target="$targetlink" + else + echo "** installing $source to $target" + interim="$cf_tmpdir"/"`basename $source`" + if test "x$origin_name" != "x$actual_name" ; then + sed \ + -e "/^.ds N/s%N.*%N $leading_cap%" \ + -e "/^.ds n/s%n.*%n $actual_name%" \ + -e "/^\.TH/s%[[ ]][[ ]]*[[^ ]][[^ ]]*% $capitalized%" \ + -e "/^\.SH[[ ]][[ ]]*NAME/,/[[ ]]\\\\-[[ ]]/s%^\\\\\\*[[Nn]]%$actual_name%" \ + "$source" >"$interim" || exit 1 + diff -c "$source" "$interim" + else + cp "$source" "$interim" || exit 1 + fi + if test -n "@cf_manpage_compress@" ; then + @cf_manpage_compress@ "$interim" + source="${interim}${suffix}" + fi + if test -d "$target" ; then + target="$target"/"$source" + else + test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@" + fi + $INSTALL_DATA "$source" "$target" || exit 1 + fi + echo "...installed $target" +else + echo "** removing $target" + test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@" + if test -f "$target" ; then + rm -f "$target" + echo "...removed $target" + else + echo "...not found" + fi +fi +exit 0 +CF_EOF +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25 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 @@ -1012,7 +1157,7 @@ if test "$ifelse([$1],,[$1],GCC)" = yes ; then AC_TRY_COMPILE([],[ #ifdef __INTEL_COMPILER #else -make an error +#error __INTEL_COMPILER is not defined #endif ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes cf_save_CFLAGS="$cf_save_CFLAGS -we147" @@ -1124,6 +1269,162 @@ AC_SUBST(ETAGS) AC_SUBST(MAKE_UPPER_TAGS) AC_SUBST(MAKE_LOWER_TAGS) +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_MANPAGE_FORMAT version: 18 updated: 2023/05/19 18:35:02 +dnl ----------------- +dnl Option to allow user to override automatic configuration of manpage format. +dnl There are several special cases: +dnl +dnl compress - man checks for, can display compressed files +dnl bzip2 - man checks for, can display bzip2'd files +dnl gzip - man checks for, can display gzip'd files +dnl xz - man checks for, can display xz'd files +dnl +dnl BSDI - files in the cat-directories are suffixed ".0" +dnl formatted - installer should format (put files in cat-directory) +dnl catonly - installer should only format, e.g., for a turnkey system. +dnl +dnl There are other configurations which this macro does not test, e.g., HPUX's +dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming +dnl convention would not match our use). +AC_DEFUN([CF_MANPAGE_FORMAT], +[ +AC_REQUIRE([CF_PATHSEP]) +AC_MSG_CHECKING(format of man-pages) + +AC_ARG_WITH(manpage-format, + [ --with-manpage-format specify manpage-format: gzip/compress/bzip2/xz, + BSDI/normal and optionally formatted/catonly, + e.g., gzip,formatted], + [MANPAGE_FORMAT=$withval], + [MANPAGE_FORMAT=unknown]) + +test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown +MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'` + +cf_unknown= + +case "$MANPAGE_FORMAT" in +(unknown) + if test -z "$MANPATH" ; then + MANPATH="/usr/man:/usr/share/man" + fi + + # look for the 'date' man-page (it is most likely to be installed!) + MANPAGE_FORMAT= + cf_preform="no" + cf_catonly="yes" + cf_example="date" + + IFS="${IFS:- }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for cf_dir in $MANPATH; do + test -z "$cf_dir" && cf_dir=/usr/man + for cf_name in $cf_dir/man*/$cf_example.[[01]]* $cf_dir/cat*/$cf_example.[[01]]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example + do + cf_test=`echo "$cf_name" | sed -e 's/*//'` + if test "x$cf_test" = "x$cf_name" ; then + + case "$cf_name" in + (*.bz2) MANPAGE_FORMAT="$MANPAGE_FORMAT bzip2";; + (*.xz) MANPAGE_FORMAT="$MANPAGE_FORMAT xz";; + (*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";; + (*.Z) MANPAGE_FORMAT="$MANPAGE_FORMAT compress";; + (*.0) MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";; + (*) MANPAGE_FORMAT="$MANPAGE_FORMAT normal";; + esac + + case "$cf_name" in + ($cf_dir/man*) + cf_catonly=no + ;; + ($cf_dir/cat*) + cf_preform=yes + ;; + esac + break + fi + + # if we found a match in either man* or cat*, stop looking + if test -n "$MANPAGE_FORMAT" ; then + cf_found=no + test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted" + test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly" + case "$cf_name" in + ($cf_dir/cat*) + cf_found=yes + ;; + esac + test "$cf_found" = yes && break + fi + done + # only check the first directory in $MANPATH where we find manpages + if test -n "$MANPAGE_FORMAT" ; then + break + fi + done + # if we did not find the example, just assume it is normal + test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal + IFS="$ac_save_ifs" + ;; +(*) + for cf_option in $MANPAGE_FORMAT; do + case "$cf_option" in + (xz|bzip2|gzip|compress|BSDI|normal|formatted|catonly) + ;; + (*) + cf_unknown="$cf_unknown $cf_option" + ;; + esac + done + ;; +esac + +AC_MSG_RESULT($MANPAGE_FORMAT) +if test -n "$cf_unknown" ; then + AC_MSG_WARN(Unexpected manpage-format $cf_unknown) +fi + +cf_manpage_format=no +cf_manpage_inboth=no +cf_manpage_so_strip= +cf_manpage_compress= + +for cf_item in $MANPAGE_FORMAT +do +case "$cf_item" in +(catonly) + cf_manpage_format=yes + cf_manpage_inboth=no + ;; +(formatted) + cf_manpage_format=yes + cf_manpage_inboth=yes + ;; +(compress) + cf_manpage_so_strip="Z" + cf_manpage_compress=compress + ;; +(gzip) + cf_manpage_so_strip="gz" + cf_manpage_compress=gzip + ;; +(bzip2) + cf_manpage_so_strip="bz2" + cf_manpage_compress=bzip2 + ;; +(xz) + cf_manpage_so_strip="xz" + cf_manpage_compress=xz + ;; +esac +done + +AC_SUBST(cf_manpage_format) +AC_SUBST(cf_manpage_inboth) +AC_SUBST(cf_manpage_so_strip) +AC_SUBST(cf_manpage_compress) + ])dnl dnl --------------------------------------------------------------------------- dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59 @@ -1156,7 +1457,7 @@ fi test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.]) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_MKSTEMP version: 12 updated: 2023/01/05 17:53:11 +dnl CF_MKSTEMP version: 13 updated: 2023/12/01 17:22:50 dnl ---------- dnl Check for a working mkstemp. This creates two files, checks that they are dnl successfully created and distinct (AmigaOS apparently fails on the last). @@ -1171,7 +1472,7 @@ $ac_includes_default int main(void) { - char *tmpl = "conftestXXXXXX"; + static char tmpl[] = "conftestXXXXXX"; char name[2][80]; int n; int result = 0; @@ -1255,6 +1556,22 @@ case ".$with_cflags" in esac ])dnl dnl --------------------------------------------------------------------------- +dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04 +dnl ---------- +dnl Provide a value for the $PATH and similar separator (or amend the value +dnl as provided in autoconf 2.5x). +AC_DEFUN([CF_PATHSEP], +[ + AC_MSG_CHECKING(for PATH separator) + case "$cf_cv_system_name" in + (os2*) PATH_SEPARATOR=';' ;; + (*) ${PATH_SEPARATOR:=':'} ;; + esac +ifelse([$1],,,[$1=$PATH_SEPARATOR]) + AC_SUBST(PATH_SEPARATOR) + AC_MSG_RESULT($PATH_SEPARATOR) +])dnl +dnl --------------------------------------------------------------------------- dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20 dnl -------------- dnl Check the argument to see that it looks like a pathname. Rewrite it if it @@ -1292,7 +1609,7 @@ case ".[$]$1" in esac ])dnl dnl --------------------------------------------------------------------------- -dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17 +dnl CF_POSIX_C_SOURCE version: 12 updated: 2023/02/18 17:41:25 dnl ----------------- dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed. dnl @@ -1323,7 +1640,7 @@ AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[ CF_MSG_LOG(if the symbol is already defined go no further) AC_TRY_COMPILE([#include ],[ #ifndef _POSIX_C_SOURCE -make an error +#error _POSIX_C_SOURCE is not defined #endif], [cf_cv_posix_c_source=no], [cf_want_posix_source=no @@ -1342,7 +1659,7 @@ make an error if test "$cf_want_posix_source" = yes ; then AC_TRY_COMPILE([#include ],[ #ifdef _POSIX_SOURCE -make an error +#error _POSIX_SOURCE is defined #endif],[], cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE") fi @@ -1353,7 +1670,7 @@ make an error CF_MSG_LOG(if the second compile does not leave our definition intact error) AC_TRY_COMPILE([#include ],[ #ifndef _POSIX_C_SOURCE -make an error +#error _POSIX_C_SOURCE is not defined #endif],, [cf_cv_posix_c_source=no]) CFLAGS="$cf_save_CFLAGS" @@ -1578,7 +1895,7 @@ if test "$with_dmalloc" = yes ; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_WITH_MAN2HTML version: 12 updated: 2021/01/03 18:30:50 +dnl CF_WITH_MAN2HTML version: 13 updated: 2023/11/23 06:40:35 dnl ---------------- dnl Check for man2html and groff. Prefer man2html over groff, but use groff dnl as a fallback. See @@ -1620,7 +1937,7 @@ esac AC_MSG_CHECKING(for program to convert manpage to html) AC_ARG_WITH(man2html, - [ --with-man2html=XXX use XXX rather than groff], + [[ --with-man2html[=XXX] use XXX rather than groff]], [cf_man2html=$withval], [cf_man2html=$cf_man2html]) @@ -1761,7 +2078,7 @@ CF_NO_LEAKS_OPTION(valgrind, [USE_VALGRIND]) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_XOPEN_SOURCE version: 63 updated: 2022/12/29 10:10:26 +dnl CF_XOPEN_SOURCE version: 67 updated: 2023/09/06 18:55:27 dnl --------------- dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions, dnl or adapt to the vendor's definitions to get equivalent functionality, @@ -1770,6 +2087,18 @@ dnl dnl Parameters: dnl $1 is the nominal value for _XOPEN_SOURCE dnl $2 is the nominal value for _POSIX_C_SOURCE +dnl +dnl The default case prefers _XOPEN_SOURCE over _POSIX_C_SOURCE if the +dnl implementation predefines it, because X/Open and most implementations agree +dnl that the latter is a legacy or "aligned" value. +dnl +dnl Because _XOPEN_SOURCE is preferred, if defining _POSIX_C_SOURCE turns +dnl that off, then refrain from setting _POSIX_C_SOURCE explicitly. +dnl +dnl References: +dnl https://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html +dnl https://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html +dnl https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html AC_DEFUN([CF_XOPEN_SOURCE],[ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([CF_POSIX_VISIBLE]) @@ -1784,9 +2113,6 @@ case "$host_os" in (aix[[4-7]]*) cf_xopen_source="-D_ALL_SOURCE" ;; -(msys) - cf_XOPEN_SOURCE=600 - ;; (darwin[[0-8]].*) cf_xopen_source="-D_APPLE_C_SOURCE" ;; @@ -1812,7 +2138,7 @@ case "$host_os" in cf_xopen_source="-D_SGI_SOURCE" cf_XOPEN_SOURCE= ;; -(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin) +(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc) CF_GNU_SOURCE($cf_XOPEN_SOURCE) ;; (minix*) @@ -1864,8 +2190,8 @@ case "$host_os" in cf_save_xopen_cppflags="$CPPFLAGS" CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE) # Some of these niche implementations use copy/paste, double-check... - if test "$cf_cv_xopen_source" != no ; then - CF_VERBOSE(checking if _POSIX_C_SOURCE inteferes) + if test "$cf_cv_xopen_source" = no ; then + CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE) AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,,[ AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable) CPPFLAGS="$cf_save_xopen_cppflags"]) @@ -1884,7 +2210,7 @@ if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then AC_MSG_CHECKING(if _XOPEN_SOURCE really is set) AC_TRY_COMPILE([#include ],[ #ifndef _XOPEN_SOURCE -make an error +#error _XOPEN_SOURCE is not defined #endif], [cf_XOPEN_SOURCE_set=yes], [cf_XOPEN_SOURCE_set=no]) @@ -1893,7 +2219,7 @@ make an error then AC_TRY_COMPILE([#include ],[ #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE -make an error +#error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE #endif], [cf_XOPEN_SOURCE_set_ok=yes], [cf_XOPEN_SOURCE_set_ok=no]) @@ -1908,22 +2234,20 @@ fi fi # cf_cv_posix_visible ]) dnl --------------------------------------------------------------------------- -dnl CF__XOPEN_SOURCE_BODY version: 1 updated: 2022/09/10 15:17:35 +dnl CF__XOPEN_SOURCE_BODY version: 2 updated: 2023/02/18 17:41:25 dnl --------------------- dnl body of test when test-compiling for _XOPEN_SOURCE check define([CF__XOPEN_SOURCE_BODY], [ #ifndef _XOPEN_SOURCE -make an error +#error _XOPEN_SOURCE is not defined #endif ]) dnl --------------------------------------------------------------------------- -dnl CF__XOPEN_SOURCE_HEAD version: 1 updated: 2022/09/10 15:17:03 +dnl CF__XOPEN_SOURCE_HEAD version: 2 updated: 2023/02/18 17:41:25 dnl --------------------- dnl headers to include when test-compiling for _XOPEN_SOURCE check define([CF__XOPEN_SOURCE_HEAD], [ -#include -#include -#include +$ac_includes_default ]) diff --git a/config.guess b/config.guess index a419d8643b6..cdfc4392047 100755 --- a/config.guess +++ b/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2022 Free Software Foundation, Inc. +# Copyright 1992-2023 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2022-08-01' +timestamp='2023-08-22' # 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 @@ -47,7 +47,7 @@ me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] -Output the configuration name of the system \`$me' is run on. +Output the configuration name of the system '$me' is run on. Options: -h, --help print this help, then exit @@ -60,13 +60,13 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2022 Free Software Foundation, Inc. +Copyright 1992-2023 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." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -102,8 +102,8 @@ GUESS= # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. +# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still +# use 'HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. @@ -155,6 +155,9 @@ Linux|GNU|GNU/*) set_cc_for_build cat <<-EOF > "$dummy.c" + #if defined(__ANDROID__) + LIBC=android + #else #include #if defined(__UCLIBC__) LIBC=uclibc @@ -169,6 +172,7 @@ Linux|GNU|GNU/*) LIBC=musl #endif #endif + #endif EOF cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` eval "$cc_set_libc" @@ -459,7 +463,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in UNAME_RELEASE=`uname -v` ;; esac - # Japanese Language versions have a version number like `4.1.3-JL'. + # Japanese Language versions have a version number like '4.1.3-JL'. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` GUESS=sparc-sun-sunos$SUN_REL ;; @@ -904,7 +908,7 @@ EOF fi ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` + UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; @@ -966,11 +970,37 @@ EOF GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC ;; + x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-pc-managarm-mlibc" + ;; + *:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" + ;; *:Minix:*:*) GUESS=$UNAME_MACHINE-unknown-minix ;; aarch64:Linux:*:*) - GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __ARM_EABI__ + #ifdef __ARM_PCS_VFP + ABI=eabihf + #else + ABI=eabi + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; + esac + fi + GUESS=$CPU-unknown-linux-$LIBCABI ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be @@ -1036,6 +1066,15 @@ EOF k1om:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; + kvx:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:cos:*:*) + GUESS=$UNAME_MACHINE-unknown-cos + ;; + kvx:mbr:*:*) + GUESS=$UNAME_MACHINE-unknown-mbr + ;; loongarch32:Linux:*:* | loongarch64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; @@ -1191,7 +1230,7 @@ EOF GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION ;; i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility + # If we were able to find 'uname', then EMX Unix compatibility # is probably installed. GUESS=$UNAME_MACHINE-pc-os2-emx ;; @@ -1332,7 +1371,7 @@ EOF GUESS=ns32k-sni-sysv fi ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort # says GUESS=i586-unisys-sysv4 ;; diff --git a/config.sub b/config.sub index fbaa37f2352..51394d32014 100755 --- a/config.sub +++ b/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2022 Free Software Foundation, Inc. +# Copyright 1992-2023 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2022-08-01' +timestamp='2023-09-15' # 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 @@ -76,13 +76,13 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2022 Free Software Foundation, Inc. +Copyright 1992-2023 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." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -130,7 +130,7 @@ IFS=$saved_IFS # Separate into logical components for further validation case $1 in *-*-*-*-*) - echo Invalid configuration \`"$1"\': more than four components >&2 + echo "Invalid configuration '$1': more than four components" >&2 exit 1 ;; *-*-*-*) @@ -145,7 +145,8 @@ case $1 in nto-qnx* | linux-* | uclinux-uclibc* \ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ - | storm-chaos* | os2-emx* | rtmk-nova*) + | storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \ + | windows-* ) basic_machine=$field1 basic_os=$maybe_os ;; @@ -943,7 +944,7 @@ $basic_machine EOF IFS=$saved_IFS ;; - # We use `pc' rather than `unknown' + # We use 'pc' rather than 'unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) @@ -1075,7 +1076,7 @@ case $cpu-$vendor in pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) cpu=i586 ;; - pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*) cpu=i686 ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) @@ -1180,7 +1181,7 @@ case $cpu-$vendor in case $cpu in 1750a | 580 \ | a29k \ - | aarch64 | aarch64_be \ + | aarch64 | aarch64_be | aarch64c | arm64ec \ | abacus \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ @@ -1199,12 +1200,14 @@ case $cpu-$vendor in | d10v | d30v | dlx | dsp16xx \ | e2k | elxsi | epiphany \ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | javascript \ | h8300 | h8500 \ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i*86 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ + | kvx \ | le32 | le64 \ | lm32 \ | loongarch32 | loongarch64 \ @@ -1213,31 +1216,7 @@ case $cpu-$vendor in | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ | m88110 | m88k | maxq | mb | mcore | mep | metag \ | microblaze | microblazeel \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64eb | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r3 | mipsisa32r3el \ - | mipsisa32r5 | mipsisa32r5el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r3 | mipsisa64r3el \ - | mipsisa64r5 | mipsisa64r5el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ + | mips* \ | mmix \ | mn10200 | mn10300 \ | moxie \ @@ -1285,7 +1264,7 @@ case $cpu-$vendor in ;; *) - echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2 exit 1 ;; esac @@ -1306,11 +1285,12 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if test x$basic_os != x +if test x"$basic_os" != x then # First recognize some ad-hoc cases, or perhaps split kernel-os, or else just # set os. +obj= case $basic_os in gnu/linux*) kernel=linux @@ -1341,6 +1321,10 @@ EOF kernel=linux os=`echo "$basic_os" | sed -e 's|linux|gnu|'` ;; + managarm*) + kernel=managarm + os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'` + ;; *) kernel= os=$basic_os @@ -1506,10 +1490,16 @@ case $os in os=eabi ;; *) - os=elf + os= + obj=elf ;; esac ;; + aout* | coff* | elf* | pe*) + # These are machine code file formats, not OSes + obj=$os + os= + ;; *) # No normalization, but not necessarily accepted, that comes below. ;; @@ -1528,12 +1518,15 @@ else # system, and we'll never get to this point. kernel= +obj= case $cpu-$vendor in score-*) - os=elf + os= + obj=elf ;; spu-*) - os=elf + os= + obj=elf ;; *-acorn) os=riscix1.2 @@ -1543,28 +1536,35 @@ case $cpu-$vendor in os=gnu ;; arm*-semi) - os=aout + os= + obj=aout ;; c4x-* | tic4x-*) - os=coff + os= + obj=coff ;; c8051-*) - os=elf + os= + obj=elf ;; clipper-intergraph) os=clix ;; hexagon-*) - os=elf + os= + obj=elf ;; tic54x-*) - os=coff + os= + obj=coff ;; tic55x-*) - os=coff + os= + obj=coff ;; tic6x-*) - os=coff + os= + obj=coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1586,19 +1586,24 @@ case $cpu-$vendor in os=sunos3 ;; m68*-cisco) - os=aout + os= + obj=aout ;; mep-*) - os=elf + os= + obj=elf ;; mips*-cisco) - os=elf + os= + obj=elf ;; mips*-*) - os=elf + os= + obj=elf ;; or32-*) - os=coff + os= + obj=coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=sysv3 @@ -1607,7 +1612,8 @@ case $cpu-$vendor in os=sunos4.1.1 ;; pru-*) - os=elf + os= + obj=elf ;; *-be) os=beos @@ -1688,10 +1694,12 @@ case $cpu-$vendor in os=uxpv ;; *-rom68k) - os=coff + os= + obj=coff ;; *-*bug) - os=coff + os= + obj=coff ;; *-apple) os=macos @@ -1709,7 +1717,8 @@ esac fi -# Now, validate our (potentially fixed-up) OS. +# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ). + case $os in # Sometimes we do "kernel-libc", so those need to count as OSes. musl* | newlib* | relibc* | uclibc*) @@ -1720,6 +1729,9 @@ case $os in # VxWorks passes extra cpu info in the 4th filed. simlinux | simwindows | spe) ;; + # See `case $cpu-$os` validation below + ghcjs) + ;; # Now accept the basic system types. # The portable systems comes first. # Each alternative MUST end in a * to match a version number. @@ -1728,7 +1740,7 @@ case $os in | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ | hiux* | abug | nacl* | netware* | windows* \ - | os9* | macos* | osx* | ios* \ + | os9* | macos* | osx* | ios* | tvos* | watchos* \ | mpw* | magic* | mmixware* | mon960* | lnews* \ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ | aos* | aros* | cloudabi* | sortix* | twizzler* \ @@ -1737,11 +1749,11 @@ case $os in | mirbsd* | netbsd* | dicos* | openedition* | ose* \ | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ - | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ - | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | bosx* | nextstep* | cxux* | oabi* \ + | ptx* | ecoff* | winnt* | domain* | vsta* \ | udi* | lites* | ieee* | go32* | aux* | hcos* \ | chorusrdb* | cegcc* | glidix* | serenity* \ - | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | cygwin* | msys* | moss* | proelf* | rtems* \ | midipix* | mingw32* | mingw64* | mint* \ | uxpv* | beos* | mpeix* | udk* | moxiebox* \ | interix* | uwin* | mks* | rhapsody* | darwin* \ @@ -1754,7 +1766,7 @@ case $os in | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ - | fiwix* ) + | fiwix* | mlibc* | cos* | mbr* ) ;; # This one is extra strict with allowed versions sco3.2v2 | sco3.2v[4-9]* | sco5v6*) @@ -1762,41 +1774,99 @@ case $os in ;; none) ;; + kernel* | msvc* ) + # Restricted further below + ;; + '') + if test x"$obj" = x + then + echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2 + fi + ;; *) - echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2 + exit 1 + ;; +esac + +case $obj in + aout* | coff* | elf* | pe*) + ;; + '') + # empty is fine + ;; + *) + echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2 + exit 1 + ;; +esac + +# Here we handle the constraint that a (synthetic) cpu and os are +# valid only in combination with each other and nowhere else. +case $cpu-$os in + # The "javascript-unknown-ghcjs" triple is used by GHC; we + # accept it here in order to tolerate that, but reject any + # variations. + javascript-ghcjs) + ;; + javascript-* | *-ghcjs) + echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2 exit 1 ;; esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. -case $kernel-$os in - linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ - | linux-musl* | linux-relibc* | linux-uclibc* ) +case $kernel-$os-$obj in + linux-gnu*- | linux-dietlibc*- | linux-android*- | linux-newlib*- \ + | linux-musl*- | linux-relibc*- | linux-uclibc*- | linux-mlibc*- ) ;; - uclinux-uclibc* ) + uclinux-uclibc*- ) ;; - -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* ) + managarm-mlibc*- | managarm-kernel*- ) + ;; + windows*-gnu*- | windows*-msvc*-) + ;; + -dietlibc*- | -newlib*- | -musl*- | -relibc*- | -uclibc*- | -mlibc*- ) # These are just libc implementations, not actual OSes, and thus # require a kernel. - echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 exit 1 ;; - kfreebsd*-gnu* | kopensolaris*-gnu*) + -kernel*- ) + echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2 + exit 1 ;; - vxworks-simlinux | vxworks-simwindows | vxworks-spe) + *-kernel*- ) + echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2 + exit 1 ;; - nto-qnx*) + *-msvc*- ) + echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2 + exit 1 ;; - os2-emx) + kfreebsd*-gnu*- | kopensolaris*-gnu*-) ;; - *-eabi* | *-gnueabi*) + vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) ;; - -*) + nto-qnx*-) + ;; + os2-emx-) + ;; + *-eabi*- | *-gnueabi*-) + ;; + none--*) + # None (no kernel, i.e. freestanding / bare metal), + # can be paired with an machine code file format + ;; + -*-) # Blank kernel with real OS is always fine. ;; - *-*) - echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + --*) + # Blank kernel and OS with real machine code file format is always fine. + ;; + *-*-*) + echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2 exit 1 ;; esac @@ -1879,7 +1949,7 @@ case $vendor in ;; esac -echo "$cpu-$vendor-${kernel:+$kernel-}$os" +echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}" exit # Local variables: diff --git a/configure b/configure index cb47b4c5492..16a9036fd0d 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in Revision: 1.28 . +# From configure.in Revision: 1.29 . # Guess values for system-dependent variables and create Makefiles. -# Generated by Autoconf 2.52.20230114. +# Generated by Autoconf 2.52.20231210. # # Copyright 2003-2022,2023 Thomas E. Dickey # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 @@ -711,7 +711,10 @@ Optional Features: --with-dbmalloc test: use Conor Cahill's dbmalloc library --with-valgrind test: use valgrind --disable-leaks test: free permanent memory, analyze leaks - --with-man2html=XXX use XXX rather than groff + --with-manpage-format specify manpage-format: gzip/compress/bzip2/xz, + BSDI/normal and optionally formatted/catonly, + e.g., gzip,formatted + --with-man2html[=XXX] use XXX rather than groff Some influential environment variables: CC C compiler command @@ -782,7 +785,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.52.20230114. Invocation command line was +generated by GNU Autoconf 2.52.20231210. Invocation command line was $ $0 $@ @@ -906,7 +909,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:909: loading site script $ac_site_file" >&5 + { echo "$as_me:912: 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" @@ -917,7 +920,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:920: loading cache $cache_file" >&5 + { echo "$as_me:923: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; @@ -925,7 +928,7 @@ echo "$as_me: loading cache $cache_file" >&6;} esac fi else - { echo "$as_me:928: creating cache $cache_file" >&5 + { echo "$as_me:931: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -941,21 +944,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:944: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 + { echo "$as_me:947: 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:948: error: \`$ac_var' was not set in the previous run" >&5 + { echo "$as_me:951: 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:954: error: \`$ac_var' has changed since the previous run:" >&5 + { echo "$as_me:957: 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:956: former value: $ac_old_val" >&5 + { echo "$as_me:959: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:958: current value: $ac_new_val" >&5 + { echo "$as_me:961: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; @@ -974,9 +977,9 @@ echo "$as_me: current value: $ac_new_val" >&2;} fi done if "$ac_cache_corrupted"; then - { echo "$as_me:977: error: changes in the environment can compromise the build" >&5 + { echo "$as_me:980: 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:979: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 + { { echo "$as_me:982: 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 @@ -1005,10 +1008,10 @@ esac echo "#! $SHELL" >conftest.sh echo "exit 0" >>conftest.sh chmod +x conftest.sh -if { (echo "$as_me:1008: PATH=\".;.\"; conftest.sh") >&5 +if { (echo "$as_me:1011: PATH=\".;.\"; conftest.sh") >&5 (PATH=".;."; conftest.sh) 2>&5 ac_status=$? - echo "$as_me:1011: \$? = $ac_status" >&5 + echo "$as_me:1014: \$? = $ac_status" >&5 (exit "$ac_status"); }; then ac_path_separator=';' else @@ -1036,7 +1039,7 @@ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do fi done if test -z "$ac_aux_dir"; then - { { echo "$as_me:1039: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 + { { echo "$as_me:1042: 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 @@ -1046,11 +1049,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:1049: error: cannot run $ac_config_sub" >&5 + { { echo "$as_me:1052: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } -echo "$as_me:1053: checking build system type" >&5 +echo "$as_me:1056: 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 @@ -1059,23 +1062,23 @@ else test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && - { { echo "$as_me:1062: error: cannot guess build type; you must specify one" >&5 + { { echo "$as_me:1065: 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:1066: error: $ac_config_sub $ac_cv_build_alias failed." >&5 + { { echo "$as_me:1069: 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:1071: result: $ac_cv_build" >&5 +echo "$as_me:1074: 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:1078: checking host system type" >&5 +echo "$as_me:1081: 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 @@ -1084,12 +1087,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:1087: error: $ac_config_sub $ac_cv_host_alias failed" >&5 + { { echo "$as_me:1090: 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:1092: result: $ac_cv_host" >&5 +echo "$as_me:1095: 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/'` @@ -1097,7 +1100,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:1100: checking target system type" >&5 + echo "$as_me:1103: 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 @@ -1106,12 +1109,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:1109: error: $ac_config_sub $ac_cv_target_alias failed" >&5 + { { echo "$as_me:1112: 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:1114: result: $ac_cv_target" >&5 +echo "$as_me:1117: 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/'` @@ -1143,13 +1146,13 @@ else fi test -z "$system_name" && system_name="$cf_cv_system_name" -test -n "$cf_cv_system_name" && echo "$as_me:1146: result: Configuring for $cf_cv_system_name" >&5 +test -n "$cf_cv_system_name" && echo "$as_me:1149: 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:1150: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5 + echo "$as_me:1153: 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:1152: error: \"Please remove config.cache and try again.\"" >&5 + { { echo "$as_me:1155: 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 @@ -1176,7 +1179,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:1179: checking for $ac_word" >&5 +echo "$as_me:1182: 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 @@ -1191,7 +1194,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:1194: found $ac_dir/$ac_word" >&5 +echo "$as_me:1197: found $ac_dir/$ac_word" >&5 break done @@ -1199,10 +1202,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1202: result: $CC" >&5 + echo "$as_me:1205: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1205: result: no" >&5 + echo "$as_me:1208: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1211,7 +1214,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:1214: checking for $ac_word" >&5 +echo "$as_me:1217: 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 @@ -1226,7 +1229,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:1229: found $ac_dir/$ac_word" >&5 +echo "$as_me:1232: found $ac_dir/$ac_word" >&5 break done @@ -1234,10 +1237,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:1237: result: $ac_ct_CC" >&5 + echo "$as_me:1240: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:1240: result: no" >&5 + echo "$as_me:1243: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1250,7 +1253,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:1253: checking for $ac_word" >&5 +echo "$as_me:1256: 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 @@ -1265,7 +1268,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:1268: found $ac_dir/$ac_word" >&5 +echo "$as_me:1271: found $ac_dir/$ac_word" >&5 break done @@ -1273,10 +1276,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1276: result: $CC" >&5 + echo "$as_me:1279: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1279: result: no" >&5 + echo "$as_me:1282: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1285,7 +1288,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:1288: checking for $ac_word" >&5 +echo "$as_me:1291: 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 @@ -1300,7 +1303,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:1303: found $ac_dir/$ac_word" >&5 +echo "$as_me:1306: found $ac_dir/$ac_word" >&5 break done @@ -1308,10 +1311,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:1311: result: $ac_ct_CC" >&5 + echo "$as_me:1314: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:1314: result: no" >&5 + echo "$as_me:1317: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1324,7 +1327,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:1327: checking for $ac_word" >&5 +echo "$as_me:1330: 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 @@ -1344,7 +1347,7 @@ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then continue fi ac_cv_prog_CC="cc" -echo "$as_me:1347: found $ac_dir/$ac_word" >&5 +echo "$as_me:1350: found $ac_dir/$ac_word" >&5 break done @@ -1366,10 +1369,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1369: result: $CC" >&5 + echo "$as_me:1372: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1372: result: no" >&5 + echo "$as_me:1375: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1380,7 +1383,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:1383: checking for $ac_word" >&5 +echo "$as_me:1386: 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 @@ -1395,7 +1398,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:1398: found $ac_dir/$ac_word" >&5 +echo "$as_me:1401: found $ac_dir/$ac_word" >&5 break done @@ -1403,10 +1406,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1406: result: $CC" >&5 + echo "$as_me:1409: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1409: result: no" >&5 + echo "$as_me:1412: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1419,7 +1422,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:1422: checking for $ac_word" >&5 +echo "$as_me:1425: 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 @@ -1434,7 +1437,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:1437: found $ac_dir/$ac_word" >&5 +echo "$as_me:1440: found $ac_dir/$ac_word" >&5 break done @@ -1442,10 +1445,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:1445: result: $ac_ct_CC" >&5 + echo "$as_me:1448: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:1448: result: no" >&5 + echo "$as_me:1451: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1457,32 +1460,32 @@ fi fi -test -z "$CC" && { { echo "$as_me:1460: error: no acceptable cc found in \$PATH" >&5 +test -z "$CC" && { { echo "$as_me:1463: 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:1465:" \ +echo "$as_me:1468:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo "$2"` -{ (eval echo "$as_me:1468: \"$ac_compiler --version &5\"") >&5 +{ (eval echo "$as_me:1471: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? - echo "$as_me:1471: \$? = $ac_status" >&5 + echo "$as_me:1474: \$? = $ac_status" >&5 (exit "$ac_status"); } -{ (eval echo "$as_me:1473: \"$ac_compiler -v &5\"") >&5 +{ (eval echo "$as_me:1476: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? - echo "$as_me:1476: \$? = $ac_status" >&5 + echo "$as_me:1479: \$? = $ac_status" >&5 (exit "$ac_status"); } -{ (eval echo "$as_me:1478: \"$ac_compiler -V &5\"") >&5 +{ (eval echo "$as_me:1481: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? - echo "$as_me:1481: \$? = $ac_status" >&5 + echo "$as_me:1484: \$? = $ac_status" >&5 (exit "$ac_status"); } cat >"conftest.$ac_ext" <<_ACEOF -#line 1485 "configure" +#line 1488 "configure" #include "confdefs.h" int @@ -1498,13 +1501,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:1501: checking for C compiler default output" >&5 +echo "$as_me:1504: 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:1504: \"$ac_link_default\"") >&5 +if { (eval echo "$as_me:1507: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? - echo "$as_me:1507: \$? = $ac_status" >&5 + echo "$as_me:1510: \$? = $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 @@ -1527,34 +1530,34 @@ done else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 -{ { echo "$as_me:1530: error: C compiler cannot create executables" >&5 +{ { echo "$as_me:1533: 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:1536: result: $ac_file" >&5 +echo "$as_me:1539: 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:1541: checking whether the C compiler works" >&5 +echo "$as_me:1544: 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:1547: \"$ac_try\"") >&5 + { (eval echo "$as_me:1550: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1550: \$? = $ac_status" >&5 + echo "$as_me:1553: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { echo "$as_me:1557: error: cannot run C compiled programs. + { { echo "$as_me:1560: 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;} @@ -1562,24 +1565,24 @@ If you meant to cross compile, use \`--host'." >&2;} fi fi fi -echo "$as_me:1565: result: yes" >&5 +echo "$as_me:1568: 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:1572: checking whether we are cross compiling" >&5 +echo "$as_me:1575: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:1574: result: $cross_compiling" >&5 +echo "$as_me:1577: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 -echo "$as_me:1577: checking for executable suffix" >&5 +echo "$as_me:1580: checking for executable suffix" >&5 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 -if { (eval echo "$as_me:1579: \"$ac_link\"") >&5 +if { (eval echo "$as_me:1582: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:1582: \$? = $ac_status" >&5 + echo "$as_me:1585: \$? = $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 @@ -1595,25 +1598,25 @@ for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do esac done else - { { echo "$as_me:1598: error: cannot compute EXEEXT: cannot compile and link" >&5 + { { echo "$as_me:1601: 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:1604: result: $ac_cv_exeext" >&5 +echo "$as_me:1607: 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:1610: checking for object suffix" >&5 +echo "$as_me:1613: 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 1616 "configure" +#line 1619 "configure" #include "confdefs.h" int @@ -1625,10 +1628,10 @@ main (void) } _ACEOF rm -f conftest.o conftest.obj -if { (eval echo "$as_me:1628: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1631: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1631: \$? = $ac_status" >&5 + echo "$as_me:1634: \$? = $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 @@ -1640,24 +1643,24 @@ done else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 -{ { echo "$as_me:1643: error: cannot compute OBJEXT: cannot compile" >&5 +{ { echo "$as_me:1646: 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:1650: result: $ac_cv_objext" >&5 +echo "$as_me:1653: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -echo "$as_me:1654: checking whether we are using the GNU C compiler" >&5 +echo "$as_me:1657: 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 1660 "configure" +#line 1663 "configure" #include "confdefs.h" int @@ -1672,16 +1675,16 @@ main (void) } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:1675: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1678: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1678: \$? = $ac_status" >&5 + echo "$as_me:1681: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:1681: \"$ac_try\"") >&5 + { (eval echo "$as_me:1684: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1684: \$? = $ac_status" >&5 + echo "$as_me:1687: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_compiler_gnu=yes else @@ -1693,19 +1696,19 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext" ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:1696: result: $ac_cv_c_compiler_gnu" >&5 +echo "$as_me:1699: 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:1702: checking whether $CC accepts -g" >&5 +echo "$as_me:1705: 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 1708 "configure" +#line 1711 "configure" #include "confdefs.h" int @@ -1717,16 +1720,16 @@ main (void) } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:1720: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1723: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1723: \$? = $ac_status" >&5 + echo "$as_me:1726: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:1726: \"$ac_try\"") >&5 + { (eval echo "$as_me:1729: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1729: \$? = $ac_status" >&5 + echo "$as_me:1732: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_prog_cc_g=yes else @@ -1736,7 +1739,7 @@ ac_cv_prog_cc_g=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "$as_me:1739: result: $ac_cv_prog_cc_g" >&5 +echo "$as_me:1742: 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 @@ -1763,16 +1766,16 @@ cat >"conftest.$ac_ext" <<_ACEOF #endif _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:1766: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1769: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1769: \$? = $ac_status" >&5 + echo "$as_me:1772: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:1772: \"$ac_try\"") >&5 + { (eval echo "$as_me:1775: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1775: \$? = $ac_status" >&5 + echo "$as_me:1778: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then for ac_declaration in \ ''\ @@ -1784,7 +1787,7 @@ if { (eval echo "$as_me:1766: \"$ac_compile\"") >&5 'void exit (int);' do cat >"conftest.$ac_ext" <<_ACEOF -#line 1787 "configure" +#line 1790 "configure" #include "confdefs.h" #include $ac_declaration @@ -1797,16 +1800,16 @@ exit (42); } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:1800: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1803: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1803: \$? = $ac_status" >&5 + echo "$as_me:1806: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:1806: \"$ac_try\"") >&5 + { (eval echo "$as_me:1809: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1809: \$? = $ac_status" >&5 + echo "$as_me:1812: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else @@ -1816,7 +1819,7 @@ continue fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" cat >"conftest.$ac_ext" <<_ACEOF -#line 1819 "configure" +#line 1822 "configure" #include "confdefs.h" $ac_declaration int @@ -1828,16 +1831,16 @@ exit (42); } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:1831: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1834: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1834: \$? = $ac_status" >&5 + echo "$as_me:1837: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:1837: \"$ac_try\"") >&5 + { (eval echo "$as_me:1840: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1840: \$? = $ac_status" >&5 + echo "$as_me:1843: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then break else @@ -1867,11 +1870,11 @@ ac_main_return="return" GCC_VERSION=none if test "$GCC" = yes ; then - echo "$as_me:1870: checking version of $CC" >&5 + echo "$as_me:1873: 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.].*//'`" + GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[^(]*([^)][^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" test -z "$GCC_VERSION" && GCC_VERSION=unknown - echo "$as_me:1874: result: $GCC_VERSION" >&5 + echo "$as_me:1877: result: $GCC_VERSION" >&5 echo "${ECHO_T}$GCC_VERSION" >&6 fi @@ -1880,12 +1883,12 @@ INTEL_COMPILER=no if test "$GCC" = yes ; then case "$host_os" in (linux*|gnu*) - echo "$as_me:1883: checking if this is really Intel C compiler" >&5 + echo "$as_me:1886: 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 1888 "configure" +#line 1891 "configure" #include "confdefs.h" int @@ -1894,7 +1897,7 @@ main (void) #ifdef __INTEL_COMPILER #else -make an error +#error __INTEL_COMPILER is not defined #endif ; @@ -1902,16 +1905,16 @@ make an error } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:1905: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1908: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1908: \$? = $ac_status" >&5 + echo "$as_me:1911: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:1911: \"$ac_try\"") >&5 + { (eval echo "$as_me:1914: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1914: \$? = $ac_status" >&5 + echo "$as_me:1917: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then INTEL_COMPILER=yes cf_save_CFLAGS="$cf_save_CFLAGS -we147" @@ -1922,7 +1925,7 @@ cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CFLAGS="$cf_save_CFLAGS" - echo "$as_me:1925: result: $INTEL_COMPILER" >&5 + echo "$as_me:1928: result: $INTEL_COMPILER" >&5 echo "${ECHO_T}$INTEL_COMPILER" >&6 ;; esac @@ -1931,11 +1934,11 @@ fi CLANG_COMPILER=no if test "$GCC" = yes ; then - echo "$as_me:1934: checking if this is really Clang C compiler" >&5 + echo "$as_me:1937: 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" cat >"conftest.$ac_ext" <<_ACEOF -#line 1938 "configure" +#line 1941 "configure" #include "confdefs.h" int @@ -1944,7 +1947,7 @@ main (void) #ifdef __clang__ #else -make an error +#error __clang__ is not defined #endif ; @@ -1952,16 +1955,16 @@ make an error } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:1955: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1958: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1958: \$? = $ac_status" >&5 + echo "$as_me:1961: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:1961: \"$ac_try\"") >&5 + { (eval echo "$as_me:1964: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1964: \$? = $ac_status" >&5 + echo "$as_me:1967: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then CLANG_COMPILER=yes @@ -1971,7 +1974,7 @@ cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CFLAGS="$cf_save_CFLAGS" - echo "$as_me:1974: result: $CLANG_COMPILER" >&5 + echo "$as_me:1977: result: $CLANG_COMPILER" >&5 echo "${ECHO_T}$CLANG_COMPILER" >&6 fi @@ -1980,30 +1983,30 @@ CLANG_VERSION=none if test "x$CLANG_COMPILER" = "xyes" ; then case "$CC" in (c[1-9][0-9]|*/c[1-9][0-9]) - { echo "$as_me:1983: WARNING: replacing broken compiler alias $CC" >&5 + { echo "$as_me:1986: WARNING: replacing broken compiler alias $CC" >&5 echo "$as_me: WARNING: replacing broken compiler alias $CC" >&2;} CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`" CC=clang ;; esac - echo "$as_me:1990: checking version of $CC" >&5 + echo "$as_me:1993: checking version of $CC" >&5 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6 CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" test -z "$CLANG_VERSION" && CLANG_VERSION=unknown - echo "$as_me:1994: result: $CLANG_VERSION" >&5 + echo "$as_me:1997: result: $CLANG_VERSION" >&5 echo "${ECHO_T}$CLANG_VERSION" >&6 for cf_clang_opt in \ -Qunused-arguments \ -Wno-error=implicit-function-declaration do - echo "$as_me:2001: checking if option $cf_clang_opt works" >&5 + echo "$as_me:2004: checking if option $cf_clang_opt works" >&5 echo $ECHO_N "checking if option $cf_clang_opt works... $ECHO_C" >&6 cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cf_clang_opt" cat >"conftest.$ac_ext" <<_ACEOF -#line 2006 "configure" +#line 2009 "configure" #include "confdefs.h" #include @@ -2017,16 +2020,16 @@ main (void) } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" -if { (eval echo "$as_me:2020: \"$ac_link\"") >&5 +if { (eval echo "$as_me:2023: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:2023: \$? = $ac_status" >&5 + echo "$as_me:2026: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' - { (eval echo "$as_me:2026: \"$ac_try\"") >&5 + { (eval echo "$as_me:2029: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2029: \$? = $ac_status" >&5 + echo "$as_me:2032: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_clang_optok=yes @@ -2037,13 +2040,13 @@ cat "conftest.$ac_ext" >&5 cf_clang_optok=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" - echo "$as_me:2040: result: $cf_clang_optok" >&5 + echo "$as_me:2043: result: $cf_clang_optok" >&5 echo "${ECHO_T}$cf_clang_optok" >&6 CFLAGS="$cf_save_CFLAGS" if test "$cf_clang_optok" = yes; then test -n "$verbose" && echo " adding option $cf_clang_opt" 1>&6 -echo "${as_me:-configure}:2046: testing adding option $cf_clang_opt ..." 1>&5 +echo "${as_me:-configure}:2049: testing adding option $cf_clang_opt ..." 1>&5 test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_clang_opt" @@ -2052,7 +2055,7 @@ echo "${as_me:-configure}:2046: testing adding option $cf_clang_opt ..." 1>&5 done fi -echo "$as_me:2055: checking for $CC option to accept ANSI C" >&5 +echo "$as_me:2058: 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 @@ -2060,7 +2063,7 @@ else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >"conftest.$ac_ext" <<_ACEOF -#line 2063 "configure" +#line 2066 "configure" #include "confdefs.h" #include #include @@ -2107,16 +2110,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:2110: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2113: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2113: \$? = $ac_status" >&5 + echo "$as_me:2116: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:2116: \"$ac_try\"") >&5 + { (eval echo "$as_me:2119: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2119: \$? = $ac_status" >&5 + echo "$as_me:2122: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_prog_cc_stdc=$ac_arg break @@ -2133,10 +2136,10 @@ fi case "x$ac_cv_prog_cc_stdc" in x|xno) - echo "$as_me:2136: result: none needed" >&5 + echo "$as_me:2139: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) - echo "$as_me:2139: result: $ac_cv_prog_cc_stdc" >&5 + echo "$as_me:2142: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac @@ -2144,13 +2147,13 @@ esac # This should have been defined by AC_PROG_CC : "${CC:=cc}" -echo "$as_me:2147: checking \$CFLAGS variable" >&5 +echo "$as_me:2150: checking \$CFLAGS variable" >&5 echo $ECHO_N "checking \$CFLAGS variable... $ECHO_C" >&6 case "x$CFLAGS" in (*-[IUD]*) - echo "$as_me:2151: result: broken" >&5 + echo "$as_me:2154: result: broken" >&5 echo "${ECHO_T}broken" >&6 - { echo "$as_me:2153: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&5 + { echo "$as_me:2156: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&5 echo "$as_me: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&2;} cf_flags="$CFLAGS" CFLAGS= @@ -2258,22 +2261,22 @@ fi done ;; (*) - echo "$as_me:2261: result: ok" >&5 + echo "$as_me:2264: result: ok" >&5 echo "${ECHO_T}ok" >&6 ;; esac -echo "$as_me:2266: checking \$CC variable" >&5 +echo "$as_me:2269: checking \$CC variable" >&5 echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6 case "$CC" in (*[\ \ ]-*) - echo "$as_me:2270: result: broken" >&5 + echo "$as_me:2273: result: broken" >&5 echo "${ECHO_T}broken" >&6 - { echo "$as_me:2272: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&5 + { echo "$as_me:2275: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&5 echo "$as_me: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;} # humor him... cf_prog=`echo "$CC" | sed -e 's/ / /g' -e 's/[ ]* / /g' -e 's/[ ]*[ ]-[^ ].*//'` - cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", substr($0,1+length(prog))); }'` + cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"` CC="$cf_prog" for cf_arg in $cf_flags do @@ -2386,24 +2389,24 @@ fi done test -n "$verbose" && echo " resulting CC: '$CC'" 1>&6 -echo "${as_me:-configure}:2389: testing resulting CC: '$CC' ..." 1>&5 +echo "${as_me:-configure}:2392: testing resulting CC: '$CC' ..." 1>&5 test -n "$verbose" && echo " resulting CFLAGS: '$CFLAGS'" 1>&6 -echo "${as_me:-configure}:2393: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5 +echo "${as_me:-configure}:2396: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5 test -n "$verbose" && echo " resulting CPPFLAGS: '$CPPFLAGS'" 1>&6 -echo "${as_me:-configure}:2397: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5 +echo "${as_me:-configure}:2400: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5 ;; (*) - echo "$as_me:2401: result: ok" >&5 + echo "$as_me:2404: result: ok" >&5 echo "${ECHO_T}ok" >&6 ;; esac -echo "$as_me:2406: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "$as_me:2409: 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 @@ -2423,11 +2426,11 @@ fi rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:2426: result: yes" >&5 + echo "$as_me:2429: result: yes" >&5 echo "${ECHO_T}yes" >&6 SET_MAKE= else - echo "$as_me:2430: result: no" >&5 + echo "$as_me:2433: result: no" >&5 echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi @@ -2444,7 +2447,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:2447: checking for a BSD compatible install" >&5 +echo "$as_me:2450: 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 @@ -2493,7 +2496,7 @@ fi INSTALL=$ac_install_sh fi fi -echo "$as_me:2496: result: $INSTALL" >&5 +echo "$as_me:2499: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. @@ -2504,7 +2507,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -echo "$as_me:2507: checking if filesystem supports mixed-case filenames" >&5 +echo "$as_me:2510: 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 @@ -2531,7 +2534,7 @@ else fi fi -echo "$as_me:2534: result: $cf_cv_mixedcase" >&5 +echo "$as_me:2537: result: $cf_cv_mixedcase" >&5 echo "${ECHO_T}$cf_cv_mixedcase" >&6 test "$cf_cv_mixedcase" = yes && cat >>confdefs.h <<\EOF @@ -2542,7 +2545,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:2545: checking for $ac_word" >&5 +echo "$as_me:2548: 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 @@ -2557,7 +2560,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:2560: found $ac_dir/$ac_word" >&5 +echo "$as_me:2563: found $ac_dir/$ac_word" >&5 break done @@ -2565,10 +2568,10 @@ fi fi CTAGS=$ac_cv_prog_CTAGS if test -n "$CTAGS"; then - echo "$as_me:2568: result: $CTAGS" >&5 + echo "$as_me:2571: result: $CTAGS" >&5 echo "${ECHO_T}$CTAGS" >&6 else - echo "$as_me:2571: result: no" >&5 + echo "$as_me:2574: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2579,7 +2582,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:2582: checking for $ac_word" >&5 +echo "$as_me:2585: 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 @@ -2594,7 +2597,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:2597: found $ac_dir/$ac_word" >&5 +echo "$as_me:2600: found $ac_dir/$ac_word" >&5 break done @@ -2602,10 +2605,10 @@ fi fi ETAGS=$ac_cv_prog_ETAGS if test -n "$ETAGS"; then - echo "$as_me:2605: result: $ETAGS" >&5 + echo "$as_me:2608: result: $ETAGS" >&5 echo "${ECHO_T}$ETAGS" >&6 else - echo "$as_me:2608: result: no" >&5 + echo "$as_me:2611: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2614,7 +2617,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:2617: checking for $ac_word" >&5 +echo "$as_me:2620: 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 @@ -2629,7 +2632,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:2632: found $ac_dir/$ac_word" >&5 +echo "$as_me:2635: found $ac_dir/$ac_word" >&5 break done @@ -2638,17 +2641,17 @@ fi fi MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS if test -n "$MAKE_LOWER_TAGS"; then - echo "$as_me:2641: result: $MAKE_LOWER_TAGS" >&5 + echo "$as_me:2644: result: $MAKE_LOWER_TAGS" >&5 echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6 else - echo "$as_me:2644: result: no" >&5 + echo "$as_me:2647: 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:2651: checking for $ac_word" >&5 +echo "$as_me:2654: 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 @@ -2663,7 +2666,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:2666: found $ac_dir/$ac_word" >&5 +echo "$as_me:2669: found $ac_dir/$ac_word" >&5 break done @@ -2672,10 +2675,10 @@ fi fi MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS if test -n "$MAKE_UPPER_TAGS"; then - echo "$as_me:2675: result: $MAKE_UPPER_TAGS" >&5 + echo "$as_me:2678: result: $MAKE_UPPER_TAGS" >&5 echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6 else - echo "$as_me:2678: result: no" >&5 + echo "$as_me:2681: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2699,7 +2702,7 @@ 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:2702: checking for $ac_word" >&5 +echo "$as_me:2705: 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 @@ -2714,7 +2717,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_AWK="$ac_prog" -echo "$as_me:2717: found $ac_dir/$ac_word" >&5 +echo "$as_me:2720: found $ac_dir/$ac_word" >&5 break done @@ -2722,17 +2725,17 @@ fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - echo "$as_me:2725: result: $AWK" >&5 + echo "$as_me:2728: result: $AWK" >&5 echo "${ECHO_T}$AWK" >&6 else - echo "$as_me:2728: result: no" >&5 + echo "$as_me:2731: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$AWK" && break done -test -z "$AWK" && { { echo "$as_me:2735: error: No awk program found" >&5 +test -z "$AWK" && { { echo "$as_me:2738: error: No awk program found" >&5 echo "$as_me: error: No awk program found" >&2;} { (exit 1); exit 1; }; } @@ -2740,7 +2743,7 @@ for ac_prog in lint cppcheck splint 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:2743: checking for $ac_word" >&5 +echo "$as_me:2746: 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 @@ -2755,7 +2758,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:2758: found $ac_dir/$ac_word" >&5 +echo "$as_me:2761: found $ac_dir/$ac_word" >&5 break done @@ -2763,10 +2766,10 @@ fi fi LINT=$ac_cv_prog_LINT if test -n "$LINT"; then - echo "$as_me:2766: result: $LINT" >&5 + echo "$as_me:2769: result: $LINT" >&5 echo "${ECHO_T}$LINT" >&6 else - echo "$as_me:2769: result: no" >&5 + echo "$as_me:2772: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2779,14 +2782,14 @@ case "x$LINT" in ;; esac -echo "$as_me:2782: checking if the POSIX test-macros are already defined" >&5 +echo "$as_me:2785: checking if the POSIX test-macros are already defined" >&5 echo $ECHO_N "checking if the POSIX test-macros are already defined... $ECHO_C" >&6 if test "${cf_cv_posix_visible+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF -#line 2789 "configure" +#line 2792 "configure" #include "confdefs.h" #include int @@ -2805,16 +2808,16 @@ main (void) } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:2808: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2811: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2811: \$? = $ac_status" >&5 + echo "$as_me:2814: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:2814: \"$ac_try\"") >&5 + { (eval echo "$as_me:2817: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2817: \$? = $ac_status" >&5 + echo "$as_me:2820: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_posix_visible=no else @@ -2825,7 +2828,7 @@ fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "$as_me:2828: result: $cf_cv_posix_visible" >&5 +echo "$as_me:2831: result: $cf_cv_posix_visible" >&5 echo "${ECHO_T}$cf_cv_posix_visible" >&6 if test "$cf_cv_posix_visible" = no; then @@ -2838,9 +2841,6 @@ case "$host_os" in (aix[4-7]*) cf_xopen_source="-D_ALL_SOURCE" ;; -(msys) - cf_XOPEN_SOURCE=600 - ;; (darwin[0-8].*) cf_xopen_source="-D_APPLE_C_SOURCE" ;; @@ -2866,7 +2866,7 @@ case "$host_os" in cf_xopen_source="-D_SGI_SOURCE" cf_XOPEN_SOURCE= ;; -(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin) +(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc) cf_gnu_xopen_source=$cf_XOPEN_SOURCE @@ -3416,7 +3416,7 @@ main (void) { #ifndef _POSIX_C_SOURCE -make an error +#error _POSIX_C_SOURCE is not defined #endif ; return 0; @@ -3461,7 +3461,7 @@ main (void) { #ifdef _POSIX_SOURCE -make an error +#error _POSIX_SOURCE is defined #endif ; return 0; @@ -3507,7 +3507,7 @@ main (void) { #ifndef _POSIX_C_SOURCE -make an error +#error _POSIX_C_SOURCE is not defined #endif ; return 0; @@ -3698,16 +3698,14 @@ else #line 3698 "configure" #include "confdefs.h" -#include -#include -#include +$ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE -make an error +#error _XOPEN_SOURCE is not defined #endif ; @@ -3715,16 +3713,16 @@ make an error } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:3718: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3716: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3721: \$? = $ac_status" >&5 + echo "$as_me:3719: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:3724: \"$ac_try\"") >&5 + { (eval echo "$as_me:3722: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3727: \$? = $ac_status" >&5 + echo "$as_me:3725: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_xopen_source=no else @@ -3736,19 +3734,17 @@ cf_save="$CPPFLAGS" CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" cat >"conftest.$ac_ext" <<_ACEOF -#line 3739 "configure" +#line 3737 "configure" #include "confdefs.h" -#include -#include -#include +$ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE -make an error +#error _XOPEN_SOURCE is not defined #endif ; @@ -3756,16 +3752,16 @@ make an error } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:3759: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3755: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3762: \$? = $ac_status" >&5 + echo "$as_me:3758: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:3765: \"$ac_try\"") >&5 + { (eval echo "$as_me:3761: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3768: \$? = $ac_status" >&5 + echo "$as_me:3764: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_xopen_source=no else @@ -3780,7 +3776,7 @@ fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "$as_me:3783: result: $cf_cv_xopen_source" >&5 +echo "$as_me:3779: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then @@ -3940,16 +3936,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:3943: checking if we should define _POSIX_C_SOURCE" >&5 +echo "$as_me:3939: 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}:3949: testing if the symbol is already defined go no further ..." 1>&5 +echo "${as_me:-configure}:3945: testing if the symbol is already defined go no further ..." 1>&5 cat >"conftest.$ac_ext" <<_ACEOF -#line 3952 "configure" +#line 3948 "configure" #include "confdefs.h" #include int @@ -3957,23 +3953,23 @@ main (void) { #ifndef _POSIX_C_SOURCE -make an error +#error _POSIX_C_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:3967: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3963: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3970: \$? = $ac_status" >&5 + echo "$as_me:3966: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:3973: \"$ac_try\"") >&5 + { (eval echo "$as_me:3969: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3976: \$? = $ac_status" >&5 + echo "$as_me:3972: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_posix_c_source=no else @@ -3994,7 +3990,7 @@ cf_want_posix_source=no esac if test "$cf_want_posix_source" = yes ; then cat >"conftest.$ac_ext" <<_ACEOF -#line 3997 "configure" +#line 3993 "configure" #include "confdefs.h" #include int @@ -4002,23 +3998,23 @@ main (void) { #ifdef _POSIX_SOURCE -make an error +#error _POSIX_SOURCE is defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:4012: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4008: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4015: \$? = $ac_status" >&5 + echo "$as_me:4011: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:4018: \"$ac_try\"") >&5 + { (eval echo "$as_me:4014: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4021: \$? = $ac_status" >&5 + echo "$as_me:4017: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else @@ -4029,7 +4025,7 @@ fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "${as_me:-configure}:4032: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 +echo "${as_me:-configure}:4028: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS" @@ -4037,10 +4033,10 @@ echo "${as_me:-configure}:4032: testing ifdef from value $cf_POSIX_C_SOURCE ..." test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_cv_posix_c_source" -echo "${as_me:-configure}:4040: testing if the second compile does not leave our definition intact error ..." 1>&5 +echo "${as_me:-configure}:4036: testing if the second compile does not leave our definition intact error ..." 1>&5 cat >"conftest.$ac_ext" <<_ACEOF -#line 4043 "configure" +#line 4039 "configure" #include "confdefs.h" #include int @@ -4048,23 +4044,23 @@ main (void) { #ifndef _POSIX_C_SOURCE -make an error +#error _POSIX_C_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:4058: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4054: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4061: \$? = $ac_status" >&5 + echo "$as_me:4057: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:4064: \"$ac_try\"") >&5 + { (eval echo "$as_me:4060: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4067: \$? = $ac_status" >&5 + echo "$as_me:4063: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else @@ -4080,7 +4076,7 @@ fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "$as_me:4083: result: $cf_cv_posix_c_source" >&5 +echo "$as_me:4079: 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 @@ -4190,25 +4186,23 @@ fi fi # cf_cv_posix_visible # Some of these niche implementations use copy/paste, double-check... - if test "$cf_cv_xopen_source" != no ; then - test -n "$verbose" && echo " checking if _POSIX_C_SOURCE inteferes" 1>&6 + if test "$cf_cv_xopen_source" = no ; then + test -n "$verbose" && echo " checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE" 1>&6 -echo "${as_me:-configure}:4196: testing checking if _POSIX_C_SOURCE inteferes ..." 1>&5 +echo "${as_me:-configure}:4192: testing checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE ..." 1>&5 cat >"conftest.$ac_ext" <<_ACEOF -#line 4199 "configure" +#line 4195 "configure" #include "confdefs.h" -#include -#include -#include +$ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE -make an error +#error _XOPEN_SOURCE is not defined #endif ; @@ -4216,23 +4210,23 @@ make an error } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:4219: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4213: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4222: \$? = $ac_status" >&5 + echo "$as_me:4216: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:4225: \"$ac_try\"") >&5 + { (eval echo "$as_me:4219: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4228: \$? = $ac_status" >&5 + echo "$as_me:4222: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 - { echo "$as_me:4235: WARNING: _POSIX_C_SOURCE definition is not usable" >&5 + { echo "$as_me:4229: WARNING: _POSIX_C_SOURCE definition is not usable" >&5 echo "$as_me: WARNING: _POSIX_C_SOURCE definition is not usable" >&2;} CPPFLAGS="$cf_save_xopen_cppflags" fi @@ -4255,7 +4249,7 @@ do test "$CFLAGS" != "$cf_old_cflag" || break test -n "$verbose" && echo " removing old option $cf_add_cflags from CFLAGS" 1>&6 -echo "${as_me:-configure}:4258: testing removing old option $cf_add_cflags from CFLAGS ..." 1>&5 +echo "${as_me:-configure}:4252: testing removing old option $cf_add_cflags from CFLAGS ..." 1>&5 CFLAGS="$cf_old_cflag" done @@ -4267,7 +4261,7 @@ do test "$CPPFLAGS" != "$cf_old_cflag" || break test -n "$verbose" && echo " removing old option $cf_add_cflags from CPPFLAGS" 1>&6 -echo "${as_me:-configure}:4270: testing removing old option $cf_add_cflags from CPPFLAGS ..." 1>&5 +echo "${as_me:-configure}:4264: testing removing old option $cf_add_cflags from CPPFLAGS ..." 1>&5 CPPFLAGS="$cf_old_cflag" done @@ -4355,7 +4349,7 @@ done if test -n "$cf_new_cflags" ; then test -n "$verbose" && echo " add to \$CFLAGS $cf_new_cflags" 1>&6 -echo "${as_me:-configure}:4358: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5 +echo "${as_me:-configure}:4352: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5 test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" @@ -4365,7 +4359,7 @@ fi if test -n "$cf_new_cppflags" ; then test -n "$verbose" && echo " add to \$CPPFLAGS $cf_new_cppflags" 1>&6 -echo "${as_me:-configure}:4368: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5 +echo "${as_me:-configure}:4362: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5 test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" @@ -4375,7 +4369,7 @@ fi if test -n "$cf_new_extra_cppflags" ; then test -n "$verbose" && echo " add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6 -echo "${as_me:-configure}:4378: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5 +echo "${as_me:-configure}:4372: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5 test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" @@ -4387,10 +4381,10 @@ done fi if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then - echo "$as_me:4390: checking if _XOPEN_SOURCE really is set" >&5 + echo "$as_me:4384: 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 4393 "configure" +#line 4387 "configure" #include "confdefs.h" #include int @@ -4398,23 +4392,23 @@ main (void) { #ifndef _XOPEN_SOURCE -make an error +#error _XOPEN_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:4408: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4402: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4411: \$? = $ac_status" >&5 + echo "$as_me:4405: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:4414: \"$ac_try\"") >&5 + { (eval echo "$as_me:4408: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4417: \$? = $ac_status" >&5 + echo "$as_me:4411: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_XOPEN_SOURCE_set=yes else @@ -4423,12 +4417,12 @@ cat "conftest.$ac_ext" >&5 cf_XOPEN_SOURCE_set=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" - echo "$as_me:4426: result: $cf_XOPEN_SOURCE_set" >&5 + echo "$as_me:4420: 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 4431 "configure" +#line 4425 "configure" #include "confdefs.h" #include int @@ -4436,23 +4430,23 @@ main (void) { #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE -make an error +#error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:4446: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4440: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4449: \$? = $ac_status" >&5 + echo "$as_me:4443: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:4452: \"$ac_try\"") >&5 + { (eval echo "$as_me:4446: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4455: \$? = $ac_status" >&5 + echo "$as_me:4449: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_XOPEN_SOURCE_set_ok=yes else @@ -4463,31 +4457,29 @@ fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" if test "$cf_XOPEN_SOURCE_set_ok" = no then - { echo "$as_me:4466: WARNING: _XOPEN_SOURCE is lower than requested" >&5 + { echo "$as_me:4460: WARNING: _XOPEN_SOURCE is lower than requested" >&5 echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;} fi else -echo "$as_me:4471: checking if we should define _XOPEN_SOURCE" >&5 +echo "$as_me:4465: 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 4478 "configure" +#line 4472 "configure" #include "confdefs.h" -#include -#include -#include +$ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE -make an error +#error _XOPEN_SOURCE is not defined #endif ; @@ -4495,16 +4487,16 @@ make an error } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:4498: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4490: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4501: \$? = $ac_status" >&5 + echo "$as_me:4493: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:4504: \"$ac_try\"") >&5 + { (eval echo "$as_me:4496: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4507: \$? = $ac_status" >&5 + echo "$as_me:4499: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_xopen_source=no else @@ -4516,19 +4508,17 @@ cf_save="$CPPFLAGS" CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" cat >"conftest.$ac_ext" <<_ACEOF -#line 4519 "configure" +#line 4511 "configure" #include "confdefs.h" -#include -#include -#include +$ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE -make an error +#error _XOPEN_SOURCE is not defined #endif ; @@ -4536,16 +4526,16 @@ make an error } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:4539: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4529: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4542: \$? = $ac_status" >&5 + echo "$as_me:4532: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:4545: \"$ac_try\"") >&5 + { (eval echo "$as_me:4535: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4548: \$? = $ac_status" >&5 + echo "$as_me:4538: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_xopen_source=no else @@ -4560,7 +4550,7 @@ fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "$as_me:4563: result: $cf_cv_xopen_source" >&5 +echo "$as_me:4553: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then @@ -4711,7 +4701,7 @@ for ac_prog in ggrep grep 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:4714: checking for $ac_word" >&5 +echo "$as_me:4704: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4726,7 +4716,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_GREP="$ac_prog" -echo "$as_me:4729: found $ac_dir/$ac_word" >&5 +echo "$as_me:4719: found $ac_dir/$ac_word" >&5 break done @@ -4734,10 +4724,10 @@ fi fi GREP=$ac_cv_prog_GREP if test -n "$GREP"; then - echo "$as_me:4737: result: $GREP" >&5 + echo "$as_me:4727: result: $GREP" >&5 echo "${ECHO_T}$GREP" >&6 else - echo "$as_me:4740: result: no" >&5 + echo "$as_me:4730: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -4745,7 +4735,7 @@ fi done test -n "$GREP" || GREP=": " -echo "$as_me:4748: checking for egrep" >&5 +echo "$as_me:4738: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4757,7 +4747,7 @@ else 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:4760: checking for $ac_word" >&5 +echo "$as_me:4750: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4774,7 +4764,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_EGREP="$ac_dir/$ac_word" - echo "$as_me:4777: found $ac_dir/$ac_word" >&5 + echo "$as_me:4767: found $ac_dir/$ac_word" >&5 break fi done @@ -4785,10 +4775,10 @@ fi EGREP=$ac_cv_path_EGREP if test -n "$EGREP"; then - echo "$as_me:4788: result: $EGREP" >&5 + echo "$as_me:4778: result: $EGREP" >&5 echo "${ECHO_T}$EGREP" >&6 else - echo "$as_me:4791: result: no" >&5 + echo "$as_me:4781: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -4796,12 +4786,12 @@ fi done test -n "$EGREP" || EGREP=": " - test "x$ac_cv_path_EGREP" = "x:" && { { echo "$as_me:4799: error: cannot find workable egrep" >&5 + test "x$ac_cv_path_EGREP" = "x:" && { { echo "$as_me:4789: error: cannot find workable egrep" >&5 echo "$as_me: error: cannot find workable egrep" >&2;} { (exit 1); exit 1; }; } fi fi -echo "$as_me:4804: result: $ac_cv_path_EGREP" >&5 +echo "$as_me:4794: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6 EGREP="$ac_cv_path_EGREP" @@ -4811,7 +4801,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:4814: checking how to run the C preprocessor" >&5 +echo "$as_me:4804: 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 @@ -4832,18 +4822,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 4835 "configure" +#line 4825 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:4840: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:4830: \"$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:4846: \$? = $ac_status" >&5 + echo "$as_me:4836: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4866,17 +4856,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 4869 "configure" +#line 4859 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4873: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:4863: \"$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:4879: \$? = $ac_status" >&5 + echo "$as_me:4869: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4913,7 +4903,7 @@ fi else ac_cv_prog_CPP=$CPP fi -echo "$as_me:4916: result: $CPP" >&5 +echo "$as_me:4906: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -4923,18 +4913,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 4926 "configure" +#line 4916 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:4931: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:4921: \"$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:4937: \$? = $ac_status" >&5 + echo "$as_me:4927: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4957,17 +4947,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 4960 "configure" +#line 4950 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4964: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:4954: \"$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:4970: \$? = $ac_status" >&5 + echo "$as_me:4960: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4995,7 +4985,7 @@ rm -f conftest.err "conftest.$ac_ext" if $ac_preproc_ok; then : else - { { echo "$as_me:4998: error: C preprocessor \"$CPP\" fails sanity check" >&5 + { { echo "$as_me:4988: error: C preprocessor \"$CPP\" fails sanity check" >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi @@ -5007,13 +4997,13 @@ ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ex ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" -echo "$as_me:5010: checking for ANSI C header files" >&5 +echo "$as_me:5000: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF -#line 5016 "configure" +#line 5006 "configure" #include "confdefs.h" #include #include @@ -5021,13 +5011,13 @@ else #include _ACEOF -if { (eval echo "$as_me:5024: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:5014: \"$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:5030: \$? = $ac_status" >&5 + echo "$as_me:5020: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -5049,7 +5039,7 @@ rm -f conftest.err "conftest.$ac_ext" if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >"conftest.$ac_ext" <<_ACEOF -#line 5052 "configure" +#line 5042 "configure" #include "confdefs.h" #include @@ -5067,7 +5057,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >"conftest.$ac_ext" <<_ACEOF -#line 5070 "configure" +#line 5060 "configure" #include "confdefs.h" #include @@ -5088,7 +5078,7 @@ if test $ac_cv_header_stdc = yes; then : else cat >"conftest.$ac_ext" <<_ACEOF -#line 5091 "configure" +#line 5081 "configure" #include "confdefs.h" #include #if ((' ' & 0x0FF) == 0x020) @@ -5114,15 +5104,15 @@ main (void) } _ACEOF rm -f "conftest$ac_exeext" -if { (eval echo "$as_me:5117: \"$ac_link\"") >&5 +if { (eval echo "$as_me:5107: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:5120: \$? = $ac_status" >&5 + echo "$as_me:5110: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' - { (eval echo "$as_me:5122: \"$ac_try\"") >&5 + { (eval echo "$as_me:5112: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5125: \$? = $ac_status" >&5 + echo "$as_me:5115: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else @@ -5135,7 +5125,7 @@ rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftes fi fi fi -echo "$as_me:5138: result: $ac_cv_header_stdc" >&5 +echo "$as_me:5128: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then @@ -5151,28 +5141,28 @@ for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:5154: checking for $ac_header" >&5 +echo "$as_me:5144: 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 5160 "configure" +#line 5150 "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:5166: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:5156: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:5169: \$? = $ac_status" >&5 + echo "$as_me:5159: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:5172: \"$ac_try\"") >&5 + { (eval echo "$as_me:5162: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5175: \$? = $ac_status" >&5 + echo "$as_me:5165: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then eval "$as_ac_Header=yes" else @@ -5182,7 +5172,7 @@ eval "$as_ac_Header=no" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "$as_me:5185: result: `eval echo '${'"$as_ac_Header"'}'`" >&5 +echo "$as_me:5175: 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:5185: checking whether exit is declared" >&5 echo $ECHO_N "checking whether exit is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_exit+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF -#line 5201 "configure" +#line 5191 "configure" #include "confdefs.h" $ac_includes_default int main (void) { #ifndef exit - char *p = (char *) exit; (void) p; + (void) exit; #endif ; @@ -5213,16 +5203,16 @@ main (void) } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:5216: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:5206: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:5219: \$? = $ac_status" >&5 + echo "$as_me:5209: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:5222: \"$ac_try\"") >&5 + { (eval echo "$as_me:5212: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5225: \$? = $ac_status" >&5 + echo "$as_me:5215: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_have_decl_exit=yes else @@ -5232,29 +5222,29 @@ ac_cv_have_decl_exit=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "$as_me:5235: result: $ac_cv_have_decl_exit" >&5 +echo "$as_me:5225: result: $ac_cv_have_decl_exit" >&5 echo "${ECHO_T}$ac_cv_have_decl_exit" >&6 for ac_header in fcntl.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:5241: checking for $ac_header" >&5 +echo "$as_me:5231: 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 5247 "configure" +#line 5237 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:5251: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:5241: \"$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:5257: \$? = $ac_status" >&5 + echo "$as_me:5247: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -5273,7 +5263,7 @@ else fi rm -f conftest.err "conftest.$ac_ext" fi -echo "$as_me:5276: result: `eval echo '${'"$as_ac_Header"'}'`" >&5 +echo "$as_me:5266: 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:5281: 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 5297 "configure" +#line 5287 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:5301: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:5291: \"$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:5307: \$? = $ac_status" >&5 + echo "$as_me:5297: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -5323,7 +5313,7 @@ else fi rm -f conftest.err "conftest.$ac_ext" fi -echo "$as_me:5326: result: `eval echo '${'"$as_ac_Header"'}'`" >&5 +echo "$as_me:5316: 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:5326: 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 @@ -5344,14 +5334,14 @@ if test "$cross_compiling" = yes; then cf_cv_func_mkstemp=maybe else cat >"conftest.$ac_ext" <<_ACEOF -#line 5347 "configure" +#line 5337 "configure" #include "confdefs.h" $ac_includes_default int main(void) { - char *tmpl = "conftestXXXXXX"; + static char tmpl[] = "conftestXXXXXX"; char name[2][80]; int n; int result = 0; @@ -5379,15 +5369,15 @@ int main(void) _ACEOF rm -f "conftest$ac_exeext" -if { (eval echo "$as_me:5382: \"$ac_link\"") >&5 +if { (eval echo "$as_me:5372: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:5385: \$? = $ac_status" >&5 + echo "$as_me:5375: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' - { (eval echo "$as_me:5387: \"$ac_try\"") >&5 + { (eval echo "$as_me:5377: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5390: \$? = $ac_status" >&5 + echo "$as_me:5380: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_func_mkstemp=yes @@ -5402,16 +5392,16 @@ rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftes fi fi -echo "$as_me:5405: result: $cf_cv_func_mkstemp" >&5 +echo "$as_me:5395: 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:5408: checking for mkstemp" >&5 + echo "$as_me:5398: 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 5414 "configure" +#line 5404 "configure" #include "confdefs.h" #define mkstemp autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ @@ -5442,16 +5432,16 @@ main (void) } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" -if { (eval echo "$as_me:5445: \"$ac_link\"") >&5 +if { (eval echo "$as_me:5435: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:5448: \$? = $ac_status" >&5 + echo "$as_me:5438: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' - { (eval echo "$as_me:5451: \"$ac_try\"") >&5 + { (eval echo "$as_me:5441: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5454: \$? = $ac_status" >&5 + echo "$as_me:5444: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_mkstemp=yes else @@ -5461,7 +5451,7 @@ ac_cv_func_mkstemp=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi -echo "$as_me:5464: result: $ac_cv_func_mkstemp" >&5 +echo "$as_me:5454: result: $ac_cv_func_mkstemp" >&5 echo "${ECHO_T}$ac_cv_func_mkstemp" >&6 fi @@ -5476,23 +5466,23 @@ fi for ac_header in unistd.h getopt.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:5479: checking for $ac_header" >&5 +echo "$as_me:5469: 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 5485 "configure" +#line 5475 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:5489: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:5479: \"$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:5495: \$? = $ac_status" >&5 + echo "$as_me:5485: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -5511,7 +5501,7 @@ else fi rm -f conftest.err "conftest.$ac_ext" fi -echo "$as_me:5514: result: `eval echo '${'"$as_ac_Header"'}'`" >&5 +echo "$as_me:5504: 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:5514: checking for header declaring getopt variables" >&5 echo $ECHO_N "checking for header declaring getopt variables... $ECHO_C" >&6 if test "${cf_cv_getopt_header+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5531,7 +5521,7 @@ cf_cv_getopt_header=none for cf_header in stdio.h stdlib.h unistd.h getopt.h do cat >"conftest.$ac_ext" <<_ACEOF -#line 5534 "configure" +#line 5524 "configure" #include "confdefs.h" #include <$cf_header> @@ -5544,16 +5534,16 @@ int x = optind; char *y = optarg; (void)x; (void)y } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:5547: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:5537: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:5550: \$? = $ac_status" >&5 + echo "$as_me:5540: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:5553: \"$ac_try\"") >&5 + { (eval echo "$as_me:5543: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5556: \$? = $ac_status" >&5 + echo "$as_me:5546: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_getopt_header=$cf_header break @@ -5565,7 +5555,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext" done fi -echo "$as_me:5568: result: $cf_cv_getopt_header" >&5 +echo "$as_me:5558: result: $cf_cv_getopt_header" >&5 echo "${ECHO_T}$cf_cv_getopt_header" >&6 if test "$cf_cv_getopt_header" != none ; then @@ -5585,13 +5575,13 @@ fi for ac_func in getopt vsnprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:5588: checking for $ac_func" >&5 +echo "$as_me:5578: 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 5594 "configure" +#line 5584 "configure" #include "confdefs.h" #define $ac_func autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ @@ -5622,16 +5612,16 @@ main (void) } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" -if { (eval echo "$as_me:5625: \"$ac_link\"") >&5 +if { (eval echo "$as_me:5615: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:5628: \$? = $ac_status" >&5 + echo "$as_me:5618: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' - { (eval echo "$as_me:5631: \"$ac_try\"") >&5 + { (eval echo "$as_me:5621: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5634: \$? = $ac_status" >&5 + echo "$as_me:5624: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then eval "$as_ac_var=yes" else @@ -5641,7 +5631,7 @@ eval "$as_ac_var=no" fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi -echo "$as_me:5644: result: `eval echo '${'"$as_ac_var"'}'`" >&5 +echo "$as_me:5634: 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 "$as_me:5644: checking for maximum table size" >&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. @@ -5661,12 +5651,12 @@ if test "${with_max_table_size+set}" = set; then fi; if test -n "$with_max_table_size" then - echo "$as_me:5664: result: $with_max_table_size" >&5 + echo "$as_me:5654: 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:5669: error: invalid value for --with-max-table-size: $with_max_table_size" >&5 + { { echo "$as_me:5659: 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 @@ -5676,11 +5666,11 @@ cat >>confdefs.h <&5 + echo "$as_me:5669: result: default" >&5 echo "${ECHO_T}default" >&6 fi -echo "$as_me:5683: checking if backtracking extension is wanted" >&5 +echo "$as_me:5673: 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. @@ -5697,7 +5687,7 @@ else enable_btyacc=yes fi; -echo "$as_me:5700: result: $enable_btyacc" >&5 +echo "$as_me:5690: result: $enable_btyacc" >&5 echo "${ECHO_T}$enable_btyacc" >&6 if test "$enable_btyacc" = "no"; then SKELETON=yaccpar @@ -5710,7 +5700,7 @@ EOF SKELETON=btyaccpar fi -echo "$as_me:5713: checking for fgrep" >&5 +echo "$as_me:5703: checking for fgrep" >&5 echo $ECHO_N "checking for fgrep... $ECHO_C" >&6 if test "${ac_cv_path_FGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5722,7 +5712,7 @@ else 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:5725: checking for $ac_word" >&5 +echo "$as_me:5715: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_FGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5739,7 +5729,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_FGREP="$ac_dir/$ac_word" - echo "$as_me:5742: found $ac_dir/$ac_word" >&5 + echo "$as_me:5732: found $ac_dir/$ac_word" >&5 break fi done @@ -5750,10 +5740,10 @@ fi FGREP=$ac_cv_path_FGREP if test -n "$FGREP"; then - echo "$as_me:5753: result: $FGREP" >&5 + echo "$as_me:5743: result: $FGREP" >&5 echo "${ECHO_T}$FGREP" >&6 else - echo "$as_me:5756: result: no" >&5 + echo "$as_me:5746: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -5761,16 +5751,16 @@ fi done test -n "$FGREP" || FGREP=": " - test "x$ac_cv_path_FGREP" = "x:" && { { echo "$as_me:5764: error: cannot find workable fgrep" >&5 + test "x$ac_cv_path_FGREP" = "x:" && { { echo "$as_me:5754: error: cannot find workable fgrep" >&5 echo "$as_me: error: cannot find workable fgrep" >&2;} { (exit 1); exit 1; }; } fi fi -echo "$as_me:5769: result: $ac_cv_path_FGREP" >&5 +echo "$as_me:5759: result: $ac_cv_path_FGREP" >&5 echo "${ECHO_T}$ac_cv_path_FGREP" >&6 FGREP="$ac_cv_path_FGREP" -echo "$as_me:5773: checking if you want to use C11 _Noreturn feature" >&5 +echo "$as_me:5763: checking if you want to use C11 _Noreturn feature" >&5 echo $ECHO_N "checking if you want to use C11 _Noreturn feature... $ECHO_C" >&6 # Check whether --enable-stdnoreturn or --disable-stdnoreturn was given. @@ -5787,21 +5777,20 @@ else enable_stdnoreturn=no fi; -echo "$as_me:5790: result: $enable_stdnoreturn" >&5 +echo "$as_me:5780: result: $enable_stdnoreturn" >&5 echo "${ECHO_T}$enable_stdnoreturn" >&6 if test $enable_stdnoreturn = yes; then -echo "$as_me:5794: checking for C11 _Noreturn feature" >&5 +echo "$as_me:5784: checking for C11 _Noreturn feature" >&5 echo $ECHO_N "checking for C11 _Noreturn feature... $ECHO_C" >&6 if test "${cf_cv_c11_noreturn+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF -#line 5800 "configure" +#line 5790 "configure" #include "confdefs.h" -#include -#include +$ac_includes_default #include static _Noreturn void giveup(void) { exit(0); } @@ -5814,16 +5803,16 @@ if (feof(stdin)) giveup() } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:5817: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:5806: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:5820: \$? = $ac_status" >&5 + echo "$as_me:5809: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:5823: \"$ac_try\"") >&5 + { (eval echo "$as_me:5812: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5826: \$? = $ac_status" >&5 + echo "$as_me:5815: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_c11_noreturn=yes else @@ -5834,7 +5823,7 @@ fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "$as_me:5837: result: $cf_cv_c11_noreturn" >&5 +echo "$as_me:5826: result: $cf_cv_c11_noreturn" >&5 echo "${ECHO_T}$cf_cv_c11_noreturn" >&6 else cf_cv_c11_noreturn=no, @@ -5890,16 +5879,16 @@ then then test -n "$verbose" && echo " repairing CFLAGS: $CFLAGS" 1>&6 -echo "${as_me:-configure}:5893: testing repairing CFLAGS: $CFLAGS ..." 1>&5 +echo "${as_me:-configure}:5882: testing repairing CFLAGS: $CFLAGS ..." 1>&5 CFLAGS="$cf_temp_flags" test -n "$verbose" && echo " ... fixed $CFLAGS" 1>&6 -echo "${as_me:-configure}:5898: testing ... fixed $CFLAGS ..." 1>&5 +echo "${as_me:-configure}:5887: testing ... fixed $CFLAGS ..." 1>&5 test -n "$verbose" && echo " ... extra $EXTRA_CFLAGS" 1>&6 -echo "${as_me:-configure}:5902: testing ... extra $EXTRA_CFLAGS ..." 1>&5 +echo "${as_me:-configure}:5891: testing ... extra $EXTRA_CFLAGS ..." 1>&5 fi ;; @@ -5938,16 +5927,16 @@ then then test -n "$verbose" && echo " repairing CPPFLAGS: $CPPFLAGS" 1>&6 -echo "${as_me:-configure}:5941: testing repairing CPPFLAGS: $CPPFLAGS ..." 1>&5 +echo "${as_me:-configure}:5930: testing repairing CPPFLAGS: $CPPFLAGS ..." 1>&5 CPPFLAGS="$cf_temp_flags" test -n "$verbose" && echo " ... fixed $CPPFLAGS" 1>&6 -echo "${as_me:-configure}:5946: testing ... fixed $CPPFLAGS ..." 1>&5 +echo "${as_me:-configure}:5935: testing ... fixed $CPPFLAGS ..." 1>&5 test -n "$verbose" && echo " ... extra $EXTRA_CFLAGS" 1>&6 -echo "${as_me:-configure}:5950: testing ... extra $EXTRA_CFLAGS ..." 1>&5 +echo "${as_me:-configure}:5939: testing ... extra $EXTRA_CFLAGS ..." 1>&5 fi ;; @@ -5986,23 +5975,23 @@ then then test -n "$verbose" && echo " repairing LDFLAGS: $LDFLAGS" 1>&6 -echo "${as_me:-configure}:5989: testing repairing LDFLAGS: $LDFLAGS ..." 1>&5 +echo "${as_me:-configure}:5978: testing repairing LDFLAGS: $LDFLAGS ..." 1>&5 LDFLAGS="$cf_temp_flags" test -n "$verbose" && echo " ... fixed $LDFLAGS" 1>&6 -echo "${as_me:-configure}:5994: testing ... fixed $LDFLAGS ..." 1>&5 +echo "${as_me:-configure}:5983: testing ... fixed $LDFLAGS ..." 1>&5 test -n "$verbose" && echo " ... extra $EXTRA_CFLAGS" 1>&6 -echo "${as_me:-configure}:5998: testing ... extra $EXTRA_CFLAGS ..." 1>&5 +echo "${as_me:-configure}:5987: testing ... extra $EXTRA_CFLAGS ..." 1>&5 fi ;; esac fi -echo "$as_me:6005: checking if you want to turn on gcc warnings" >&5 +echo "$as_me:5994: checking if you want to turn on gcc warnings" >&5 echo $ECHO_N "checking if you want to turn on gcc warnings... $ECHO_C" >&6 # Check whether --enable-warnings or --disable-warnings was given. @@ -6019,14 +6008,14 @@ else enable_warnings=no fi; -echo "$as_me:6022: result: $enable_warnings" >&5 +echo "$as_me:6011: result: $enable_warnings" >&5 echo "${ECHO_T}$enable_warnings" >&6 if test "$enable_warnings" = "yes" then if test "x$have_x" = xyes; then echo "skipping X-const check"; fi cat > "conftest.$ac_ext" <&5 + { echo "$as_me:6034: checking for $CC warning options..." >&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall" @@ -6058,12 +6047,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:6061: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:6050: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:6064: \$? = $ac_status" >&5 + echo "$as_me:6053: \$? = $ac_status" >&5 (exit "$ac_status"); }; then - test -n "$verbose" && echo "$as_me:6066: result: ... -$cf_opt" >&5 + test -n "$verbose" && echo "$as_me:6055: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" fi @@ -6071,7 +6060,7 @@ echo "${ECHO_T}... -$cf_opt" >&6 CFLAGS="$cf_save_CFLAGS" elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown" then - { echo "$as_me:6074: checking for $CC warning options..." >&5 + { echo "$as_me:6063: checking for $CC warning options..." >&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" cf_warn_CONST="" @@ -6094,12 +6083,12 @@ echo "$as_me: checking for $CC warning options..." >&6;} Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST Wwrite-strings do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" - if { (eval echo "$as_me:6097: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:6086: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:6100: \$? = $ac_status" >&5 + echo "$as_me:6089: \$? = $ac_status" >&5 (exit "$ac_status"); }; then - test -n "$verbose" && echo "$as_me:6102: result: ... -$cf_opt" >&5 + test -n "$verbose" && echo "$as_me:6091: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 case "$cf_opt" in (Winline) @@ -6107,7 +6096,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}:6110: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 +echo "${as_me:-configure}:6099: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac @@ -6117,7 +6106,7 @@ echo "${as_me:-configure}:6110: 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}:6120: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 +echo "${as_me:-configure}:6109: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac @@ -6150,10 +6139,10 @@ cat > conftest.i <&5 + { echo "$as_me:6142: checking for $CC __attribute__ directives..." >&5 echo "$as_me: checking for $CC __attribute__ directives..." >&6;} cat > "conftest.$ac_ext" < #include "confdefs.h" #include "conftest.h" @@ -6203,12 +6192,12 @@ EOF ;; esac - if { (eval echo "$as_me:6206: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:6195: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:6209: \$? = $ac_status" >&5 + echo "$as_me:6198: \$? = $ac_status" >&5 (exit "$ac_status"); }; then - test -n "$verbose" && echo "$as_me:6211: result: ... $cf_attribute" >&5 + test -n "$verbose" && echo "$as_me:6200: result: ... $cf_attribute" >&5 echo "${ECHO_T}... $cf_attribute" >&6 cat conftest.h >>confdefs.h case "$cf_attribute" in @@ -6269,7 +6258,7 @@ fi fi -echo "$as_me:6272: checking if you want to see long compiling messages" >&5 +echo "$as_me:6261: 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. @@ -6303,10 +6292,10 @@ else ECHO_CC='' fi; -echo "$as_me:6306: result: $enableval" >&5 +echo "$as_me:6295: result: $enableval" >&5 echo "${ECHO_T}$enableval" >&6 -echo "$as_me:6309: checking if you want to use dmalloc for testing" >&5 +echo "$as_me:6298: 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. @@ -6328,7 +6317,7 @@ EOF else with_dmalloc= fi; -echo "$as_me:6331: result: ${with_dmalloc:-no}" >&5 +echo "$as_me:6320: result: ${with_dmalloc:-no}" >&5 echo "${ECHO_T}${with_dmalloc:-no}" >&6 case ".$with_cflags" in @@ -6442,23 +6431,23 @@ fi esac if test "$with_dmalloc" = yes ; then - echo "$as_me:6445: checking for dmalloc.h" >&5 + echo "$as_me:6434: 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 6451 "configure" +#line 6440 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:6455: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:6444: \"$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:6461: \$? = $ac_status" >&5 + echo "$as_me:6450: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -6477,11 +6466,11 @@ else fi rm -f conftest.err "conftest.$ac_ext" fi -echo "$as_me:6480: result: $ac_cv_header_dmalloc_h" >&5 +echo "$as_me:6469: 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:6484: checking for dmalloc_debug in -ldmalloc" >&5 +echo "$as_me:6473: 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 @@ -6489,7 +6478,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldmalloc $LIBS" cat >"conftest.$ac_ext" <<_ACEOF -#line 6492 "configure" +#line 6481 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -6498,7 +6487,7 @@ 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 dmalloc_debug (); +char dmalloc_debug (void); int main (void) { @@ -6508,16 +6497,16 @@ dmalloc_debug (); } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" -if { (eval echo "$as_me:6511: \"$ac_link\"") >&5 +if { (eval echo "$as_me:6500: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:6514: \$? = $ac_status" >&5 + echo "$as_me:6503: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' - { (eval echo "$as_me:6517: \"$ac_try\"") >&5 + { (eval echo "$as_me:6506: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:6520: \$? = $ac_status" >&5 + echo "$as_me:6509: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_dmalloc_dmalloc_debug=yes else @@ -6528,7 +6517,7 @@ fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:6531: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5 +echo "$as_me:6520: 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:6535: 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. @@ -6565,7 +6554,7 @@ EOF else with_dbmalloc= fi; -echo "$as_me:6568: result: ${with_dbmalloc:-no}" >&5 +echo "$as_me:6557: result: ${with_dbmalloc:-no}" >&5 echo "${ECHO_T}${with_dbmalloc:-no}" >&6 case ".$with_cflags" in @@ -6679,23 +6668,23 @@ fi esac if test "$with_dbmalloc" = yes ; then - echo "$as_me:6682: checking for dbmalloc.h" >&5 + echo "$as_me:6671: 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 6688 "configure" +#line 6677 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:6692: \"$ac_cpp "conftest.$ac_ext"\"") >&5 +if { (eval echo "$as_me:6681: \"$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:6698: \$? = $ac_status" >&5 + echo "$as_me:6687: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -6714,11 +6703,11 @@ else fi rm -f conftest.err "conftest.$ac_ext" fi -echo "$as_me:6717: result: $ac_cv_header_dbmalloc_h" >&5 +echo "$as_me:6706: 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:6721: checking for debug_malloc in -ldbmalloc" >&5 +echo "$as_me:6710: 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 @@ -6726,7 +6715,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldbmalloc $LIBS" cat >"conftest.$ac_ext" <<_ACEOF -#line 6729 "configure" +#line 6718 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -6735,7 +6724,7 @@ 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 debug_malloc (); +char debug_malloc (void); int main (void) { @@ -6745,16 +6734,16 @@ debug_malloc (); } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" -if { (eval echo "$as_me:6748: \"$ac_link\"") >&5 +if { (eval echo "$as_me:6737: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:6751: \$? = $ac_status" >&5 + echo "$as_me:6740: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' - { (eval echo "$as_me:6754: \"$ac_try\"") >&5 + { (eval echo "$as_me:6743: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:6757: \$? = $ac_status" >&5 + echo "$as_me:6746: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_dbmalloc_debug_malloc=yes else @@ -6765,7 +6754,7 @@ fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:6768: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5 +echo "$as_me:6757: 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:6772: 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. @@ -6802,7 +6791,7 @@ EOF else with_valgrind= fi; -echo "$as_me:6805: result: ${with_valgrind:-no}" >&5 +echo "$as_me:6794: result: ${with_valgrind:-no}" >&5 echo "${ECHO_T}${with_valgrind:-no}" >&6 case ".$with_cflags" in @@ -6915,7 +6904,7 @@ fi ;; esac -echo "$as_me:6918: checking if you want to perform memory-leak testing" >&5 +echo "$as_me:6907: 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. @@ -6926,7 +6915,7 @@ else enable_leaks=yes fi; if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi -echo "$as_me:6929: result: $with_no_leaks" >&5 +echo "$as_me:6918: result: $with_no_leaks" >&5 echo "${ECHO_T}$with_no_leaks" >&6 if test "$enable_leaks" = no ; then @@ -6941,9 +6930,282 @@ EOF fi + echo "$as_me:6933: checking for PATH separator" >&5 +echo $ECHO_N "checking for PATH separator... $ECHO_C" >&6 + case "$cf_cv_system_name" in + (os2*) PATH_SEPARATOR=';' ;; + (*) ${PATH_SEPARATOR:=':'} ;; + esac + + echo "$as_me:6940: result: $PATH_SEPARATOR" >&5 +echo "${ECHO_T}$PATH_SEPARATOR" >&6 + +echo "$as_me:6943: checking format of man-pages" >&5 +echo $ECHO_N "checking format of man-pages... $ECHO_C" >&6 + +# Check whether --with-manpage-format or --without-manpage-format was given. +if test "${with_manpage_format+set}" = set; then + withval="$with_manpage_format" + MANPAGE_FORMAT=$withval +else + MANPAGE_FORMAT=unknown +fi; + +test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown +MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'` + +cf_unknown= + +case "$MANPAGE_FORMAT" in +(unknown) + if test -z "$MANPATH" ; then + MANPATH="/usr/man:/usr/share/man" + fi + + # look for the 'date' man-page (it is most likely to be installed!) + MANPAGE_FORMAT= + cf_preform="no" + cf_catonly="yes" + cf_example="date" + + IFS="${IFS:- }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for cf_dir in $MANPATH; do + test -z "$cf_dir" && cf_dir=/usr/man + for cf_name in $cf_dir/man*/$cf_example.[01]* $cf_dir/cat*/$cf_example.[01]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example + do + cf_test=`echo "$cf_name" | sed -e 's/*//'` + if test "x$cf_test" = "x$cf_name" ; then + + case "$cf_name" in + (*.bz2) MANPAGE_FORMAT="$MANPAGE_FORMAT bzip2";; + (*.xz) MANPAGE_FORMAT="$MANPAGE_FORMAT xz";; + (*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";; + (*.Z) MANPAGE_FORMAT="$MANPAGE_FORMAT compress";; + (*.0) MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";; + (*) MANPAGE_FORMAT="$MANPAGE_FORMAT normal";; + esac + + case "$cf_name" in + ($cf_dir/man*) + cf_catonly=no + ;; + ($cf_dir/cat*) + cf_preform=yes + ;; + esac + break + fi + + # if we found a match in either man* or cat*, stop looking + if test -n "$MANPAGE_FORMAT" ; then + cf_found=no + test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted" + test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly" + case "$cf_name" in + ($cf_dir/cat*) + cf_found=yes + ;; + esac + test "$cf_found" = yes && break + fi + done + # only check the first directory in $MANPATH where we find manpages + if test -n "$MANPAGE_FORMAT" ; then + break + fi + done + # if we did not find the example, just assume it is normal + test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal + IFS="$ac_save_ifs" + ;; +(*) + for cf_option in $MANPAGE_FORMAT; do + case "$cf_option" in + (xz|bzip2|gzip|compress|BSDI|normal|formatted|catonly) + ;; + (*) + cf_unknown="$cf_unknown $cf_option" + ;; + esac + done + ;; +esac + +echo "$as_me:7034: result: $MANPAGE_FORMAT" >&5 +echo "${ECHO_T}$MANPAGE_FORMAT" >&6 +if test -n "$cf_unknown" ; then + { echo "$as_me:7037: WARNING: Unexpected manpage-format $cf_unknown" >&5 +echo "$as_me: WARNING: Unexpected manpage-format $cf_unknown" >&2;} +fi + +cf_manpage_format=no +cf_manpage_inboth=no +cf_manpage_so_strip= +cf_manpage_compress= + +for cf_item in $MANPAGE_FORMAT +do +case "$cf_item" in +(catonly) + cf_manpage_format=yes + cf_manpage_inboth=no + ;; +(formatted) + cf_manpage_format=yes + cf_manpage_inboth=yes + ;; +(compress) + cf_manpage_so_strip="Z" + cf_manpage_compress=compress + ;; +(gzip) + cf_manpage_so_strip="gz" + cf_manpage_compress=gzip + ;; +(bzip2) + cf_manpage_so_strip="bz2" + cf_manpage_compress=bzip2 + ;; +(xz) + cf_manpage_so_strip="xz" + cf_manpage_compress=xz + ;; +esac +done + +echo "$as_me:7076: checking whether ln -s works" >&5 +echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + echo "$as_me:7080: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:7083: result: no, using $LN_S" >&5 +echo "${ECHO_T}no, using $LN_S" >&6 +fi + +cf_install_man=install-man +ac_config_files="$ac_config_files $cf_install_man" +cf_install_man=$cf_install_man.in +echo $as_me: creating $cf_install_man +cat >$cf_install_man <<"CF_EOF" +#!/bin/sh +# generated by CF_INSTALL_MAN + +LANG=C; export LANG +LC_ALL=C; export LC_ALL +LC_CTYPE=C; export LC_CTYPE +LANGUAGE=C; export LANGUAGE + +INSTALL="@INSTALL@" +INSTALL_DATA="@INSTALL_DATA@" + +usage() { + cat <&2 + exit 1 +} + +test $# != 0 || usage +OPTS= +case "x$1" in +(x-l) + OPTS="link" + shift + ;; +(x-*) + usage + ;; +esac + +source= +if test $# = 2 ; then + source=$1; shift + target=$1 +elif test $# = 1 ; then + test -n "$OPTS" && usage + target=$1 +else + usage +fi + +origin_name=`echo "$source" |sed -e 's%^.*/%%' -e 's%\..*%%'` +actual_name=`echo "$origin_name" |sed '@program_transform_name@'` +leading_cap=`echo "$actual_name" | sed -e 's%^\(.\).*$%\1%' | tr a-z A-Z``echo "$actual_name" | sed -e 's%^.%%'` +capitalized=`echo "$actual_name" | tr a-z A-Z` + +cf_tmpdir=`mktemp -d` +trap 'rm -rf "$cf_tmpdir"; exit 1' 1 2 3 15 +trap 'rm -rf "$cf_tmpdir"; exit 0' 0 + +if test -n "$source" ; then + suffix= + test -n "@cf_manpage_so_strip" && suffix=".@cf_manpage_so_strip@" + if test "x$OPTS" = xlink ; then + source_dir=`echo "$source" | sed -e "s%/[^/]*$%%"` + target_dir=`echo "$target" | sed -e "s%/[^/]*$%%"` + sourcelink="${source}${suffix}" + targetfile="${target}${suffix}" + targetlink="${target_dir}/${sourcelink}" + if test ! -d "$target_dir" ; then + failed "target directory does not exist: $target_dir" + elif test ! -f "$targetfile" ; then + failed "target file does not exist: $targetfile" + elif test "$source" != "$source_dir" ; then + failed "unexpected directory for source-link: $source_dir" + fi + test -f "$targetlink" && failed "already exists $targetlink" + ( cd "$target_dir" && @LN_S@ "`echo "$targetfile" | sed -e 's%^.*/%%'`" "$sourcelink" ) + test -f "$targetlink" || failed "cannot create $targetlink" + target="$targetlink" + else + echo "** installing $source to $target" + interim="$cf_tmpdir"/"`basename $source`" + if test "x$origin_name" != "x$actual_name" ; then + sed \ + -e "/^.ds N/s%N.*%N $leading_cap%" \ + -e "/^.ds n/s%n.*%n $actual_name%" \ + -e "/^\.TH/s%[ ][ ]*[^ ][^ ]*% $capitalized%" \ + -e "/^\.SH[ ][ ]*NAME/,/[ ]\\\\-[ ]/s%^\\\\\\*[Nn]%$actual_name%" \ + "$source" >"$interim" || exit 1 + diff -c "$source" "$interim" + else + cp "$source" "$interim" || exit 1 + fi + if test -n "@cf_manpage_compress@" ; then + @cf_manpage_compress@ "$interim" + source="${interim}${suffix}" + fi + if test -d "$target" ; then + target="$target"/"$source" + else + test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@" + fi + $INSTALL_DATA "$source" "$target" || exit 1 + fi + echo "...installed $target" +else + echo "** removing $target" + test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@" + if test -f "$target" ; then + rm -f "$target" + echo "...removed $target" + else + echo "...not found" + fi +fi +exit 0 +CF_EOF + # Extract the first word of "groff", so it can be a program name with args. set dummy groff; ac_word=$2 -echo "$as_me:6946: checking for $ac_word" >&5 +echo "$as_me:7208: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_GROFF_PATH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6960,7 +7222,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_GROFF_PATH="$ac_dir/$ac_word" - echo "$as_me:6963: found $ac_dir/$ac_word" >&5 + echo "$as_me:7225: found $ac_dir/$ac_word" >&5 break fi done @@ -6972,10 +7234,10 @@ fi GROFF_PATH=$ac_cv_path_GROFF_PATH if test -n "$GROFF_PATH"; then - echo "$as_me:6975: result: $GROFF_PATH" >&5 + echo "$as_me:7237: result: $GROFF_PATH" >&5 echo "${ECHO_T}$GROFF_PATH" >&6 else - echo "$as_me:6978: result: no" >&5 + echo "$as_me:7240: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -6983,7 +7245,7 @@ for ac_prog in nroff mandoc 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:6986: checking for $ac_word" >&5 +echo "$as_me:7248: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_NROFF_PATH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7000,7 +7262,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_NROFF_PATH="$ac_dir/$ac_word" - echo "$as_me:7003: found $ac_dir/$ac_word" >&5 + echo "$as_me:7265: found $ac_dir/$ac_word" >&5 break fi done @@ -7011,10 +7273,10 @@ fi NROFF_PATH=$ac_cv_path_NROFF_PATH if test -n "$NROFF_PATH"; then - echo "$as_me:7014: result: $NROFF_PATH" >&5 + echo "$as_me:7276: result: $NROFF_PATH" >&5 echo "${ECHO_T}$NROFF_PATH" >&6 else - echo "$as_me:7017: result: no" >&5 + echo "$as_me:7279: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -7024,7 +7286,7 @@ test -n "$NROFF_PATH" || NROFF_PATH="no" # Extract the first word of "tbl", so it can be a program name with args. set dummy tbl; ac_word=$2 -echo "$as_me:7027: checking for $ac_word" >&5 +echo "$as_me:7289: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_TBL_PATH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7041,7 +7303,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_TBL_PATH="$ac_dir/$ac_word" - echo "$as_me:7044: found $ac_dir/$ac_word" >&5 + echo "$as_me:7306: found $ac_dir/$ac_word" >&5 break fi done @@ -7053,10 +7315,10 @@ fi TBL_PATH=$ac_cv_path_TBL_PATH if test -n "$TBL_PATH"; then - echo "$as_me:7056: result: $TBL_PATH" >&5 + echo "$as_me:7318: result: $TBL_PATH" >&5 echo "${ECHO_T}$TBL_PATH" >&6 else - echo "$as_me:7059: result: no" >&5 + echo "$as_me:7321: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -7076,7 +7338,7 @@ case "x${with_man2html}" in (x|xyes) # Extract the first word of "man2html", so it can be a program name with args. set dummy man2html; ac_word=$2 -echo "$as_me:7079: checking for $ac_word" >&5 +echo "$as_me:7341: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_cf_man2html+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7093,7 +7355,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_cf_man2html="$ac_dir/$ac_word" - echo "$as_me:7096: found $ac_dir/$ac_word" >&5 + echo "$as_me:7358: found $ac_dir/$ac_word" >&5 break fi done @@ -7105,16 +7367,16 @@ fi cf_man2html=$ac_cv_path_cf_man2html if test -n "$cf_man2html"; then - echo "$as_me:7108: result: $cf_man2html" >&5 + echo "$as_me:7370: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 else - echo "$as_me:7111: result: no" >&5 + echo "$as_me:7373: result: no" >&5 echo "${ECHO_T}no" >&6 fi case "x$cf_man2html" in (x/*) - echo "$as_me:7117: checking for the modified Earl Hood script" >&5 + echo "$as_me:7379: checking for the modified Earl Hood script" >&5 echo $ECHO_N "checking for the modified Earl Hood script... $ECHO_C" >&6 if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null ) then @@ -7123,7 +7385,7 @@ echo $ECHO_N "checking for the modified Earl Hood script... $ECHO_C" >&6 cf_man2html=no cf_man2html_ok=no fi - echo "$as_me:7126: result: $cf_man2html_ok" >&5 + echo "$as_me:7388: result: $cf_man2html_ok" >&5 echo "${ECHO_T}$cf_man2html_ok" >&6 ;; (*) @@ -7132,7 +7394,7 @@ echo "${ECHO_T}$cf_man2html_ok" >&6 esac esac -echo "$as_me:7135: checking for program to convert manpage to html" >&5 +echo "$as_me:7397: checking for program to convert manpage to html" >&5 echo $ECHO_N "checking for program to convert manpage to html... $ECHO_C" >&6 # Check whether --with-man2html or --without-man2html was given. @@ -7147,11 +7409,11 @@ cf_with_groff=no case $cf_man2html in (yes) - echo "$as_me:7150: result: man2html" >&5 + echo "$as_me:7412: result: man2html" >&5 echo "${ECHO_T}man2html" >&6 # Extract the first word of "man2html", so it can be a program name with args. set dummy man2html; ac_word=$2 -echo "$as_me:7154: checking for $ac_word" >&5 +echo "$as_me:7416: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_cf_man2html+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7168,7 +7430,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_cf_man2html="$ac_dir/$ac_word" - echo "$as_me:7171: found $ac_dir/$ac_word" >&5 + echo "$as_me:7433: found $ac_dir/$ac_word" >&5 break fi done @@ -7180,10 +7442,10 @@ fi cf_man2html=$ac_cv_path_cf_man2html if test -n "$cf_man2html"; then - echo "$as_me:7183: result: $cf_man2html" >&5 + echo "$as_me:7445: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 else - echo "$as_me:7186: result: no" >&5 + echo "$as_me:7448: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -7191,11 +7453,11 @@ fi (no|groff|*/groff*) cf_with_groff=yes cf_man2html=$GROFF_PATH - echo "$as_me:7194: result: $cf_man2html" >&5 + echo "$as_me:7456: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 ;; (*) - echo "$as_me:7198: result: $cf_man2html" >&5 + echo "$as_me:7460: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 ;; esac @@ -7236,12 +7498,12 @@ else # disable hyphenation if this is groff if test "x$GROFF_PATH" != xno then - echo "$as_me:7239: checking if nroff is really groff" >&5 + echo "$as_me:7501: checking if nroff is really groff" >&5 echo $ECHO_N "checking if nroff is really groff... $ECHO_C" >&6 cf_check_groff="`$NROFF_PATH --version 2>/dev/null | grep groff`" test -n "$cf_check_groff" && cf_check_groff=yes test -n "$cf_check_groff" || cf_check_groff=no - echo "$as_me:7244: result: $cf_check_groff" >&5 + echo "$as_me:7506: result: $cf_check_groff" >&5 echo "${ECHO_T}$cf_check_groff" >&6 test "x$cf_check_groff" = xyes && NROFF_OPTS="-rHY=0" fi @@ -7272,14 +7534,14 @@ case ".$cf_man2html" in cf_man2html=`echo "$cf_man2html" | sed -e s%NONE%$cf_path_syntax%` ;; (*) - { { echo "$as_me:7275: error: expected a pathname, not \"$cf_man2html\"" >&5 + { { echo "$as_me:7537: error: expected a pathname, not \"$cf_man2html\"" >&5 echo "$as_me: error: expected a pathname, not \"$cf_man2html\"" >&2;} { (exit 1); exit 1; }; } ;; esac MAN2HTML_PATH="$cf_man2html" - echo "$as_me:7282: checking for $cf_man2html top/bottom margins" >&5 + echo "$as_me:7544: checking for $cf_man2html top/bottom margins" >&5 echo $ECHO_N "checking for $cf_man2html top/bottom margins... $ECHO_C" >&6 # for this example, expect 3 lines of content, the remainder is head/foot @@ -7297,10 +7559,10 @@ CF_EOF cf_man2html_bot=`expr "$cf_man2html_bot" - 2 - "$cf_man2html_top"` cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot" - echo "$as_me:7300: result: $cf_man2html_top_bot" >&5 + echo "$as_me:7562: result: $cf_man2html_top_bot" >&5 echo "${ECHO_T}$cf_man2html_top_bot" >&6 - echo "$as_me:7303: checking for pagesize to use" >&5 + echo "$as_me:7565: checking for pagesize to use" >&5 echo $ECHO_N "checking for pagesize to use... $ECHO_C" >&6 for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do @@ -7325,7 +7587,7 @@ CF_EOF test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999 rm -rf conftest* - echo "$as_me:7328: result: $cf_man2html_page" >&5 + echo "$as_me:7590: result: $cf_man2html_page" >&5 echo "${ECHO_T}$cf_man2html_page" >&6 cat >>$MAN2HTML_TEMP <&5 +echo "$as_me:7609: checking for mode_t" >&5 echo $ECHO_N "checking for mode_t... $ECHO_C" >&6 if test "${ac_cv_type_mode_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF -#line 7353 "configure" +#line 7615 "configure" #include "confdefs.h" $ac_includes_default int @@ -7365,16 +7627,16 @@ if (sizeof (mode_t)) } _ACEOF rm -f "conftest.$ac_objext" -if { (eval echo "$as_me:7368: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:7630: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:7371: \$? = $ac_status" >&5 + echo "$as_me:7633: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' - { (eval echo "$as_me:7374: \"$ac_try\"") >&5 + { (eval echo "$as_me:7636: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:7377: \$? = $ac_status" >&5 + echo "$as_me:7639: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_type_mode_t=yes else @@ -7384,7 +7646,7 @@ ac_cv_type_mode_t=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi -echo "$as_me:7387: result: $ac_cv_type_mode_t" >&5 +echo "$as_me:7649: result: $ac_cv_type_mode_t" >&5 echo "${ECHO_T}$ac_cv_type_mode_t" >&6 if test "$ac_cv_type_mode_t" = yes; then : @@ -7408,7 +7670,7 @@ cat >confcache <<\_ACEOF # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # -# `ac_cv_env_foo' variables (set or unset) will be overriden when +# `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. @@ -7477,7 +7739,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:7480: creating $CONFIG_STATUS" >&5 +{ echo "$as_me:7742: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >"$CONFIG_STATUS" <<_ACEOF #! $SHELL @@ -7610,7 +7872,7 @@ EOF cat >>"$CONFIG_STATUS" <>"$CONFIG_STATUS" <<\EOF echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header - { { echo "$as_me:7658: error: ambiguous option: $1 + { { echo "$as_me:7920: 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;} @@ -7674,7 +7936,7 @@ Try \`$0 --help' for more information." >&2;} ac_need_defaults=false;; # This is an error. - -*) { { echo "$as_me:7677: error: unrecognized option: $1 + -*) { { echo "$as_me:7939: 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;} @@ -7693,7 +7955,7 @@ cat >&5 << _ACEOF ## Running config.status. ## ## ----------------------- ## -This file was extended by $as_me 2.52.20230114, executed with +This file was extended by $as_me 2.52.20231210, executed with CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS @@ -7711,7 +7973,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:7714: error: invalid argument: $ac_config_target" >&5 + *) { { echo "$as_me:7976: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac @@ -7841,6 +8103,11 @@ s,@ECHO_LD@,$ECHO_LD,;t t s,@RULE_CC@,$RULE_CC,;t t s,@SHOW_CC@,$SHOW_CC,;t t s,@ECHO_CC@,$ECHO_CC,;t t +s,@cf_manpage_format@,$cf_manpage_format,;t t +s,@cf_manpage_inboth@,$cf_manpage_inboth,;t t +s,@cf_manpage_so_strip@,$cf_manpage_so_strip,;t t +s,@cf_manpage_compress@,$cf_manpage_compress,;t t +s,@LN_S@,$LN_S,;t t s,@GROFF_PATH@,$GROFF_PATH,;t t s,@NROFF_PATH@,$NROFF_PATH,;t t s,@TBL_PATH@,$TBL_PATH,;t t @@ -7982,7 +8249,7 @@ done; } esac if test x"$ac_file" != x-; then - { echo "$as_me:7985: creating $ac_file" >&5 + { echo "$as_me:8252: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi @@ -8000,7 +8267,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:8003: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:8270: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo "$f";; @@ -8013,7 +8280,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo "$srcdir/$f" else # /dev/null tree - { { echo "$as_me:8016: error: cannot find input file: $f" >&5 + { { echo "$as_me:8283: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -8029,7 +8296,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:8032: WARNING: datarootdir was used implicitly but not set: + { echo "$as_me:8299: 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;} @@ -8038,7 +8305,7 @@ $ac_seen" >&2;} fi ac_seen=`grep '${datarootdir}' "$ac_item"` if test -n "$ac_seen"; then - { echo "$as_me:8041: WARNING: datarootdir was used explicitly but not set: + { echo "$as_me:8308: 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;} @@ -8066,11 +8333,11 @@ s,@INSTALL@,$ac_INSTALL,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >"$tmp"/out rm -f "$tmp"/stdin EOF -: "${FGREP:=grep -F}" -: "${EGREP:=grep -E}" +test -n "${FGREP}" || FGREP="grep -F" +test -n "${EGREP}" || EGREP="grep -E" cat >>"$CONFIG_STATUS" <>"$CONFIG_STATUS" <<\EOF if test x"$ac_file" != x-; then @@ -8083,7 +8350,7 @@ cat >>"$CONFIG_STATUS" <<\EOF 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:8086: WARNING: Variable $ac_name is used but was not set: + { echo "$as_me:8353: 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;} @@ -8094,7 +8361,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:8097: WARNING: Some variables may not be substituted: + { echo "$as_me:8364: WARNING: Some variables may not be substituted: $ac_seen" >&5 echo "$as_me: WARNING: Some variables may not be substituted: $ac_seen" >&2;} @@ -8143,7 +8410,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:8146: creating $ac_file" >&5 + test x"$ac_file" != x- && { echo "$as_me:8413: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the @@ -8154,7 +8421,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:8157: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:8424: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -8167,7 +8434,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo "$srcdir/$f" else # /dev/null tree - { { echo "$as_me:8170: error: cannot find input file: $f" >&5 + { { echo "$as_me:8437: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -8220,7 +8487,8 @@ EOF # Break up conftest.defines because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #define templates only if necessary.' >>"$CONFIG_STATUS" -echo ' if ${EGREP-grep -E} "^[ ]*#[ ]*define" "$tmp"/in >/dev/null; then' >>"$CONFIG_STATUS" +echo ' test -n "${EGREP}" || EGREP="grep -E"' >>"$CONFIG_STATUS" +echo ' if ${EGREP} "^[ ]*#[ ]*define" "$tmp"/in >/dev/null; then' >>"$CONFIG_STATUS" echo ' # If there are no defines, we may have an empty if/fi' >>"$CONFIG_STATUS" echo ' :' >>"$CONFIG_STATUS" rm -f conftest.tail @@ -8285,7 +8553,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:8288: $ac_file is unchanged" >&5 + { echo "$as_me:8556: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ diff --git a/configure.in b/configure.in index 165f059ef3f..4b59b2dd00e 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl Process this file with 'autoconf' to produce a 'configure' script -dnl $Id: configure.in,v 1.28 2023/02/02 00:14:51 tom Exp $ +dnl $Id: configure.in,v 1.29 2023/05/19 07:58:43 tom Exp $ AC_PREREQ(2.52.20200802) -AC_REVISION($Revision: 1.28 $) +AC_REVISION($Revision: 1.29 $) AC_INIT(main.c) AC_CONFIG_HEADER(config.h:config_h.in) @@ -60,6 +60,8 @@ AC_SUBST(SKELETON) CF_ENABLE_WARNINGS(Wwrite-strings,yes) CF_DISABLE_ECHO CF_DISABLE_LEAKS +CF_MANPAGE_FORMAT +CF_INSTALL_MAN CF_WITH_MAN2HTML AC_TYPE_MODE_T diff --git a/defs.h b/defs.h index 62855e41ed8..5e0fd018c17 100644 --- a/defs.h +++ b/defs.h @@ -1,4 +1,4 @@ -/* $Id: defs.h,v 1.71 2022/11/06 21:44:54 tom Exp $ */ +/* $Id: defs.h,v 1.74 2023/05/18 21:28:05 tom Exp $ */ #ifdef HAVE_CONFIG_H #include @@ -122,6 +122,7 @@ typedef enum ,NONPOSIX_DEBUG /* other bison "extensions", some useful */ + ,HACK_DEFINE ,ERROR_VERBOSE ,EXPECT ,EXPECT_RR @@ -187,7 +188,7 @@ SYM_CASES; #define DO_FREE(x) if (x) { FREE(x); x = 0; } -#define NO_SPACE(p) if (p == 0) no_space(); assert(p != 0) +#define NO_SPACE(p) do { if (p == 0) on_error(); assert(p != 0); } while (0) /* messages */ #define PLURAL(n) ((n) > 1 ? "s" : "") @@ -470,41 +471,45 @@ struct ainfo char *a_cptr; }; -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 GCC_NORETURN void at_error(int a_lineno, char *a_line, char *a_cptr); +extern void arg_number_disagree_warning(int a_lineno, const char *a_name); +extern void arg_type_disagree_warning(int a_lineno, int i, const char *a_name); +extern GCC_NORETURN void at_error(int a_lineno, const char *a_line, const char *a_cptr); extern void at_warning(int a_lineno, int i); extern GCC_NORETURN void bad_formals(void); -extern void default_action_warning(char *s); +extern void default_action_warning(const char *s); extern void destructor_redeclared_warning(const struct ainfo *); -extern GCC_NORETURN void dollar_error(int a_lineno, char *a_line, char *a_cptr); +extern void dislocations_warning(void); +extern GCC_NORETURN void dollar_error(int a_lineno, const char *a_line, const char *a_cptr); extern void dollar_warning(int a_lineno, int i); extern GCC_NORETURN void fatal(const char *msg); -extern GCC_NORETURN void illegal_character(char *c_cptr); -extern GCC_NORETURN void illegal_tag(int t_lineno, char *t_line, char *t_cptr); +extern GCC_NORETURN void illegal_character(const char *c_cptr); +extern GCC_NORETURN void illegal_tag(int t_lineno, const char *t_line, const char *t_cptr); extern GCC_NORETURN void missing_brace(void); extern GCC_NORETURN void no_grammar(void); -extern GCC_NORETURN void no_space(void); +extern GCC_NORETURN void on_error(void); extern GCC_NORETURN void open_error(const char *filename); -extern GCC_NORETURN void over_unionized(char *u_cptr); +extern GCC_NORETURN void over_unionized(const char *u_cptr); extern void prec_redeclared(void); -extern void reprec_warning(char *s); +extern void reprec_warning(const 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 GCC_NORETURN void syntax_error(int st_lineno, char *st_line, char *st_cptr); +extern void retyped_warning(const char *s); +extern void revalued_warning(const char *s); +extern void start_requires_args(const char *a_name); +extern GCC_NORETURN void syntax_error(int st_lineno, const char *st_line, const char *st_cptr); extern GCC_NORETURN void terminal_lhs(int s_lineno); -extern GCC_NORETURN void terminal_start(char *s); -extern GCC_NORETURN void tokenized_start(char *s); -extern GCC_NORETURN void undefined_goal(char *s); -extern void undefined_symbol_warning(char *s); +extern GCC_NORETURN void terminal_start(const char *s); +extern GCC_NORETURN void tokenized_start(const char *s); +extern GCC_NORETURN void undefined_goal(const char *s); +extern void undefined_symbol_warning(const char *s); extern GCC_NORETURN void unexpected_EOF(void); -extern void unknown_arg_warning(int d_lineno, const char *dlr_opt, - const char *d_arg, const char *d_line, +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 GCC_NORETURN void unknown_rhs(int i); extern void unsupported_flag_warning(const char *flag, const char *details); +extern GCC_NORETURN void unexpected_value(const struct ainfo *); extern GCC_NORETURN void unterminated_action(const struct ainfo *); extern GCC_NORETURN void unterminated_comment(const struct ainfo *); extern GCC_NORETURN void unterminated_string(const struct ainfo *); @@ -512,11 +517,11 @@ extern GCC_NORETURN void unterminated_text(const struct ainfo *); extern GCC_NORETURN void unterminated_union(const struct ainfo *); extern void untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name); extern GCC_NORETURN void untyped_lhs(void); -extern GCC_NORETURN void untyped_rhs(int i, char *s); -extern GCC_NORETURN void used_reserved(char *s); +extern GCC_NORETURN void untyped_rhs(int i, const char *s); +extern GCC_NORETURN void used_reserved(const char *s); extern GCC_NORETURN void unterminated_arglist(const struct ainfo *); 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); +extern void wrong_type_for_arg_warning(int i, const char *a_name); /* graph.c */ extern void graph(void); diff --git a/error.c b/error.c index 07dc89417cb..ceb45ca9b92 100644 --- a/error.c +++ b/error.c @@ -1,4 +1,4 @@ -/* $Id: error.c,v 1.14 2016/12/02 18:35:55 tom Exp $ */ +/* $Id: error.c,v 1.17 2023/05/18 21:38:35 tom Exp $ */ /* routines for printing error messages */ @@ -12,10 +12,13 @@ fatal(const char *msg) } void -no_space(void) +on_error(void) { - fprintf(stderr, "%s: f - out of space\n", myname); - done(2); + const char *msg; + if (errno && (msg = strerror(errno)) != NULL) + fatal(msg); + else + fatal("unknown error"); } void @@ -68,7 +71,7 @@ print_pos(const char *st_line, const char *st_cptr) } void -syntax_error(int st_lineno, char *st_line, char *st_cptr) +syntax_error(int st_lineno, const char *st_line, const char *st_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n", myname, st_lineno, input_file_name); @@ -76,6 +79,15 @@ syntax_error(int st_lineno, char *st_line, char *st_cptr) done(1); } +void +unexpected_value(const struct ainfo *a) +{ + fprintf(stderr, "%s: e - line %d of \"%s\", unexpected value\n", + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); + done(1); +} + void unterminated_comment(const struct ainfo *a) { @@ -113,7 +125,7 @@ declaration\n", myname, a->a_lineno, input_file_name); } void -over_unionized(char *u_cptr) +over_unionized(const char *u_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \ declarations\n", myname, lineno, input_file_name); @@ -122,7 +134,7 @@ declarations\n", myname, lineno, input_file_name); } void -illegal_tag(int t_lineno, char *t_line, char *t_cptr) +illegal_tag(int t_lineno, const char *t_line, const char *t_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n", myname, t_lineno, input_file_name); @@ -131,7 +143,7 @@ illegal_tag(int t_lineno, char *t_line, char *t_cptr) } void -illegal_character(char *c_cptr) +illegal_character(const char *c_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n", myname, lineno, input_file_name); @@ -140,7 +152,7 @@ illegal_character(char *c_cptr) } void -used_reserved(char *s) +used_reserved(const char *s) { fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \ @@ -149,7 +161,7 @@ used_reserved(char *s) } void -tokenized_start(char *s) +tokenized_start(const char *s) { fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \ @@ -158,14 +170,14 @@ declared to be a token\n", myname, lineno, input_file_name, s); } void -retyped_warning(char *s) +retyped_warning(const char *s) { fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \ redeclared\n", myname, lineno, input_file_name, s); } void -reprec_warning(char *s) +reprec_warning(const char *s) { fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \ @@ -173,14 +185,14 @@ redeclared\n", myname, lineno, input_file_name, s); } void -revalued_warning(char *s) +revalued_warning(const char *s) { fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \ redeclared\n", myname, lineno, input_file_name, s); } void -terminal_start(char *s) +terminal_start(const char *s) { fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \ token\n", myname, lineno, input_file_name, s); @@ -234,7 +246,7 @@ end of the current rule\n", myname, a_lineno, input_file_name, i); } void -dollar_error(int a_lineno, char *a_line, char *a_cptr) +dollar_error(int a_lineno, const char *a_line, const char *a_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n", myname, a_lineno, input_file_name); @@ -242,6 +254,13 @@ dollar_error(int a_lineno, char *a_line, char *a_cptr) done(1); } +void +dislocations_warning(void) +{ + fprintf(stderr, "%s: e - line %d of \"%s\", expected %%locations\n", + myname, lineno, input_file_name); +} + void untyped_lhs(void) { @@ -251,7 +270,7 @@ untyped_lhs(void) } void -untyped_rhs(int i, char *s) +untyped_rhs(int i, const char *s) { fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n", myname, lineno, input_file_name, i, s); @@ -267,7 +286,7 @@ unknown_rhs(int i) } void -default_action_warning(char *s) +default_action_warning(const char *s) { fprintf(stderr, "%s: w - line %d of \"%s\", the default action for %s assigns an \ @@ -276,14 +295,14 @@ undefined value to $$\n", } void -undefined_goal(char *s) +undefined_goal(const char *s) { fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s); done(1); } void -undefined_symbol_warning(char *s) +undefined_symbol_warning(const char *s) { fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s); } @@ -306,7 +325,7 @@ 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) +at_error(int a_lineno, const char *a_line, const char *a_cptr) { fprintf(stderr, "%s: e - line %d of \"%s\", illegal @$ or @N reference\n", @@ -326,7 +345,7 @@ unterminated_arglist(const struct ainfo *a) } void -arg_number_disagree_warning(int a_lineno, char *a_name) +arg_number_disagree_warning(int a_lineno, const char *a_name) { fprintf(stderr, "%s: w - line %d of \"%s\", number of arguments of %s " "doesn't agree with previous declaration\n", @@ -343,7 +362,7 @@ bad_formals(void) } void -arg_type_disagree_warning(int a_lineno, int i, char *a_name) +arg_type_disagree_warning(int a_lineno, int i, const char *a_name) { fprintf(stderr, "%s: w - line %d of \"%s\", type of argument %d " "to %s doesn't agree with previous declaration\n", @@ -351,8 +370,10 @@ arg_type_disagree_warning(int a_lineno, int i, char *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) +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); @@ -376,7 +397,7 @@ wrong_number_args_warning(const char *which, const char *a_name) } void -wrong_type_for_arg_warning(int i, char *a_name) +wrong_type_for_arg_warning(int i, const char *a_name) { fprintf(stderr, "%s: w - line %d of \"%s\", wrong type for default argument %d to %s\n", @@ -385,7 +406,7 @@ wrong_type_for_arg_warning(int i, char *a_name) } void -start_requires_args(char *a_name) +start_requires_args(const char *a_name) { fprintf(stderr, "%s: w - line %d of \"%s\", start symbol %s requires arguments\n", diff --git a/main.c b/main.c index 89aeadfa914..dda0da23171 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.73 2021/08/08 20:39:34 tom Exp $ */ +/* $Id: main.c,v 1.74 2023/05/11 07:51:36 tom Exp $ */ #include #if !defined(_WIN32) || defined(__MINGW32__) @@ -563,8 +563,8 @@ static char * alloc_file_name(size_t len, const char *suffix) { char *result = TMALLOC(char, len + strlen(suffix) + 1); - if (result == 0) - no_space(); + if (result == NULL) + on_error(); strcpy(result, file_prefix); strcpy(result + len, suffix); return result; diff --git a/makefile.in b/makefile.in index 62d4eb78d66..7092b879f99 100644 --- a/makefile.in +++ b/makefile.in @@ -1,4 +1,4 @@ -# $Id: makefile.in,v 1.25 2022/11/06 21:03:11 tom Exp $ +# $Id: makefile.in,v 1.26 2023/05/19 23:16:31 tom Exp $ # # UNIX template-makefile for Berkeley Yacc @@ -99,7 +99,7 @@ all : $(THIS)$x install: all installdirs $(INSTALL_PROGRAM) $(THIS)$x $(bindir)/$(actual_bin) - - $(INSTALL_DATA) $(srcdir)/$(THIS).1 $(mandir)/$(actual_man) + @ $(SHELL) ./install-man $(srcdir)/$(THIS).1 $(mandir)/$(actual_man) installdirs: mkdir -p $(bindir) @@ -107,7 +107,7 @@ installdirs: uninstall: - rm -f $(bindir)/$(actual_bin) - - rm -f $(mandir)/$(actual_man) + @ $(SHELL) ./install-man $(mandir)/$(actual_man) ################################################################################ .SUFFIXES : .c $o .i .skel @@ -135,7 +135,7 @@ clean :: mostlyclean - rm -f $(THIS)$x distclean :: clean - - rm -f config.log config.cache config.status config.h makefile man2html.tmp + - rm -f config.log config.cache config.status config.h makefile man2html.tmp install-man* - rm -f $(testdir)/yacc/test-* $(testdir)/btyacc/test-* realclean :: distclean diff --git a/mstring.c b/mstring.c index 1110a7b89f3..c7b941a5f20 100644 --- a/mstring.c +++ b/mstring.c @@ -1,4 +1,4 @@ -/* $Id: mstring.c,v 1.9 2019/11/19 23:54:53 tom Exp $ */ +/* $Id: mstring.c,v 1.10 2023/02/26 10:15:01 tom Exp $ */ #include #include @@ -40,7 +40,7 @@ msprintf(struct mstring *s, const char *fmt, ...) do { va_start(args, fmt); - len = (size_t) vsnprintf(buf_ptr, buf_len, fmt, args); + len = (size_t)vsnprintf(buf_ptr, buf_len, fmt, args); va_end(args); if ((changed = (len > buf_len)) != 0) { @@ -57,17 +57,17 @@ msprintf(struct mstring *s, const char *fmt, ...) while (changed); #else va_start(args, fmt); - len = (size_t) vsprintf(buf_ptr, fmt, args); + 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)) + 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 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; @@ -97,7 +97,7 @@ mputchar(struct mstring *s, int ch) return ch; if (s->ptr == s->end) { - size_t len = (size_t) (s->end - s->base); + size_t len = (size_t)(s->end - s->base); if ((s->base = realloc(s->base, len + len + TAIL))) { s->ptr = s->base + len; diff --git a/output.c b/output.c index cd2f5aa9c11..fa9689bb036 100644 --- a/output.c +++ b/output.c @@ -1,4 +1,4 @@ -/* $Id: output.c,v 1.100 2022/01/09 18:03:56 tom Exp $ */ +/* $Id: output.c,v 1.101 2023/05/16 21:19:48 tom Exp $ */ #include "defs.h" @@ -1623,21 +1623,14 @@ output_pure_parser(FILE * fp) if (fp == code_file) ++outline; fprintf(fp, "#define YYPURE %d\n", pure_parser); - putc_code(fp, '\n'); -} - #if defined(YY_NO_LEAKS) -static void -output_no_leaks(FILE * fp) -{ - putc_code(fp, '\n'); - if (fp == code_file) ++outline; fputs("#define YY_NO_LEAKS 1\n", fp); +#else putc_code(fp, '\n'); -} #endif +} static void output_trailing_text(void) @@ -2092,9 +2085,6 @@ output(void) output_prefix(fp); output_pure_parser(fp); -#if defined(YY_NO_LEAKS) - output_no_leaks(fp); -#endif output_stored_text(fp); output_stype(fp); #if defined(YYBTYACC) diff --git a/package/byacc.spec b/package/byacc.spec deleted file mode 100644 index 6c9e43c4c14..00000000000 --- a/package/byacc.spec +++ /dev/null @@ -1,119 +0,0 @@ -Summary: public domain Berkeley LALR Yacc parser generator - -%global AppVersion 2.0 -%global AppPatched 20230201 - -%global AltProgram byacc2 -%global UseProgram yacc - -# $Id: byacc.spec,v 1.70 2023/02/02 00:12:06 tom Exp $ -Name: byacc -Version: %{AppVersion}.%{AppPatched} -Release: 1 -License: Public Domain, MIT -URL: https://invisible-island.net/%{name}/ -Source0: https://invisible-mirror.net/archives/%{name}/%{name}-%{AppPatched}.tgz - -%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. - -%package -n byacc2 -Summary: public domain Berkeley LALR Yacc parser generator with backtracking - -%description -n byacc2 -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. - -This package has the backtracking extension. - -%prep - -%global debug_package %{nil} - -%setup -q -n %{name}-%{AppPatched} - -%build -%define my_srcdir .. -%define CFG_OPTS \\\ - --verbose \\\ - --disable-echo \\\ - --enable-stdnoreturn \\\ - --target %{_target_platform} \\\ - --prefix=%{_prefix} \\\ - --srcdir=%{my_srcdir} \\\ - --bindir=%{_bindir} \\\ - --libdir=%{_libdir} \\\ - --mandir=%{_mandir} - -%global _configure ../configure - -mkdir BUILD-byacc -pushd BUILD-byacc -CONFIGURE_TOP=%{my_srcdir} \ -%configure %{CFG_OPTS} \ - --program-prefix=b \ -make -popd - -mkdir BUILD-byacc2 -pushd BUILD-byacc2 -CONFIGURE_TOP=%{my_srcdir} \ -%configure %{CFG_OPTS} \ - --enable-btyacc \ - --program-transform-name='s,\ Wed, 01 Feb 2023 19:12:06 -0500 - -byacc (1:2.0.20221229) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Thu, 29 Dec 2022 05:23:05 -0500 - -byacc (1:2.0.20221106) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 06 Nov 2022 10:51:43 -0500 - -byacc (1:2.0.20220128) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Fri, 28 Jan 2022 08:38:52 -0500 - -byacc (1:2.0.20220114) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Fri, 14 Jan 2022 16:33:35 -0500 - -byacc (1:2.0.20220109) unstable; urgency=low - - * maintenance updates, modify packaging to more closely match distributors. - In particular, correct versioning using an epoch. - - -- Thomas E. Dickey Sun, 09 Jan 2022 10:49:20 -0500 - -byacc (20220102) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 02 Jan 2022 11:12:56 -0500 - -byacc (20220101) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sat, 01 Jan 2022 07:06:35 -0500 - -byacc (20211224) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Fri, 24 Dec 2021 19:13:22 -0500 - -byacc (20210808) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 08 Aug 2021 15:26:10 -0400 - -byacc (20210802) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Mon, 02 Aug 2021 16:50:01 -0400 - -byacc (20210801) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 01 Aug 2021 15:30:22 -0400 - -byacc (20210619) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sat, 19 Jun 2021 14:06:48 -0400 - -byacc (20210520) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Thu, 20 May 2021 15:25:00 -0400 - -byacc (20210328) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 28 Mar 2021 11:14:10 -0400 - -byacc (20210109) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sat, 09 Jan 2021 09:32:51 -0500 - -byacc (20200910) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Thu, 10 Sep 2020 10:45:10 -0400 - -byacc (20200330) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Mon, 30 Mar 2020 19:31:42 -0400 - -byacc (20191125) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Mon, 25 Nov 2019 18:13:14 -0500 - -byacc (20191119) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Tue, 19 Nov 2019 20:40:56 -0500 - -byacc (20191103) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 03 Nov 2019 16:42:41 -0500 - -byacc (20190617) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 16 Jun 2019 15:51:03 -0400 - -byacc (20190616) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 16 Jun 2019 08:55:03 -0400 - -byacc (20180609) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sat, 09 Jun 2018 20:42:16 -0400 - -byacc (20180525) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Mon, 21 May 2018 18:50:44 -0400 - -byacc (20180510) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Thu, 10 May 2018 04:59:09 -0400 - -byacc (20180509) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Wed, 09 May 2018 21:13:51 -0400 - -byacc (20180508) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Tue, 08 May 2018 16:24:39 -0400 - -byacc (20170709) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 09 Jul 2017 13:49:13 -0400 - -byacc (20170430) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 30 Apr 2017 16:55:15 -0400 - -byacc (20170201) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Wed, 01 Feb 2017 04:55:04 -0500 - -byacc (20161202) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Fri, 02 Dec 2016 07:58:46 -0500 - -byacc (20160606) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Mon, 06 Jun 2016 20:44:26 -0400 - -byacc (20160601) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Mon, 06 Jun 2016 05:21:18 -0400 - -byacc (20160324) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Thu, 24 Mar 2016 19:55:52 -0400 - -byacc (20150711) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Fri, 10 Jul 2015 20:53:15 -0400 - -byacc (20150705) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 05 Jul 2015 18:24:51 -0400 - -byacc (20141128) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Fri, 28 Nov 2014 10:42:17 -0500 - -byacc (20141006) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Mon, 06 Oct 2014 18:52:03 -0400 - -byacc (20141005) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Sun, 27 Jul 2014 10:45:06 -0400 - -byacc (20140715) unstable; urgency=low - - * maintenance updates - - -- Thomas E. Dickey Tue, 15 Jul 2014 15:36:54 -0400 - -byacc (20140527) unstable; urgency=low - - * remove obsolete option from usage message - - -- Thomas E. Dickey Tue, 27 May 2014 22:01:55 -0400 - -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 - - -- Thomas E. Dickey Mon, 04 Mar 2013 20:17:32 -0500 - -byacc (20121003) unstable; urgency=low - - * changes from or prompted by Adrian Bunk. - - -- Thomas E. Dickey Sat, 29 Sep 2012 09:14:31 -0400 - -byacc (20120526) unstable; urgency=low - - * minor code-cleanup. - - -- Thomas E. Dickey Sat, 26 May 2012 12:14:17 -0400 - -byacc (20120115) unstable; urgency=low - - * add testcases, improve documentation for "-s" option. - - -- Thomas E. Dickey Fri, 13 Jan 2012 20:44:34 -0500 - -byacc (20111219) unstable; urgency=low - - * add "-s" option. - - -- Thomas E. Dickey Mon, 19 Dec 2011 20:54:09 -0500 - -byacc (20110908) unstable; urgency=low - - * add "-i" option. - * add error-check in reader.c - - -- Thomas E. Dickey Mon, 05 Sep 2011 20:05:51 -0400 - -byacc (20101229) unstable; urgency=low - - * fixes from Christos Zoulos - - -- Thomas E. Dickey Wed, 29 Dec 2010 13:03:50 -0500 - -byacc (20101226) unstable; urgency=low - - * portability fix for MinGW - - -- Thomas E. Dickey Sat, 25 Dec 2010 19:37:54 -0500 - -byacc (20101127) unstable; urgency=low - - * corrected yyerror use of %parse-param data - - -- Thomas E. Dickey Sat, 27 Nov 2010 12:32:00 -0500 - -byacc (20101126) unstable; urgency=low - - * additional fix to generated code to avoid symbol conflict - - -- Thomas E. Dickey Fri, 26 Nov 2010 04:23:08 -0500 - -byacc (20101124) unstable; urgency=low - - * amend fix for Red Hat #112617 to restore warning message. - - -- Thomas E. Dickey Mon, 22 Nov 2010 08:21:23 -0500 - -byacc (20101122) unstable; urgency=low - - * fix for generated header to avoid symbol conflict - - -- Thomas E. Dickey Mon, 22 Nov 2010 08:21:23 -0500 - -byacc (20100610) unstable; urgency=low - - * Add package scripts to upstream source, for test-builds. - - -- Thomas E. Dickey Thu, 10 Jun 2010 08:59:11 -0400 - -byacc (20100216-1) unstable; urgency=low - - * New upstream release - * debian/source/format: Added using format "3.0 (quilt)" - - -- Dave Beckett Tue, 20 Apr 2010 12:56:11 -0700 - -byacc (20091027-1) unstable; urgency=low - - * New upstream release - * debian/control: - - Updated to policy 3.8.4 - - Add ${misc:Depends} - - -- Dave Beckett Tue, 02 Feb 2010 21:36:34 -0800 - -byacc (20090221-1) unstable; urgency=low - - * New upstream release - - -- Dave Beckett Thu, 26 Feb 2009 21:06:20 -0800 - -byacc (20080826-1) unstable; urgency=high - - * New upstream release - * debian/patches/02-skeleton.patch: Removed - merged upstream - * debian/control: Updated to policy 3.8.0 - * debian/preinst, debian/postrm: removed - empty (lintian) - * debian/watch: version 3 and make FTP passive - * Acknowledge NMU - thanks. - - -- Dave Beckett Wed, 11 Sep 2008 23:58:00 -0700 - -byacc (20070509-1.1) unstable; urgency=high - - * Non-maintainer upload. - * Fix stack overflow in skeleton.c with upstream patch. - Closes: #491182 aka CVE-2008-3196 - - -- Thomas Viehmann Sun, 24 Aug 2008 23:13:07 +0200 - -byacc (20070509-1) unstable; urgency=low - - * New upstream release - * debian/watch: Fix to use passive FTP - * debian/compat: added instead of use of DH_COMPAT in debian/rules - - -- Dave Beckett Tue, 26 Jun 2007 22:39:45 -0700 - -byacc (20050813-1) unstable; urgency=low - - * New upstream release: - - Do not close union_file for -d option (Closes: #322858) - - -- Dave Beckett Sun, 14 Aug 2005 10:14:12 +0100 - -byacc (20050505-1) unstable; urgency=low - - * New maintainer (Closes: #321377) - * Switch to new upstream and new source (Closes: #240662) - * debian/copyright: Update to new upstream and add source information - (Closes: #166300) - * Acknowledge fix in NMUs (Closes: #283174) - * New manual page does not have the formatting problem (Closes: #100947) - * Added debian/watch file. - - -- Dave Beckett Fri, 5 Aug 2005 22:50:20 +0100 - -byacc (1.9.1-1.1) unstable; urgency=low - - * Remove alternative in prerm. Closes: #283174 - - -- LaMont Jones Fri, 26 Nov 2004 18:49:09 -0700 - -byacc (1.9.1-1) unstable; urgency=low - - * Maintainer upload. - * Fixed alternatives entry, closes: Bug#146195; - * Changed priority to "extra" at behest of Daniel Bungert, - closes: Bug#142271. - * Fixed awful packaging error which meant the test/ directory was excluded - from the orig.tar.gz. - - -- Jason Henry Parker Fri, 27 Sep 2002 16:25:27 -0400 - -byacc (1.9-13.1) unstable; urgency=low - - * Non-maintainer upload - * Removed erraneous escapes in manpage - some data wasn't visable, - closes: Bug#100947 - * Alternatives entry added, closes: Bug#113168 - * Standards-version: 3.5.6 - * Maintainer script cleaning - - -- Daniel Bungert Fri, 29 Mar 2002 16:58:30 -0500 - -byacc (1.9-13) unstable; urgency=low - - * Applied patch from "Randolph Chung" to fix build problems - on ia64, closes: Bug#91966 - - -- Jason Henry Parker Thu, 29 Mar 2001 21:41:19 +1000 - -byacc (1.9-12) unstable; urgency=low - - * Updated to latest version of debhelper, and Standards-Version: 3.2.1.0, closes: Bug#81444 - * Added Build-Depends: debhelper, closes: Bug#70207 - * Removed mktemp() calls in main.c - - -- Jason Henry Parker Mon, 18 Dec 2000 08:02:54 +1000 - -byacc (1.9-11.7) unstable; urgency=low - - * New maintainer. - * Updated to dh_make and standards version 2.4.0.0, no lintian errors - or warnings. - * Added several more files from the upstream distribution to - /usr/doc/byacc. - - -- Jason Henry Parker Sat, 2 Jan 1999 03:04:17 +1000 - -byacc (1.9-11.6) unstable; urgency=low - - * Patch by to remove some - superfluous files that can interfere with the build process on other - architectures. (Bug #21607). - - -- Vincent Renardias Fri, 24 Apr 1998 19:56:58 +0200 - -byacc (1.9-11.5) unstable; urgency=low - - * Added 'binary-arch' target in debian/rules (Bug #12742). - - -- Vincent Renardias Sun, 9 Nov 1997 23:37:31 +0100 - -byacc (1.9-11.4) unstable; urgency=low - - * Cosmetic change (Fix bug #9623). - - -- Vincent Renardias Fri, 9 May 1997 16:30:24 +0200 - -byacc (1.9-11.3) unstable; urgency=low - - * Rebuilt with libc6. - - -- Debian QA Group Thu, 1 May 1997 22:02:04 +0200 - -byacc (1.9-11.2) unstable; urgency=low - - * Orphaned the package at his maintainer's request (dgregor@coil.com). - - -- Debian QA Group Sun, 20 Apr 1997 20:03:03 +0200 - -byacc (1.9-11.1) unstable; urgency=low - - * Converted to new source format (Fixes #8085). - * Compressed manpage. - * Fixed to allow compilation on non-i386 (Fixes #3361). - * Added extended description (Fixes #3567). - * Added diversion to avoid conflict with bison (Fixes #8086). - - -- Vincent Renardias Sun, 20 Apr 1997 15:59:28 +0200 diff --git a/package/debian/control b/package/debian/control deleted file mode 100644 index 95e709a3ee9..00000000000 --- a/package/debian/control +++ /dev/null @@ -1,28 +0,0 @@ -Source: byacc -Maintainer: Thomas E. Dickey -Uploaders: Thomas E. Dickey -Section: devel -Priority: optional -Standards-Version: 4.6.0.1 -Build-Depends: debhelper-compat (= 12), -Rules-Requires-Root: no -Homepage: https://invisible-island.net/byacc/ -Vcs-Browser: https://salsa.debian.org/debian/byacc -Vcs-Git: https://salsa.debian.org/debian/byacc.git - -Package: byacc2 -Provides: yacc -Architecture: any -Multi-Arch: foreign -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: public domain Berkeley LALR Yacc parser generator - 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. - . - This package has the backtracking extension, adapted from btyacc. - The package is renamed to allow installing at the same time as "byacc". - . - Related packages: bison, btyacc, byacc, antlr diff --git a/package/debian/copyright b/package/debian/copyright deleted file mode 100644 index d80760fbf38..00000000000 --- a/package/debian/copyright +++ /dev/null @@ -1,129 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: byacc -Upstream-Contact: (Thomas E. Dickey) -Source: https://invisible-island.net/byacc/ - -Files: * -Copyright: 2001-2022,2023 by Thomas E. Dickey -License: public-domain - Berkeley Yacc is in the public domain; changes made to it by the current - maintainer are likewise unrestricted. That applies to most of the files. - A few files (currently those related to autoconf scripting) have other - licenses as noted here. - . - Current byacc upstream maintainer: Thomas Dickey - . - Public domain notice and no warranty: - ------------------------------------------------------------------------------- - Berkeley Yacc is an LALR(1) parser generator. Berkeley Yacc has been made - 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. - . - Berkeley Yacc is distributed with no warranty whatever. The code - is certain to contain errors. Neither the author nor any contributor - takes responsibility for any consequences of its use. - . - Berkeley Yacc is in the public domain. The data structures and algorithms - used in Berkeley Yacc are all either taken from documents available to the - general public or are inventions of the author. Anyone may freely distribute - source or binary forms of Berkeley Yacc whether unchanged or modified. - Distributers may charge whatever fees they can obtain for Berkeley Yacc. - Programs generated by Berkeley Yacc may be distributed freely. - . - Please report bugs to - . - robert.corbett@eng.Sun.COM - . - Include a small example if possible. Please include the banner string from - skeleton.c with the bug report. Do not expect rapid responses. - ------------------------------------------------------------------------------- - -Files: aclocal.m4 -Copyright: 2004-2022,2023 by Thomas E. Dickey -License: other-BSD - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, distribute with modifications, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - . - The above copyright notice and this permission notice shall be included - in all copies or portions of the Software. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - THE USE OR OTHER DEALINGS IN THE SOFTWARE. - . - Except as contained in this notice, the name(s) of the above copyright - holders shall not be used in advertising or otherwise to promote the - sale, use or other dealings in this Software without prior written - authorization. - -Files: install-sh -Copyright: 1994 X Consortium -License: other-BSD - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to - deal in the Software without restriction, including without limitation the - rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - . - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- - TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - . - Except as contained in this notice, the name of the X Consortium shall not - be used in advertising or otherwise to promote the sale, use or other deal- - ings in this Software without prior written authorization from the X Consor- - tium. - . - FSF changes to this file are in the public domain. - . - Calling this script install-sh is preferred over install.sh, to prevent - `make' implicit rules from creating a file called install from it - when there is no Makefile. - . - This script is compatible with the BSD install script, but was written - from scratch. It can only install one file at a time, a restriction - shared with many OS's install programs. - -Files: package/debian/* -Copyright: 2012-2022,2023 Thomas E. Dickey -License: other-BSD - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose and without fee is hereby granted, - provided that the above copyright notice appear in all copies and that - both that copyright notice and this permission notice appear in - supporting documentation, and that the name of the above listed - copyright holder(s) not be used in advertising or publicity pertaining - to distribution of the software without specific, written prior - permission. - . - THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD - TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE - LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -Files: config.guess config.sub -Copyright: 1992-2021 Free Software Foundation, Inc. -License: GPL-3 - On Debian systems, the complete text of the GNU General - Public License can be found in '/usr/share/common-licenses/GPL-3' diff --git a/package/debian/rules b/package/debian/rules deleted file mode 100755 index 81b0e7c6f0c..00000000000 --- a/package/debian/rules +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/make -f - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -export DEB_BUILD_MAINT_OPTIONS := hardening=+all qa=+bug reproducible=+all - -%: - dh $@ - -# dh_autoreconf interferes with portability -- skip it -override_dh_autoreconf: - echo "skip: dh_autoreconf autoreconf-dickey -- -f -i" - -override_dh_auto_configure: - dh_auto_configure -- \ - --enable-warnings \ - --verbose \ - --enable-stdnoreturn \ - --enable-btyacc \ - --with-max-table-size=123456 \ - --program-transform-name='s,^yacc,byacc2,' - - # workaround for whatis - sed -i '/- an LALR/s,^..N,byacc2,' yacc.1 - - # omit tests which rely upon getopt error-messages - sed -i.bak '/MYFILE=nosuchfile/,/# Test special cases/d' test/run_test.sh - diff -u test/run_test.sh.bak test/run_test.sh || echo OK diff --git a/package/debian/source/format b/package/debian/source/format deleted file mode 100644 index 89ae9db8f88..00000000000 --- a/package/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) diff --git a/package/debian/watch b/package/debian/watch deleted file mode 100644 index a31bf234aac..00000000000 --- a/package/debian/watch +++ /dev/null @@ -1,20 +0,0 @@ -version=4 - -# upstream provides tarballs such as "byacc-20220101.tgz" (originally to -# keep the filenames compatible with systems where multiple "." are illegal). -# -# The version number (2.0) is current since late 2020; before that it was -# "1.9" for a long time. Use -# byacc -V -# to see the version number: -# byacc - 2.0 20220101 -# -# The introduction of the back-tracking configuration motivated the change of -# major/minor numbers; for compatibility the parser skeleton still says "1.9". -# -# Patch-dates are always # in yyyymmdd format. - -opts=pgpmode=auto,\ -dversionmangle=s/^2\.0\.//,\ -oversionmangle=s/^(.*)/2.0.$1/ \ - https://invisible-mirror.net/archives/byacc/byacc-(\d+)\.tgz diff --git a/package/mingw-byacc.spec b/package/mingw-byacc.spec deleted file mode 100644 index 0ba6dd22f53..00000000000 --- a/package/mingw-byacc.spec +++ /dev/null @@ -1,68 +0,0 @@ -Summary: public domain Berkeley LALR Yacc parser generator - -%global AppVersion 2.0 -%global AppPatched 20230201 - -%global UseProgram yacc - -# $Id: mingw-byacc.spec,v 1.47 2023/02/02 00:12:06 tom Exp $ -Name: byacc -Version: %{AppVersion}.%{AppPatched} -Release: 1 -License: Public Domain, MIT -URL: https://invisible-island.net/%{name}/ -Source0: https://invisible-mirror.net/archives/%{name}/%{name}-%{AppPatched}.tgz - -%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 - -%global debug_package %{nil} - -%setup -q -n %{name}-%{AppPatched} - -%build -%configure --verbose \ - --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 %{name} %{UseProgram} ) - -strip $RPM_BUILD_ROOT%{_bindir}/%{name} - -%clean -[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT - -%files -%doc ACKNOWLEDGEMENTS CHANGES NEW_FEATURES NOTES NO_WARRANTY README -%license LICENSE -%{_bindir}/%{name} -%{_bindir}/%{UseProgram} -%{_mandir}/man1/%{name}.* - -%changelog -# each patch should add its ChangeLog entries here - -* Sun Jan 09 2022 Thomas Dickey -- rpmlint - -* Sun Jul 09 2017 Thomas Dickey -- use predefined "configure" - -* Wed Sep 25 2013 Thomas Dickey -- cloned from byacc.spec diff --git a/package/pkgsrc/DESCR b/package/pkgsrc/DESCR deleted file mode 100644 index fe018659e9a..00000000000 --- a/package/pkgsrc/DESCR +++ /dev/null @@ -1,6 +0,0 @@ -Berkeley Yacc (byacc) is a LALR(1) parser generator. Berkeley Yacc -has been made as compatible as possible with AT&T Yacc. Berkeley -Yacc can accept any input specification that conforms to the AT&T -Yacc documentation. - -Some programs depend on a byacc (instead of bison). diff --git a/package/pkgsrc/Makefile b/package/pkgsrc/Makefile deleted file mode 100644 index 4bde471dcc1..00000000000 --- a/package/pkgsrc/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# $NetBSD: Makefile,v 1.24 2021/08/14 01:04:32 mef Exp $ -# - -DISTNAME= byacc-20230201 -CATEGORIES= devel -MASTER_SITES= https://invisible-mirror.net/archives/byacc/ -DIST_SUBDIR= byacc-20220101 -EXTRACT_SUFX= .tgz - -MAINTAINER= fcambus@NetBSD.org -HOMEPAGE= https://invisible-island.net/byacc/byacc.html -COMMENT= Berkeley Yacc -LICENSE= public-domain - - -GNU_CONFIGURE= YES -MAKE_FILE= makefile - -.include "../../mk/bsd.pkg.mk" diff --git a/package/pkgsrc/PLIST b/package/pkgsrc/PLIST deleted file mode 100644 index 5bcfece36ca..00000000000 --- a/package/pkgsrc/PLIST +++ /dev/null @@ -1,3 +0,0 @@ -@comment $NetBSD: PLIST,v 1.2 2005/04/13 14:11:54 wiz Exp $ -bin/yacc -man/man1/yacc.1 diff --git a/package/pkgsrc/distinfo b/package/pkgsrc/distinfo deleted file mode 100644 index 99252a68675..00000000000 --- a/package/pkgsrc/distinfo +++ /dev/null @@ -1,6 +0,0 @@ -$NetBSD: distinfo,v 1.4 2008/07/24 17:13:00 tonnerre Exp $ - -SHA1 (byacc-20050813.tgz) = 3258494f3422eb3150944c1823af1c9c2c386062 -RMD160 (byacc-20050813.tgz) = 3ee159857a79025a83e2b0807577925fe460f816 -Size (byacc-20050813.tgz) = 138684 bytes -SHA1 (patch-aa) = decae78775a5e0f1e1f7aaaa258da53903aa1f7a diff --git a/reader.c b/reader.c index 5e8ca67bc64..49e90dee1ae 100644 --- a/reader.c +++ b/reader.c @@ -1,4 +1,4 @@ -/* $Id: reader.c,v 1.91 2022/01/09 18:04:58 tom Exp $ */ +/* $Id: reader.c,v 1.104 2023/05/18 21:18:17 tom Exp $ */ #include "defs.h" @@ -20,6 +20,11 @@ /* this is a hard limit, but seems more than adequate */ #define MAXARGS 20 +/* limit the size of optional names for %union */ +#define NAME_LEN 32 + +#define IS_ALNUM(c) (isalnum(c) || (c) == '_') + #define begin_case(f,n) fprintf(f, "case %d:\n", (int)(n)) #define end_case(f) \ @@ -27,6 +32,17 @@ fprintf_lineno(f, 1, ""); \ fprintf(f, "break;\n") +#define begin_ainfo(data, offset) do { \ + data.a_lineno = lineno; \ + data.a_line = dup_line(); \ + data.a_cptr = data.a_line + (cptr - line - offset); \ + } while (0) + +#define end_ainfo(data) do { \ + FREE(data.a_line); \ + memset(&data, 0, sizeof(data)); \ + } while (0) + static void start_rule(bucket *bp, int s_lineno); #if defined(YYBTYACC) static void copy_initial_action(void); @@ -44,8 +60,22 @@ static char **tag_table; static char saw_eof; char unionized; -char *cptr, *line; -static int linesize; + +char *line; /* current input-line */ +char *cptr; /* position within current input-line */ +static size_t linesize; /* length of current input-line */ + +typedef struct +{ + char *line_data; /* saved input-line */ + size_t line_used; /* position within saved input-line */ + size_t line_size; /* length of saved input-line */ + fpos_t line_fpos; /* pointer before reading past saved input-line */ +} +SAVE_LINE; + +static SAVE_LINE save_area; +static int must_save; /* request > 0, triggered < 0, inactive 0 */ static bucket *goal; static Value_t prec; @@ -264,15 +294,59 @@ line_directive(void) #undef UNLESS } +static void +save_line(void) +{ + /* remember to save the input-line if we call get_line() */ + if (!must_save) + { + must_save = 1; + save_area.line_used = (size_t)(cptr - line); + } +} + +static void +restore_line(void) +{ + /* if we saved the line, restore it */ + if (must_save < 0) + { + free(line); + line = save_area.line_data; + cptr = save_area.line_used + line; + linesize = save_area.line_size; + if (fsetpos(input_file, &save_area.line_fpos) != 0) + on_error(); + memset(&save_area, 0, sizeof(save_area)); + } + else if (must_save > 0) + { + cptr = line + save_area.line_used; + } + must_save = 0; +} + static void get_line(void) { FILE *f = input_file; + if (must_save > 0) + { + save_area.line_data = TMALLOC(char, linesize); + save_area.line_used = (size_t)(cptr - line); + save_area.line_size = linesize; + NO_SPACE(save_area.line_data); + memcpy(save_area.line_data, line, linesize); + if (fgetpos(f, &save_area.line_fpos) != 0) + on_error(); + must_save = -must_save; + } + do { int c; - int i; + size_t i; if (saw_eof || (c = getc(f)) == EOF) { @@ -348,9 +422,8 @@ skip_comment(void) { char *s; struct ainfo a; - a.a_lineno = lineno; - a.a_line = dup_line(); - a.a_cptr = a.a_line + (cptr - line); + + begin_ainfo(a, 0); s = cptr + 2; for (;;) @@ -358,7 +431,7 @@ skip_comment(void) if (*s == '*' && s[1] == '/') { cptr = s + 2; - FREE(a.a_line); + end_ainfo(a); return; } if (*s == '\n') @@ -425,6 +498,7 @@ nextc(void) { switch (ch = next_inline()) { + case '\0': case '\n': get_line(); break; @@ -459,6 +533,7 @@ keywords[] = { { "binary", NONASSOC }, { "code", XCODE }, { "debug", NONPOSIX_DEBUG }, + { "define", HACK_DEFINE }, #if defined(YYBTYACC) { "destructor", DESTRUCTOR }, #endif @@ -475,6 +550,7 @@ keywords[] = { { "locations", LOCATIONS }, #endif { "nonassoc", NONASSOC }, + { "nterm", TYPE }, { "parse-param", PARSE_PARAM }, { "pure-parser", PURE_PARSER }, { "right", RIGHT }, @@ -597,9 +673,8 @@ copy_string(int quote) { struct mstring *temp = msnew(); struct ainfo a; - a.a_lineno = lineno; - a.a_line = dup_line(); - a.a_cptr = a.a_line + (cptr - line - 1); + + begin_ainfo(a, 1); for (;;) { @@ -608,7 +683,7 @@ copy_string(int quote) mputc(temp, c); if (c == quote) { - FREE(a.a_line); + end_ainfo(a); return msdone(temp); } if (c == '\n') @@ -649,9 +724,8 @@ copy_comment(void) else if (c == '*') { struct ainfo a; - a.a_lineno = lineno; - a.a_line = dup_line(); - a.a_cptr = a.a_line + (cptr - line - 1); + + begin_ainfo(a, 1); mputc(temp, c); ++cptr; @@ -663,7 +737,7 @@ copy_comment(void) { mputc(temp, '/'); ++cptr; - FREE(a.a_line); + end_ainfo(a); return msdone(temp); } if (c == '\n') @@ -706,6 +780,16 @@ copy_code(void) c = *++cptr; if (c == EOF) unexpected_EOF(); + if (c == '\0') + { + get_line(); + if (line == NULL) + { + unexpected_EOF(); + /*NOTREACHED */ + } + c = *cptr; + } if (isspace(UCH(c))) continue; @@ -806,9 +890,8 @@ copy_text(void) FILE *f = text_file; int need_newline = 0; struct ainfo a; - a.a_lineno = lineno; - a.a_line = dup_line(); - a.a_cptr = a.a_line + (cptr - line - 2); + + begin_ainfo(a, 2); if (*cptr == '\n') { @@ -858,7 +941,7 @@ copy_text(void) if (need_newline) putc('\n', f); ++cptr; - FREE(a.a_line); + end_ainfo(a); return; } /* FALLTHRU */ @@ -873,9 +956,12 @@ copy_text(void) static void puts_both(const char *s) { - fputs(s, text_file); - if (dflag) - fputs(s, union_file); + if (s && *s) + { + fputs(s, text_file); + if (dflag) + fputs(s, union_file); + } } static void @@ -892,9 +978,16 @@ copy_union(void) int c; int depth; struct ainfo a; - a.a_lineno = lineno; - a.a_line = dup_line(); - a.a_cptr = a.a_line + (cptr - line - 6); + char prefix_buf[NAME_LEN + 1]; + size_t prefix_len = 0; + char filler_buf[NAME_LEN + 1]; + size_t filler_len = 0; + int in_prefix = 1; + + prefix_buf[0] = '\0'; + filler_buf[0] = '\0'; + + begin_ainfo(a, 6); if (unionized) over_unionized(cptr - 6); @@ -908,12 +1001,51 @@ copy_union(void) puts_both("#define YYSTYPE_IS_DECLARED 1\n"); fprintf_lineno(text_file, lineno, input_file_name); - puts_both("typedef union YYSTYPE"); depth = 0; loop: c = *cptr++; - putc_both(c); + if (in_prefix) + { + if (c == L_CURL) + { + in_prefix = 0; + if (prefix_len) + { + puts_both("union "); + puts_both(prefix_buf); + puts_both(filler_buf); + } + else + { + puts_both("typedef union YYSTYPE"); + puts_both(filler_buf); + } + } + else if (isspace(c)) + { + if (filler_len >= sizeof(filler_buf) - 1) + { + puts_both(filler_buf); + filler_len = 0; + } + filler_buf[filler_len++] = (char)c; + filler_buf[filler_len] = 0; + if (c != '\n') + goto loop; + } + else if (IS_IDENT(c)) + { + if (prefix_len < NAME_LEN) + { + prefix_buf[prefix_len++] = (char)c; + prefix_buf[prefix_len] = 0; + } + goto loop; + } + } + if (c != '\n' || !in_prefix) + putc_both(c); switch (c) { case '\n': @@ -929,9 +1061,15 @@ copy_union(void) case R_CURL: if (--depth == 0) { - puts_both(" YYSTYPE;\n"); + puts_both(prefix_len ? "; " : " YYSTYPE;\n"); + if (prefix_len) + { + puts_both("typedef union "); + puts_both(prefix_buf); + puts_both(" YYSTYPE;\n"); + } puts_both("#endif /* !YYSTYPE_IS_DECLARED */\n"); - FREE(a.a_line); + end_ainfo(a); return; } goto loop; @@ -1017,9 +1155,9 @@ trim_blanks(char *buffer) static int more_curly(void) { - char *save = cptr; int result = 0; int finish = 0; + save_line(); do { switch (next_inline()) @@ -1036,7 +1174,7 @@ more_curly(void) ++cptr; } while (!finish); - cptr = save; + restore_line(); return result; } @@ -1053,6 +1191,24 @@ save_param(int k, char *buffer, int name, int type2) buffer[type2] = '\0'; (void)trim_blanks(p->type2); + if (!IS_ALNUM(buffer[name])) + { + int n; + for (n = name - 1; n >= 0; --n) + { + if (!isspace(UCH(buffer[n]))) + { + break; + } + } + while (n > 0) + { + if (!IS_ALNUM(UCH(buffer[n - 1]))) + break; + --n; + } + name = n; + } p->name = strdup(buffer + name); NO_SPACE(p->name); buffer[name] = '\0'; @@ -1240,7 +1396,7 @@ copy_param(int k) type2 = i + 1; } - while (i > 0 && (isalnum(UCH(parms[i])) || UCH(parms[i]) == '_')) + while (i > 0 && IS_ALNUM(UCH(parms[i]))) i--; if (!isspace(UCH(parms[i])) && parms[i] != '*') @@ -1280,9 +1436,8 @@ get_literal(void) char *s; bucket *bp; struct ainfo a; - a.a_lineno = lineno; - a.a_line = dup_line(); - a.a_cptr = a.a_line + (cptr - line); + + begin_ainfo(a, 0); quote = *cptr++; cinc = 0; @@ -1375,7 +1530,7 @@ get_literal(void) } cachec(c); } - FREE(a.a_line); + end_ainfo(a); n = cinc; s = TMALLOC(char, n); @@ -1742,6 +1897,82 @@ declare_argtypes(bucket *bp) } #endif +static int +scan_blanks(void) +{ + int c; + + do + { + c = next_inline(); + if (c == '\n') + { + ++cptr; + return 0; + } + else if (c == ' ' || c == '\t') + ++cptr; + else + break; + } + while (c == ' ' || c == '\t'); + + return 1; +} + +static int +scan_ident(void) +{ + int c; + + cinc = 0; + for (c = *cptr; IS_IDENT(c); c = *++cptr) + cachec(c); + cachec(NUL); + + return cinc; +} + +static void +hack_defines(void) +{ + struct ainfo a; + + if (!scan_blanks()) + return; + + begin_ainfo(a, 0); + if (!scan_ident()) + { + end_ainfo(a); + } + + if (!strcmp(cache, "api.pure")) + { + end_ainfo(a); + scan_blanks(); + begin_ainfo(a, 0); + scan_ident(); + + if (!strcmp(cache, "false")) + pure_parser = 0; + else if (!strcmp(cache, "true") + || !strcmp(cache, "full") + || *cache == 0) + pure_parser = 1; + else + unexpected_value(&a); + end_ainfo(a); + } + else + { + unexpected_value(&a); + } + + while (next_inline() != '\n') + ++cptr; +} + static void declare_types(void) { @@ -1900,6 +2131,10 @@ read_declarations(void) tflag = 1; break; + case HACK_DEFINE: + hack_defines(); + break; + case POSIX_YACC: /* noop for bison compatibility. byacc is already designed to be posix * yacc compatible. */ @@ -1983,9 +2218,7 @@ copy_args(int *alen) char c, quote = 0; struct ainfo a; - a.a_lineno = lineno; - a.a_line = dup_line(); - a.a_cptr = a.a_line + (cptr - line - 1); + begin_ainfo(a, 1); while ((c = *cptr++) != R_PAREN || depth || quote) { @@ -2029,7 +2262,7 @@ copy_args(int *alen) } if (alen) *alen = len; - FREE(a.a_line); + end_ainfo(a); return msdone(s); } @@ -2681,9 +2914,7 @@ copy_action(void) Value_t *offsets = NULL, maxoffset; bucket **rhs; - a.a_lineno = lineno; - a.a_line = dup_line(); - a.a_cptr = a.a_line + (cptr - line); + begin_ainfo(a, 0); if (last_was_action) insert_empty_rule(); @@ -2877,10 +3108,8 @@ copy_action(void) { 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); + dislocations_warning(); + locations = 1; } if (cptr[1] == '$') { @@ -2949,7 +3178,7 @@ copy_action(void) goto loop; } end_case(f); - FREE(a.a_line); + end_ainfo(a); if (maxoffset > 0) FREE(offsets); return; @@ -2969,7 +3198,7 @@ copy_action(void) if (depth > 0) goto loop; end_case(f); - free(a.a_line); + end_ainfo(a); if (maxoffset > 0) FREE(offsets); return; @@ -3011,7 +3240,7 @@ copy_action(void) } #endif end_case(f); - free(a.a_line); + end_ainfo(a); if (maxoffset > 0) FREE(offsets); return; @@ -3057,9 +3286,7 @@ get_code(struct ainfo *a, const char *loc) else syntax_error(lineno, line, cptr); - a->a_lineno = lineno; - a->a_line = dup_line(); - a->a_cptr = a->a_line + (cptr - line); + begin_ainfo((*a), 0); depth = 0; loop: @@ -3097,10 +3324,8 @@ get_code(struct ainfo *a, const char *loc) { 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); + dislocations_warning(); + locations = 1; } msprintf(code_mstr, "%s", loc); cptr += 2; @@ -3165,7 +3390,7 @@ copy_initial_action(void) struct ainfo a; initial_action = get_code(&a, "yyloc"); - free(a.a_line); + end_ainfo(a); } static void @@ -3247,7 +3472,7 @@ copy_destructor(void) else break; } - free(a.a_line); + end_ainfo(a); free(code_text); } diff --git a/test/README b/test/README deleted file mode 100644 index c9133c5bc87..00000000000 --- a/test/README +++ /dev/null @@ -1,4 +0,0 @@ --- $Id: README,v 1.1 2004/03/28 19:10:48 tom Exp $ - -The files in this directory are input (.y) and output (.output, .tab.c, .tab.h) -examples. diff --git a/test/btyacc/big_b.error b/test/btyacc/big_b.error deleted file mode 100644 index 7f74f49a89b..00000000000 --- a/test/btyacc/big_b.error +++ /dev/null @@ -1,30 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/btyacc/big_b.output b/test/btyacc/big_b.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/big_l.error b/test/btyacc/big_l.error deleted file mode 100644 index 7f74f49a89b..00000000000 --- a/test/btyacc/big_l.error +++ /dev/null @@ -1,30 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/btyacc/big_l.output b/test/btyacc/big_l.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/btyacc_calc1.error b/test/btyacc/btyacc_calc1.error deleted file mode 100644 index 1807ff98801..00000000000 --- a/test/btyacc/btyacc_calc1.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 17 shift/reduce conflicts, 27 reduce/reduce conflicts. diff --git a/test/btyacc/btyacc_calc1.output b/test/btyacc/btyacc_calc1.output deleted file mode 100644 index fe68c43780c..00000000000 --- a/test/btyacc/btyacc_calc1.output +++ /dev/null @@ -1,949 +0,0 @@ - 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/test/btyacc/btyacc_calc1.tab.c b/test/btyacc/btyacc_calc1.tab.c deleted file mode 100644 index 53edd4e8889..00000000000 --- a/test/btyacc/btyacc_calc1.tab.c +++ /dev/null @@ -1,1803 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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]; - -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 29 "btyacc_calc1.y" -typedef union YYSTYPE -{ - 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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -#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 620 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yyerrflag; - int yychar; - YYSTYPE yyval; - YYSTYPE yylval; - int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyloc; /* position returned by actions */ - YYLTYPE yylloc; /* position from the lexer */ -#endif - - /* 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 YYINT *yylexp = 0; - - static YYINT *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[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - - yyerrflag = 0; - yychar = 0; - memset(&yyval, 0, sizeof(yyval)); - memset(&yylval, 0, sizeof(yylval)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(&yyloc, 0, sizeof(yyloc)); - memset(&yylloc, 0, sizeof(yylloc)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 2: -#line 51 "btyacc_calc1.y" -{YYVALID;} -#line 1354 "btyacc_calc1.tab.c" -break; -case 3: -#line 52 "btyacc_calc1.y" -{YYVALID;} if (!yytrial) -#line 53 "btyacc_calc1.y" -{ - yyerrok; - } -#line 1363 "btyacc_calc1.tab.c" -break; -case 4: - if (!yytrial) -#line 59 "btyacc_calc1.y" - { - (void) printf("%15.8f\n", yystack.l_mark[0].dval); - } -#line 1371 "btyacc_calc1.tab.c" -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); - } -#line 1379 "btyacc_calc1.tab.c" -break; -case 6: - if (!yytrial) -#line 67 "btyacc_calc1.y" - { - dreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].dval; - } -#line 1387 "btyacc_calc1.tab.c" -break; -case 7: - if (!yytrial) -#line 71 "btyacc_calc1.y" - { - vreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].vval; - } -#line 1395 "btyacc_calc1.tab.c" -break; -case 9: - if (!yytrial) -#line 78 "btyacc_calc1.y" - { - yyval.dval = dreg[yystack.l_mark[0].ival]; - } -#line 1403 "btyacc_calc1.tab.c" -break; -case 10: - if (!yytrial) -#line 82 "btyacc_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; - } -#line 1411 "btyacc_calc1.tab.c" -break; -case 11: - if (!yytrial) -#line 86 "btyacc_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; - } -#line 1419 "btyacc_calc1.tab.c" -break; -case 12: - if (!yytrial) -#line 90 "btyacc_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; - } -#line 1427 "btyacc_calc1.tab.c" -break; -case 13: - if (!yytrial) -#line 94 "btyacc_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; - } -#line 1435 "btyacc_calc1.tab.c" -break; -case 14: - if (!yytrial) -#line 98 "btyacc_calc1.y" - { - yyval.dval = -yystack.l_mark[0].dval; - } -#line 1443 "btyacc_calc1.tab.c" -break; -case 15: - if (!yytrial) -#line 102 "btyacc_calc1.y" - { - yyval.dval = yystack.l_mark[-1].dval; - } -#line 1451 "btyacc_calc1.tab.c" -break; -case 16: - if (!yytrial) -#line 108 "btyacc_calc1.y" - { - yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; - } -#line 1459 "btyacc_calc1.tab.c" -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; - } - } -#line 1473 "btyacc_calc1.tab.c" -break; -case 18: - if (!yytrial) -#line 122 "btyacc_calc1.y" - { - yyval.vval = vreg[yystack.l_mark[0].ival]; - } -#line 1481 "btyacc_calc1.tab.c" -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; - } -#line 1490 "btyacc_calc1.tab.c" -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; - } -#line 1499 "btyacc_calc1.tab.c" -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; - } -#line 1508 "btyacc_calc1.tab.c" -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; - } -#line 1517 "btyacc_calc1.tab.c" -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 ); - } -#line 1525 "btyacc_calc1.tab.c" -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 ); - } -#line 1533 "btyacc_calc1.tab.c" -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 ); - } -#line 1542 "btyacc_calc1.tab.c" -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 ); - } -#line 1551 "btyacc_calc1.tab.c" -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; - } -#line 1560 "btyacc_calc1.tab.c" -break; -case 28: - if (!yytrial) -#line 169 "btyacc_calc1.y" - { - yyval.vval = yystack.l_mark[-1].vval; - } -#line 1568 "btyacc_calc1.tab.c" -break; -#line 1570 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/btyacc_calc1.tab.h b/test/btyacc/btyacc_calc1.tab.h deleted file mode 100644 index 114d213cd96..00000000000 --- a/test/btyacc/btyacc_calc1.tab.h +++ /dev/null @@ -1,22 +0,0 @@ -#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 YYSTYPE -{ - int ival; - double dval; - INTERVAL vval; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ - -#endif /* _calc1__defines_h_ */ diff --git a/test/btyacc/btyacc_demo.error b/test/btyacc/btyacc_demo.error deleted file mode 100644 index c070d881ffa..00000000000 --- a/test/btyacc/btyacc_demo.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 12 shift/reduce conflicts. diff --git a/test/btyacc/btyacc_demo.output b/test/btyacc/btyacc_demo.output deleted file mode 100644 index a281c242a37..00000000000 --- a/test/btyacc/btyacc_demo.output +++ /dev/null @@ -1,1298 +0,0 @@ - 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 decl : decl_specs declarator_list ';' - - 11 $$3 : - - 12 decl : decl_specs declarator $$3 block_statement - - 13 decl_specs : decl_spec - 14 | decl_specs $$2 decl_spec - - 15 cv_quals : - 16 | cv_quals cv_qual - - 17 decl_spec : cv_qual - 18 | typename - 19 | EXTERN - 20 | REGISTER - 21 | STATIC - - 22 cv_qual : CONST - 23 | VOLATILE - - 24 $$4 : - - 25 $$5 : - - 26 declarator_list : declarator_list ',' $$4 $$5 declarator - 27 | declarator - - 28 declarator : - 29 | ID - - 30 $$6 : - - 31 $$7 : - - 32 declarator : '(' $$6 $$7 declarator ')' - 33 | '*' cv_quals $$4 $$5 declarator - 34 | declarator '[' $$4 expr ']' - 35 | declarator '(' $$4 formal_arg_list ')' cv_quals - - 36 formal_arg_list : - 37 | nonempty_formal_arg_list - - 38 nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg - 39 | formal_arg - - 40 formal_arg : decl_specs declarator - - 41 expr : expr '+' $$6 expr - 42 | expr '-' $$6 expr - 43 | expr '*' $$6 expr - 44 | expr '%' $$6 expr - 45 | expr '/' $$6 expr - 46 | '*' $$2 expr - 47 | ID - 48 | CONSTANT - - 49 statement : decl - 50 | expr ';' - - 51 $$8 : - - 52 $$9 : - - 53 statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement - 54 | IF '(' $$6 expr ')' THEN $$8 statement - - 55 $$10 : - - 56 statement : $$10 block_statement - - 57 statement_list : - 58 | statement_list $$2 statement - - 59 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 . (19) - - . reduce 19 - - -state 6 - decl_spec : REGISTER . (20) - - . reduce 20 - - -state 7 - decl_spec : STATIC . (21) - - . reduce 21 - - -state 8 - cv_qual : CONST . (22) - - . reduce 22 - - -state 9 - cv_qual : VOLATILE . (23) - - . reduce 23 - - -state 10 - opt_scope : CLCL . (2) - - . reduce 2 - - -state 11 - decl_list : decl_list $$2 decl . (9) - - . reduce 9 - - -12: shift/reduce conflict (shift 18, reduce 28) on '(' -12: shift/reduce conflict (shift 19, reduce 8) on ID -state 12 - decl : decl_specs . declarator_list ';' (10) - decl : decl_specs . declarator $$3 block_statement (12) - decl_specs : decl_specs . $$2 decl_spec (14) - $$2 : . (8) - declarator : . (28) - - '*' shift 17 - '(' [trial] shift 18 - ID [trial] shift 19 - '(' [trial] reduce 28 - '[' reduce 28 - ID [trial] reduce 8 - EXTERN reduce 8 - REGISTER reduce 8 - STATIC reduce 8 - CONST reduce 8 - VOLATILE reduce 8 - CLCL reduce 8 - ';' reduce 28 - ',' reduce 28 - '{' reduce 28 - - declarator_list goto 20 - declarator goto 21 - $$2 goto 22 - - -state 13 - decl_specs : decl_spec . (13) - - . reduce 13 - - -state 14 - decl_spec : typename . (18) - - . reduce 18 - - -state 15 - decl_spec : cv_qual . (17) - - . reduce 17 - - -state 16 - opt_scope : opt_scope . ID CLCL (3) - typename : opt_scope . ID (4) - - ID shift 23 - . error - - -state 17 - declarator : '*' . cv_quals $$4 $$5 declarator (33) - cv_quals : . (15) - - . reduce 15 - - cv_quals goto 24 - - -state 18 - declarator : '(' . $$6 $$7 declarator ')' (32) - $$6 : . (30) - - . reduce 30 - - $$6 goto 25 - - -state 19 - declarator : ID . (29) - - . reduce 29 - - -state 20 - decl : decl_specs declarator_list . ';' (10) - declarator_list : declarator_list . ',' $$4 $$5 declarator (26) - - ';' shift 26 - ',' shift 27 - . error - - -state 21 - decl : decl_specs declarator . $$3 block_statement (12) - declarator_list : declarator . (27) - declarator : declarator . '[' $$4 expr ']' (34) - declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) - $$3 : . (11) - - '(' shift 28 - '[' shift 29 - ';' reduce 27 - ',' reduce 27 - '{' reduce 11 - - $$3 goto 30 - - -state 22 - decl_specs : decl_specs $$2 . decl_spec (14) - 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_spec goto 31 - typename goto 14 - cv_qual goto 15 - opt_scope goto 16 - - -23: shift/reduce conflict (shift 32, reduce 4) on CLCL -state 23 - opt_scope : opt_scope ID . CLCL (3) - typename : opt_scope ID . (4) - - CLCL [trial] shift 32 - '*' 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 24 - cv_quals : cv_quals . cv_qual (16) - declarator : '*' cv_quals . $$4 $$5 declarator (33) - $$4 : . (24) - - CONST shift 8 - VOLATILE shift 9 - '*' reduce 24 - '(' reduce 24 - '[' reduce 24 - ID reduce 24 - ';' reduce 24 - ',' reduce 24 - ')' reduce 24 - '{' reduce 24 - - cv_qual goto 33 - $$4 goto 34 - - -state 25 - declarator : '(' $$6 . $$7 declarator ')' (32) - $$7 : . (31) - - . reduce 31 - - $$7 goto 35 - - -state 26 - decl : decl_specs declarator_list ';' . (10) - - . reduce 10 - - -state 27 - declarator_list : declarator_list ',' . $$4 $$5 declarator (26) - $$4 : . (24) - - . reduce 24 - - $$4 goto 36 - - -state 28 - declarator : declarator '(' . $$4 formal_arg_list ')' cv_quals (35) - $$4 : . (24) - - . reduce 24 - - $$4 goto 37 - - -state 29 - declarator : declarator '[' . $$4 expr ']' (34) - $$4 : . (24) - - . reduce 24 - - $$4 goto 38 - - -state 30 - decl : decl_specs declarator $$3 . block_statement (12) - - '{' shift 39 - . error - - block_statement goto 40 - - -state 31 - decl_specs : decl_specs $$2 decl_spec . (14) - - . reduce 14 - - -state 32 - opt_scope : opt_scope ID CLCL . (3) - - . reduce 3 - - -state 33 - cv_quals : cv_quals cv_qual . (16) - - . reduce 16 - - -state 34 - declarator : '*' cv_quals $$4 . $$5 declarator (33) - $$5 : . (25) - - . reduce 25 - - $$5 goto 41 - - -35: shift/reduce conflict (shift 18, reduce 28) on '(' -state 35 - declarator : '(' $$6 $$7 . declarator ')' (32) - declarator : . (28) - - '*' shift 17 - '(' [trial] shift 18 - ID shift 19 - '(' [trial] reduce 28 - '[' reduce 28 - ')' reduce 28 - - declarator goto 42 - - -state 36 - declarator_list : declarator_list ',' $$4 . $$5 declarator (26) - $$5 : . (25) - - . reduce 25 - - $$5 goto 43 - - -state 37 - declarator : declarator '(' $$4 . formal_arg_list ')' cv_quals (35) - opt_scope : . (1) - formal_arg_list : . (36) - - EXTERN shift 5 - REGISTER shift 6 - STATIC shift 7 - CONST shift 8 - VOLATILE shift 9 - CLCL shift 10 - ID reduce 1 - ')' reduce 36 - - formal_arg goto 44 - decl_specs goto 45 - decl_spec goto 13 - typename goto 14 - cv_qual goto 15 - opt_scope goto 16 - formal_arg_list goto 46 - nonempty_formal_arg_list goto 47 - - -state 38 - declarator : declarator '[' $$4 . expr ']' (34) - - '*' shift 48 - ID shift 49 - CONSTANT shift 50 - . error - - expr goto 51 - - -state 39 - block_statement : '{' . $$2 statement_list '}' (59) - $$2 : . (8) - - . reduce 8 - - $$2 goto 52 - - -state 40 - decl : decl_specs declarator $$3 block_statement . (12) - - . reduce 12 - - -41: shift/reduce conflict (shift 18, reduce 28) on '(' -state 41 - declarator : '*' cv_quals $$4 $$5 . declarator (33) - declarator : . (28) - - '*' shift 17 - '(' [trial] shift 18 - ID shift 19 - '(' [trial] reduce 28 - '[' reduce 28 - ';' reduce 28 - ',' reduce 28 - ')' reduce 28 - '{' reduce 28 - - declarator goto 53 - - -state 42 - declarator : '(' $$6 $$7 declarator . ')' (32) - declarator : declarator . '[' $$4 expr ']' (34) - declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) - - '(' shift 28 - '[' shift 29 - ')' shift 54 - . error - - -43: shift/reduce conflict (shift 18, reduce 28) on '(' -state 43 - declarator_list : declarator_list ',' $$4 $$5 . declarator (26) - declarator : . (28) - - '*' shift 17 - '(' [trial] shift 18 - ID shift 19 - '(' [trial] reduce 28 - '[' reduce 28 - ';' reduce 28 - ',' reduce 28 - - declarator goto 55 - - -state 44 - nonempty_formal_arg_list : formal_arg . (39) - - . reduce 39 - - -45: shift/reduce conflict (shift 18, reduce 28) on '(' -45: shift/reduce conflict (shift 19, reduce 8) on ID -state 45 - decl_specs : decl_specs . $$2 decl_spec (14) - formal_arg : decl_specs . declarator (40) - $$2 : . (8) - declarator : . (28) - - '*' shift 17 - '(' [trial] shift 18 - ID [trial] shift 19 - '(' [trial] reduce 28 - '[' reduce 28 - ID [trial] reduce 8 - EXTERN reduce 8 - REGISTER reduce 8 - STATIC reduce 8 - CONST reduce 8 - VOLATILE reduce 8 - CLCL reduce 8 - ',' reduce 28 - ')' reduce 28 - - declarator goto 56 - $$2 goto 22 - - -state 46 - declarator : declarator '(' $$4 formal_arg_list . ')' cv_quals (35) - - ')' shift 57 - . error - - -state 47 - formal_arg_list : nonempty_formal_arg_list . (37) - nonempty_formal_arg_list : nonempty_formal_arg_list . ',' $$6 formal_arg (38) - - ',' shift 58 - ')' reduce 37 - - -state 48 - expr : '*' . $$2 expr (46) - $$2 : . (8) - - . reduce 8 - - $$2 goto 59 - - -state 49 - expr : ID . (47) - - . reduce 47 - - -state 50 - expr : CONSTANT . (48) - - . reduce 48 - - -state 51 - declarator : declarator '[' $$4 expr . ']' (34) - expr : expr . '+' $$6 expr (41) - expr : expr . '-' $$6 expr (42) - expr : expr . '*' $$6 expr (43) - expr : expr . '%' $$6 expr (44) - expr : expr . '/' $$6 expr (45) - - '+' shift 60 - '-' shift 61 - '*' shift 62 - '/' shift 63 - '%' shift 64 - ']' shift 65 - . error - - -state 52 - block_statement : '{' $$2 . statement_list '}' (59) - statement_list : . (57) - - . reduce 57 - - statement_list goto 66 - - -state 53 - declarator : '*' cv_quals $$4 $$5 declarator . (33) - declarator : declarator . '[' $$4 expr ']' (34) - declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) - - '(' shift 28 - '[' shift 29 - ';' reduce 33 - ',' reduce 33 - ')' reduce 33 - '{' reduce 33 - - -state 54 - declarator : '(' $$6 $$7 declarator ')' . (32) - - . reduce 32 - - -state 55 - declarator_list : declarator_list ',' $$4 $$5 declarator . (26) - declarator : declarator . '[' $$4 expr ']' (34) - declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) - - '(' shift 28 - '[' shift 29 - ';' reduce 26 - ',' reduce 26 - - -state 56 - declarator : declarator . '[' $$4 expr ']' (34) - declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) - formal_arg : decl_specs declarator . (40) - - '(' shift 28 - '[' shift 29 - ',' reduce 40 - ')' reduce 40 - - -state 57 - declarator : declarator '(' $$4 formal_arg_list ')' . cv_quals (35) - cv_quals : . (15) - - . reduce 15 - - cv_quals goto 67 - - -state 58 - nonempty_formal_arg_list : nonempty_formal_arg_list ',' . $$6 formal_arg (38) - $$6 : . (30) - - . reduce 30 - - $$6 goto 68 - - -state 59 - expr : '*' $$2 . expr (46) - - '*' shift 48 - ID shift 49 - CONSTANT shift 50 - . error - - expr goto 69 - - -state 60 - expr : expr '+' . $$6 expr (41) - $$6 : . (30) - - . reduce 30 - - $$6 goto 70 - - -state 61 - expr : expr '-' . $$6 expr (42) - $$6 : . (30) - - . reduce 30 - - $$6 goto 71 - - -state 62 - expr : expr '*' . $$6 expr (43) - $$6 : . (30) - - . reduce 30 - - $$6 goto 72 - - -state 63 - expr : expr '/' . $$6 expr (45) - $$6 : . (30) - - . reduce 30 - - $$6 goto 73 - - -state 64 - expr : expr '%' . $$6 expr (44) - $$6 : . (30) - - . reduce 30 - - $$6 goto 74 - - -state 65 - declarator : declarator '[' $$4 expr ']' . (34) - - . reduce 34 - - -state 66 - statement_list : statement_list . $$2 statement (58) - block_statement : '{' $$2 statement_list . '}' (59) - $$2 : . (8) - - '}' shift 75 - '*' 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 76 - - -state 67 - cv_quals : cv_quals . cv_qual (16) - declarator : declarator '(' $$4 formal_arg_list ')' cv_quals . (35) - - CONST shift 8 - VOLATILE shift 9 - '(' reduce 35 - '[' reduce 35 - ';' reduce 35 - ',' reduce 35 - ')' reduce 35 - '{' reduce 35 - - cv_qual goto 33 - - -state 68 - nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 . formal_arg (38) - 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 77 - decl_specs goto 45 - decl_spec goto 13 - typename goto 14 - cv_qual goto 15 - opt_scope goto 16 - - -state 69 - expr : expr . '+' $$6 expr (41) - expr : expr . '-' $$6 expr (42) - expr : expr . '*' $$6 expr (43) - expr : expr . '%' $$6 expr (44) - expr : expr . '/' $$6 expr (45) - expr : '*' $$2 expr . (46) - - . reduce 46 - - -state 70 - expr : expr '+' $$6 . expr (41) - - '*' shift 48 - ID shift 49 - CONSTANT shift 50 - . error - - expr goto 78 - - -state 71 - expr : expr '-' $$6 . expr (42) - - '*' shift 48 - ID shift 49 - CONSTANT shift 50 - . error - - expr goto 79 - - -state 72 - expr : expr '*' $$6 . expr (43) - - '*' shift 48 - ID shift 49 - CONSTANT shift 50 - . error - - expr goto 80 - - -state 73 - expr : expr '/' $$6 . expr (45) - - '*' shift 48 - ID shift 49 - CONSTANT shift 50 - . error - - expr goto 81 - - -state 74 - expr : expr '%' $$6 . expr (44) - - '*' shift 48 - ID shift 49 - CONSTANT shift 50 - . error - - expr goto 82 - - -state 75 - block_statement : '{' $$2 statement_list '}' . (59) - - . reduce 59 - - -76: shift/reduce conflict (shift 49, reduce 1) on ID -state 76 - statement_list : statement_list $$2 . statement (58) - opt_scope : . (1) - $$10 : . (55) - - '*' shift 48 - ID [trial] shift 49 - CONSTANT shift 50 - EXTERN shift 5 - REGISTER shift 6 - STATIC shift 7 - CONST shift 8 - VOLATILE shift 9 - IF shift 83 - CLCL shift 10 - ID [trial] reduce 1 - '{' reduce 55 - - expr goto 84 - decl goto 85 - statement goto 86 - decl_specs goto 12 - decl_spec goto 13 - typename goto 14 - cv_qual goto 15 - opt_scope goto 16 - $$10 goto 87 - - -state 77 - nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg . (38) - - . reduce 38 - - -state 78 - expr : expr . '+' $$6 expr (41) - expr : expr '+' $$6 expr . (41) - expr : expr . '-' $$6 expr (42) - expr : expr . '*' $$6 expr (43) - expr : expr . '%' $$6 expr (44) - expr : expr . '/' $$6 expr (45) - - '*' shift 62 - '/' shift 63 - '%' shift 64 - '+' reduce 41 - '-' reduce 41 - ';' reduce 41 - ')' reduce 41 - ']' reduce 41 - - -state 79 - expr : expr . '+' $$6 expr (41) - expr : expr . '-' $$6 expr (42) - expr : expr '-' $$6 expr . (42) - expr : expr . '*' $$6 expr (43) - expr : expr . '%' $$6 expr (44) - expr : expr . '/' $$6 expr (45) - - '*' shift 62 - '/' shift 63 - '%' shift 64 - '+' reduce 42 - '-' reduce 42 - ';' reduce 42 - ')' reduce 42 - ']' reduce 42 - - -state 80 - expr : expr . '+' $$6 expr (41) - expr : expr . '-' $$6 expr (42) - expr : expr . '*' $$6 expr (43) - expr : expr '*' $$6 expr . (43) - expr : expr . '%' $$6 expr (44) - expr : expr . '/' $$6 expr (45) - - . reduce 43 - - -state 81 - expr : expr . '+' $$6 expr (41) - expr : expr . '-' $$6 expr (42) - expr : expr . '*' $$6 expr (43) - expr : expr . '%' $$6 expr (44) - expr : expr . '/' $$6 expr (45) - expr : expr '/' $$6 expr . (45) - - . reduce 45 - - -state 82 - expr : expr . '+' $$6 expr (41) - expr : expr . '-' $$6 expr (42) - expr : expr . '*' $$6 expr (43) - expr : expr . '%' $$6 expr (44) - expr : expr '%' $$6 expr . (44) - expr : expr . '/' $$6 expr (45) - - . reduce 44 - - -state 83 - statement : IF . '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement (53) - statement : IF . '(' $$6 expr ')' THEN $$8 statement (54) - - '(' shift 88 - . error - - -state 84 - expr : expr . '+' $$6 expr (41) - expr : expr . '-' $$6 expr (42) - expr : expr . '*' $$6 expr (43) - expr : expr . '%' $$6 expr (44) - expr : expr . '/' $$6 expr (45) - statement : expr . ';' (50) - - '+' shift 60 - '-' shift 61 - '*' shift 62 - '/' shift 63 - '%' shift 64 - ';' shift 89 - . error - - -state 85 - statement : decl . (49) - - . reduce 49 - - -state 86 - statement_list : statement_list $$2 statement . (58) - - . reduce 58 - - -state 87 - statement : $$10 . block_statement (56) - - '{' shift 39 - . error - - block_statement goto 90 - - -state 88 - statement : IF '(' . $$6 expr ')' THEN $$8 statement ELSE $$9 statement (53) - statement : IF '(' . $$6 expr ')' THEN $$8 statement (54) - $$6 : . (30) - - . reduce 30 - - $$6 goto 91 - - -state 89 - statement : expr ';' . (50) - - . reduce 50 - - -state 90 - statement : $$10 block_statement . (56) - - . reduce 56 - - -state 91 - statement : IF '(' $$6 . expr ')' THEN $$8 statement ELSE $$9 statement (53) - statement : IF '(' $$6 . expr ')' THEN $$8 statement (54) - - '*' shift 48 - ID shift 49 - CONSTANT shift 50 - . error - - expr goto 92 - - -state 92 - expr : expr . '+' $$6 expr (41) - expr : expr . '-' $$6 expr (42) - expr : expr . '*' $$6 expr (43) - expr : expr . '%' $$6 expr (44) - expr : expr . '/' $$6 expr (45) - statement : IF '(' $$6 expr . ')' THEN $$8 statement ELSE $$9 statement (53) - statement : IF '(' $$6 expr . ')' THEN $$8 statement (54) - - '+' shift 60 - '-' shift 61 - '*' shift 62 - '/' shift 63 - '%' shift 64 - ')' shift 93 - . error - - -state 93 - statement : IF '(' $$6 expr ')' . THEN $$8 statement ELSE $$9 statement (53) - statement : IF '(' $$6 expr ')' . THEN $$8 statement (54) - - THEN shift 94 - . error - - -state 94 - statement : IF '(' $$6 expr ')' THEN . $$8 statement ELSE $$9 statement (53) - statement : IF '(' $$6 expr ')' THEN . $$8 statement (54) - $$8 : . (51) - - . reduce 51 - - $$8 goto 95 - - -95: shift/reduce conflict (shift 49, reduce 1) on ID -state 95 - statement : IF '(' $$6 expr ')' THEN $$8 . statement ELSE $$9 statement (53) - statement : IF '(' $$6 expr ')' THEN $$8 . statement (54) - opt_scope : . (1) - $$10 : . (55) - - '*' shift 48 - ID [trial] shift 49 - CONSTANT shift 50 - EXTERN shift 5 - REGISTER shift 6 - STATIC shift 7 - CONST shift 8 - VOLATILE shift 9 - IF shift 83 - CLCL shift 10 - ID [trial] reduce 1 - '{' reduce 55 - - expr goto 84 - decl goto 85 - statement goto 96 - decl_specs goto 12 - decl_spec goto 13 - typename goto 14 - cv_qual goto 15 - opt_scope goto 16 - $$10 goto 87 - - -96: shift/reduce conflict (shift 97, reduce 54) on ELSE -state 96 - statement : IF '(' $$6 expr ')' THEN $$8 statement . ELSE $$9 statement (53) - statement : IF '(' $$6 expr ')' THEN $$8 statement . (54) - - ELSE [trial] shift 97 - '*' reduce 54 - ID reduce 54 - CONSTANT reduce 54 - EXTERN reduce 54 - REGISTER reduce 54 - STATIC reduce 54 - CONST reduce 54 - VOLATILE reduce 54 - IF reduce 54 - ELSE [trial] reduce 54 - CLCL reduce 54 - '{' reduce 54 - '}' reduce 54 - - -state 97 - statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE . $$9 statement (53) - $$9 : . (52) - - . reduce 52 - - $$9 goto 98 - - -98: shift/reduce conflict (shift 49, reduce 1) on ID -state 98 - statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 . statement (53) - opt_scope : . (1) - $$10 : . (55) - - '*' shift 48 - ID [trial] shift 49 - CONSTANT shift 50 - EXTERN shift 5 - REGISTER shift 6 - STATIC shift 7 - CONST shift 8 - VOLATILE shift 9 - IF shift 83 - CLCL shift 10 - ID [trial] reduce 1 - '{' reduce 55 - - expr goto 84 - decl goto 85 - statement goto 99 - decl_specs goto 12 - decl_spec goto 13 - typename goto 14 - cv_qual goto 15 - opt_scope goto 16 - $$10 goto 87 - - -state 99 - statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement . (53) - - . reduce 53 - - -State 12 contains 2 shift/reduce conflicts. -State 23 contains 1 shift/reduce conflict. -State 35 contains 1 shift/reduce conflict. -State 41 contains 1 shift/reduce conflict. -State 43 contains 1 shift/reduce conflict. -State 45 contains 2 shift/reduce conflicts. -State 76 contains 1 shift/reduce conflict. -State 95 contains 1 shift/reduce conflict. -State 96 contains 1 shift/reduce conflict. -State 98 contains 1 shift/reduce conflict. - - -29 terminals, 29 nonterminals -60 grammar rules, 100 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 diff --git a/test/btyacc/btyacc_demo.tab.c b/test/btyacc/btyacc_demo.tab.c deleted file mode 100644 index 6b346f27cea..00000000000 --- a/test/btyacc/btyacc_demo.tab.c +++ /dev/null @@ -1,2400 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 36 "btyacc_demo.y" -typedef union YYSTYPE { - 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; - unsigned source; -} YYLTYPE; -#define YYLTYPE_IS_DECLARED 1 -#endif -#define YYRHSLOC(rhs, k) ((rhs)[k]) - -/* 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 int YYINT; -static const YYINT demo_lhs[] = { -1, - 15, 15, 15, 12, 18, 0, 4, 19, 4, 2, - 20, 2, 10, 10, 13, 13, 11, 11, 11, 11, - 11, 14, 14, 21, 22, 3, 3, 8, 8, 23, - 24, 8, 8, 8, 8, 16, 16, 17, 17, 9, - 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, - 25, 26, 5, 5, 27, 5, 6, 6, 7, -}; -static const YYINT demo_len[] = { 2, - 0, 1, 3, 2, 0, 2, 0, 0, 3, 3, - 0, 4, 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, 2, - 4, 4, 4, 4, 4, 3, 1, 1, 1, 2, - 0, 0, 11, 8, 0, 2, 0, 3, 4, -}; -static const YYINT demo_defred[] = { 5, - 0, 7, 0, 0, 19, 20, 21, 22, 23, 2, - 9, 0, 13, 18, 17, 0, 15, 30, 29, 0, - 0, 0, 0, 0, 31, 10, 24, 24, 24, 0, - 14, 3, 16, 25, 0, 25, 0, 0, 8, 12, - 0, 0, 0, 39, 0, 0, 0, 8, 47, 48, - 0, 57, 0, 32, 0, 0, 15, 30, 0, 30, - 30, 30, 30, 30, 34, 0, 0, 0, 46, 0, - 0, 0, 0, 0, 59, 0, 38, 0, 0, 43, - 45, 44, 0, 0, 49, 58, 0, 30, 50, 56, - 0, 0, 0, 51, 0, 0, 52, 0, 53, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT demo_stos[] = { 0, - 271, 289, 275, 290, 261, 262, 263, 264, 265, 269, - 273, 281, 282, 283, 285, 286, 42, 40, 259, 274, - 279, 290, 259, 284, 294, 59, 44, 40, 91, 291, - 282, 269, 285, 292, 295, 292, 292, 292, 123, 278, - 293, 279, 293, 280, 281, 287, 288, 42, 259, 260, - 272, 290, 279, 41, 279, 279, 41, 44, 290, 43, - 45, 42, 47, 37, 93, 277, 284, 294, 272, 294, - 294, 294, 294, 294, 125, 290, 280, 272, 272, 272, - 272, 272, 266, 272, 273, 276, 298, 40, 59, 278, - 294, 272, 41, 267, 296, 276, 268, 297, 276, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT demo_dgoto[] = { 1, - 84, 85, 20, 3, 86, 66, 40, 21, 44, 12, - 13, 14, 24, 15, 16, 46, 47, 2, 22, 30, - 34, 41, 25, 35, 95, 98, 87, -}; -static const YYINT demo_sindex[] = { 0, - 0, 0, 0, -103, 0, 0, 0, 0, 0, 0, - 0, -31, 0, 0, 0, -238, 0, 0, 0, 4, - -36, -103, 0, -133, 0, 0, 0, 0, 0, -94, - 0, 0, 0, 0, -40, 0, -103, -33, 0, 0, - -40, -25, -40, 0, -31, 8, 15, 0, 0, 0, - -2, 0, -36, 0, -36, -36, 0, 0, -33, 0, - 0, 0, 0, 0, 0, -92, -133, -103, 0, -33, - -33, -33, -33, -33, 0, -8, 0, 23, 23, 0, - 0, 0, 11, 75, 0, 0, -94, 0, 0, 0, - -33, 96, -194, 0, -8, 0, 0, -8, 0, -}; -static const YYINT demo_rindex[] = { 0, - 0, 0, 1, -181, 0, 0, 0, 0, 0, 0, - 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, - -39, -181, 12, -34, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -5, 0, -11, 0, 0, 0, - -17, 0, 28, 0, -41, 0, 47, 0, 0, 0, - 0, 0, -13, 0, 18, 70, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -19, -27, -181, 0, 0, - 0, 0, 0, 0, 0, -29, 0, 56, 64, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -29, -30, 0, -29, 0, -}; -#if YYBTYACC -static const YYINT demo_cindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -22, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -179, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, - 58, 0, 62, 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, -146, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -143, -147, 0, -134, 0, -}; -#endif -static const YYINT demo_gindex[] = { 0, - 9, 143, 0, 0, 50, 0, 63, 101, 83, 7, - 130, 0, 98, 2, 0, 0, 0, 0, 19, 0, - 10, 117, 66, 0, 0, 0, 0, -}; -#define YYTABLESIZE 286 -static const YYINT demo_table[] = { 28, - 6, 17, 28, 28, 27, 24, 24, 24, 48, 24, - 17, 54, 35, 35, 28, 54, 35, 0, 0, 27, - 23, 4, 8, 28, 24, 33, 28, 33, 39, 36, - 33, 35, 75, 48, 64, 28, 36, 37, 38, 62, - 60, 28, 61, 45, 63, 33, 51, 27, 57, 28, - 88, 4, 4, 4, 29, 4, 24, 52, 58, 64, - 28, 26, 26, 35, 62, 29, 59, 69, 33, 63, - 4, 28, 94, 28, 45, 28, 26, 1, 78, 79, - 80, 81, 82, 11, 76, 28, 28, 37, 24, 6, - 65, 0, 54, 55, 54, 35, 41, 0, 41, 92, - 41, 0, 4, 8, 42, 28, 42, 28, 42, 33, - 40, 64, 9, 40, 41, 9, 62, 60, 28, 61, - 12, 63, 42, 68, 9, 70, 71, 72, 73, 74, - 8, 9, 64, 89, 4, 42, 93, 62, 60, 28, - 61, 53, 63, 55, 96, 56, 11, 99, 41, 90, - 77, 31, 43, 91, 67, 0, 42, 5, 6, 7, - 8, 9, 0, 0, 0, 10, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 19, 8, - 8, 8, 8, 8, 24, 49, 50, 8, 54, 54, - 54, 54, 54, 54, 54, 54, 3, 3, 54, 8, - 8, 8, 8, 8, 8, 8, 8, 1, 0, 8, - 0, 50, 5, 6, 7, 8, 9, 83, 0, 8, - 10, 8, 8, 8, 8, 8, 0, 0, 0, 8, - 4, 0, 4, 4, 4, 4, 4, 8, 8, 8, - 8, 8, 0, 0, 0, 8, -}; -static const YYINT demo_check[] = { 41, - 0, 42, 44, 40, 44, 40, 41, 42, 42, 44, - 42, 42, 40, 41, 40, 41, 44, 40, 40, 59, - 259, 3, 42, 41, 59, 24, 44, 41, 123, 41, - 44, 59, 125, 42, 37, 41, 27, 28, 29, 42, - 43, 59, 45, 37, 47, 59, 38, 44, 41, 91, - 40, 40, 41, 42, 91, 44, 91, 39, 44, 37, - 44, 44, 59, 91, 42, 91, 48, 59, 67, 47, - 59, 44, 267, 91, 68, 59, 59, 259, 70, 71, - 72, 73, 74, 123, 66, 91, 59, 41, 123, 269, - 93, 40, 123, 123, 125, 123, 41, 40, 43, 91, - 45, 40, 91, 123, 41, 123, 43, 91, 45, 123, - 41, 37, 259, 44, 59, 259, 42, 43, 91, 45, - 268, 47, 59, 58, 259, 60, 61, 62, 63, 64, - 264, 265, 37, 59, 123, 35, 41, 42, 43, 123, - 45, 41, 47, 43, 95, 45, 4, 98, 93, 87, - 68, 22, 36, 88, 57, -1, 93, 261, 262, 263, - 264, 265, -1, -1, -1, 269, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -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, 261, - 262, 263, 264, 265, 259, 259, 260, 269, 259, 260, - 261, 262, 263, 264, 265, 266, 259, 259, 269, 259, - 260, 261, 262, 263, 264, 265, 266, 259, -1, 269, - -1, 260, 261, 262, 263, 264, 265, 266, -1, 259, - 269, 261, 262, 263, 264, 265, -1, -1, -1, 269, - 259, -1, 261, 262, 263, 264, 265, 261, 262, 263, - 264, 265, -1, -1, -1, 269, -}; -#if YYBTYACC -static const YYINT demo_ctable[] = { 18, - 28, -1, 19, 8, -1, 32, 4, -1, 49, 1, - -1, 97, 54, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 269 -#define YYUNDFTOKEN 299 -#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","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", -"decl : decl_specs declarator_list ';'", -"$$3 :", -"decl : decl_specs declarator $$3 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", -"$$4 :", -"$$5 :", -"declarator_list : declarator_list ',' $$4 $$5 declarator", -"declarator_list : declarator", -"declarator :", -"declarator : ID", -"$$6 :", -"$$7 :", -"declarator : '(' $$6 $$7 declarator ')'", -"declarator : '*' cv_quals $$4 $$5 declarator", -"declarator : declarator '[' $$4 expr ']'", -"declarator : declarator '(' $$4 formal_arg_list ')' cv_quals", -"formal_arg_list :", -"formal_arg_list : nonempty_formal_arg_list", -"nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg", -"nonempty_formal_arg_list : formal_arg", -"formal_arg : decl_specs declarator", -"expr : expr '+' $$6 expr", -"expr : expr '-' $$6 expr", -"expr : expr '*' $$6 expr", -"expr : expr '%' $$6 expr", -"expr : expr '/' $$6 expr", -"expr : '*' $$2 expr", -"expr : ID", -"expr : CONSTANT", -"statement : decl", -"statement : expr ';'", -"$$8 :", -"$$9 :", -"statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement", -"statement : IF '(' $$6 expr ')' THEN $$8 statement", -"$$10 :", -"statement : $$10 block_statement", -"statement_list :", -"statement_list : statement_list $$2 statement", -"block_statement : '{' $$2 statement_list '}'", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 667 "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 */ } -#line 683 "btyacc_demo.tab.c" - break; - 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 */ } -#line 692 "btyacc_demo.tab.c" - break; - 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 */ } -#line 701 "btyacc_demo.tab.c" - break; - 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 */ } -#line 710 "btyacc_demo.tab.c" - break; - 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 */ } -#line 719 "btyacc_demo.tab.c" - break; - 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 */ } -#line 728 "btyacc_demo.tab.c" - break; - 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 */ } -#line 737 "btyacc_demo.tab.c" - break; - 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 */ } -#line 746 "btyacc_demo.tab.c" - break; - 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 */ } -#line 755 "btyacc_demo.tab.c" - break; - 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 */ } -#line 764 "btyacc_demo.tab.c" - break; - 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); } -#line 773 "btyacc_demo.tab.c" - break; - 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); } -#line 782 "btyacc_demo.tab.c" - break; - 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 */ } -#line 791 "btyacc_demo.tab.c" - break; - 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 */ } -#line 800 "btyacc_demo.tab.c" - break; - 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 */ } -#line 809 "btyacc_demo.tab.c" - break; - 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 */ } -#line 818 "btyacc_demo.tab.c" - break; - 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 */ } -#line 827 "btyacc_demo.tab.c" - break; - 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 */ } -#line 836 "btyacc_demo.tab.c" - break; - 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 */ } -#line 845 "btyacc_demo.tab.c" - break; - 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 */ } -#line 854 "btyacc_demo.tab.c" - break; - 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 */ } -#line 863 "btyacc_demo.tab.c" - break; - 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 */ } -#line 872 "btyacc_demo.tab.c" - break; - 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 */ } -#line 881 "btyacc_demo.tab.c" - break; - 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 */ } -#line 890 "btyacc_demo.tab.c" - break; - 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 */ } -#line 899 "btyacc_demo.tab.c" - break; - 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 */ } -#line 908 "btyacc_demo.tab.c" - break; - 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 */ } -#line 917 "btyacc_demo.tab.c" - break; - 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 */ } -#line 926 "btyacc_demo.tab.c" - break; - 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 */ } -#line 935 "btyacc_demo.tab.c" - break; - 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); } -#line 944 "btyacc_demo.tab.c" - break; - 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); } -#line 954 "btyacc_demo.tab.c" - break; - 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 */ } -#line 963 "btyacc_demo.tab.c" - break; - 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 */ } -#line 972 "btyacc_demo.tab.c" - break; - 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); } -#line 981 "btyacc_demo.tab.c" - break; - 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); } -#line 990 "btyacc_demo.tab.c" - break; - 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); } -#line 999 "btyacc_demo.tab.c" - break; - 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); } -#line 1008 "btyacc_demo.tab.c" - break; - 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); } -#line 1017 "btyacc_demo.tab.c" - break; - 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); } -#line 1026 "btyacc_demo.tab.c" - break; - 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); } -#line 1035 "btyacc_demo.tab.c" - break; - 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); } -#line 1044 "btyacc_demo.tab.c" - break; - 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); } -#line 1053 "btyacc_demo.tab.c" - break; - 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); } -#line 1062 "btyacc_demo.tab.c" - break; - 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); } -#line 1071 "btyacc_demo.tab.c" - break; - 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); } -#line 1080 "btyacc_demo.tab.c" - break; - 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); } -#line 1089 "btyacc_demo.tab.c" - break; - 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); } -#line 1098 "btyacc_demo.tab.c" - break; - 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); } -#line 1107 "btyacc_demo.tab.c" - break; - 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).scope); } -#line 1116 "btyacc_demo.tab.c" - break; - 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); } -#line 1125 "btyacc_demo.tab.c" - break; - 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).type); } -#line 1134 "btyacc_demo.tab.c" - break; - 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).scope); } -#line 1143 "btyacc_demo.tab.c" - break; - 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).type); } -#line 1152 "btyacc_demo.tab.c" - break; - 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).scope); } -#line 1161 "btyacc_demo.tab.c" - break; - 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); } -#line 1170 "btyacc_demo.tab.c" - break; - 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); } -#line 1179 "btyacc_demo.tab.c" - break; - } -} -#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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: -#line 93 "btyacc_demo.y" -{ yyval.scope = yystack.l_mark[0].scope; } -#line 1857 "btyacc_demo.tab.c" -break; -case 2: -#line 94 "btyacc_demo.y" -{ yyval.scope = global_scope; } -#line 1862 "btyacc_demo.tab.c" -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; } -#line 1869 "btyacc_demo.tab.c" -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; } -#line 1876 "btyacc_demo.tab.c" -break; -case 5: -#line 106 "btyacc_demo.y" -yyval.scope = global_scope = new_scope(0); -#line 1881 "btyacc_demo.tab.c" -break; -case 8: -#line 107 "btyacc_demo.y" -yyval.scope = yystack.l_mark[-1].scope; -#line 1886 "btyacc_demo.tab.c" -break; -case 10: -#line 109 "btyacc_demo.y" -{YYVALID;} -#line 1891 "btyacc_demo.tab.c" -break; -case 11: -#line 110 "btyacc_demo.y" -yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl); -#line 1896 "btyacc_demo.tab.c" -break; -case 12: - 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[-3].first_line; - yyloc.first_column = yystack.p_mark[-3].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); } -#line 1908 "btyacc_demo.tab.c" -break; -case 13: -#line 121 "btyacc_demo.y" -{ yyval.type = yystack.l_mark[0].type; } -#line 1913 "btyacc_demo.tab.c" -break; -case 14: -#line 122 "btyacc_demo.y" -{ yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); } -#line 1918 "btyacc_demo.tab.c" -break; -case 15: -#line 125 "btyacc_demo.y" -{ yyval.type = 0; } -#line 1923 "btyacc_demo.tab.c" -break; -case 16: -#line 126 "btyacc_demo.y" -{ yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); } -#line 1928 "btyacc_demo.tab.c" -break; -case 17: -#line 130 "btyacc_demo.y" -{ yyval.type = yystack.l_mark[0].type; } -#line 1933 "btyacc_demo.tab.c" -break; -case 18: -#line 131 "btyacc_demo.y" -{ yyval.type = yystack.l_mark[0].type; } -#line 1938 "btyacc_demo.tab.c" -break; -case 19: -#line 132 "btyacc_demo.y" -{ yyval.type = bare_extern(); } -#line 1943 "btyacc_demo.tab.c" -break; -case 20: -#line 133 "btyacc_demo.y" -{ yyval.type = bare_register(); } -#line 1948 "btyacc_demo.tab.c" -break; -case 21: -#line 134 "btyacc_demo.y" -{ yyval.type = bare_static(); } -#line 1953 "btyacc_demo.tab.c" -break; -case 22: -#line 138 "btyacc_demo.y" -{ yyval.type = bare_const(); } -#line 1958 "btyacc_demo.tab.c" -break; -case 23: -#line 139 "btyacc_demo.y" -{ yyval.type = bare_volatile(); } -#line 1963 "btyacc_demo.tab.c" -break; -case 24: -#line 143 "btyacc_demo.y" -yyval.scope = yystack.l_mark[-3].scope; -#line 1968 "btyacc_demo.tab.c" -break; -case 25: -#line 143 "btyacc_demo.y" -yyval.type = yystack.l_mark[-3].type; -#line 1973 "btyacc_demo.tab.c" -break; -case 28: -#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); } -#line 1980 "btyacc_demo.tab.c" -break; -case 29: - 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); } -#line 1986 "btyacc_demo.tab.c" -break; -case 30: -#line 151 "btyacc_demo.y" -yyval.scope = yystack.l_mark[-2].scope; -#line 1991 "btyacc_demo.tab.c" -break; -case 31: -#line 151 "btyacc_demo.y" -yyval.type = yystack.l_mark[-2].type; -#line 1996 "btyacc_demo.tab.c" -break; -case 32: - if (!yytrial) -#line 151 "btyacc_demo.y" - { yyval.decl = yystack.l_mark[-1].decl; } -#line 2002 "btyacc_demo.tab.c" -break; -case 33: - if (!yytrial) -#line 153 "btyacc_demo.y" - { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); } -#line 2008 "btyacc_demo.tab.c" -break; -case 34: - if (!yytrial) -#line 155 "btyacc_demo.y" - { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); } -#line 2014 "btyacc_demo.tab.c" -break; -case 35: - 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); } -#line 2020 "btyacc_demo.tab.c" -break; -case 36: - if (!yytrial) -#line 160 "btyacc_demo.y" - { yyval.dlist = 0; } -#line 2026 "btyacc_demo.tab.c" -break; -case 37: - if (!yytrial) -#line 161 "btyacc_demo.y" - { yyval.dlist = yystack.l_mark[0].dlist; } -#line 2032 "btyacc_demo.tab.c" -break; -case 38: - if (!yytrial) -#line 164 "btyacc_demo.y" - { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); } -#line 2038 "btyacc_demo.tab.c" -break; -case 39: - if (!yytrial) -#line 165 "btyacc_demo.y" - { yyval.dlist = build_dlist(yystack.l_mark[0].decl); } -#line 2044 "btyacc_demo.tab.c" -break; -case 40: - if (!yytrial) -#line 168 "btyacc_demo.y" - { yyval.decl = yystack.l_mark[0].decl; } -#line 2050 "btyacc_demo.tab.c" -break; -case 41: - if (!yytrial) -#line 172 "btyacc_demo.y" - { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); } -#line 2056 "btyacc_demo.tab.c" -break; -case 42: - if (!yytrial) -#line 173 "btyacc_demo.y" - { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); } -#line 2062 "btyacc_demo.tab.c" -break; -case 43: - if (!yytrial) -#line 174 "btyacc_demo.y" - { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); } -#line 2068 "btyacc_demo.tab.c" -break; -case 44: - if (!yytrial) -#line 175 "btyacc_demo.y" - { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); } -#line 2074 "btyacc_demo.tab.c" -break; -case 45: - if (!yytrial) -#line 176 "btyacc_demo.y" - { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); } -#line 2080 "btyacc_demo.tab.c" -break; -case 46: - if (!yytrial) -#line 177 "btyacc_demo.y" - { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); } -#line 2086 "btyacc_demo.tab.c" -break; -case 47: - if (!yytrial) -#line 178 "btyacc_demo.y" - { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); } -#line 2092 "btyacc_demo.tab.c" -break; -case 48: - if (!yytrial) -#line 179 "btyacc_demo.y" - { yyval.expr = yystack.l_mark[0].expr; } -#line 2098 "btyacc_demo.tab.c" -break; -case 49: - if (!yytrial) -#line 183 "btyacc_demo.y" - { yyval.code = 0; } -#line 2104 "btyacc_demo.tab.c" -break; -case 50: -#line 184 "btyacc_demo.y" -{YYVALID;} if (!yytrial) -#line 184 "btyacc_demo.y" -{ yyval.code = build_expr_code(yystack.l_mark[-1].expr); } -#line 2111 "btyacc_demo.tab.c" -break; -case 51: -#line 185 "btyacc_demo.y" -yyval.scope = yystack.l_mark[-6].scope; -#line 2116 "btyacc_demo.tab.c" -break; -case 52: -#line 185 "btyacc_demo.y" -yyval.scope = yystack.l_mark[-9].scope; -#line 2121 "btyacc_demo.tab.c" -break; -case 53: -#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); } -#line 2128 "btyacc_demo.tab.c" -break; -case 54: -#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); } -#line 2135 "btyacc_demo.tab.c" -break; -case 55: -#line 189 "btyacc_demo.y" -yyval.scope = new_scope(yystack.l_mark[0].scope); -#line 2140 "btyacc_demo.tab.c" -break; -case 56: -#line 189 "btyacc_demo.y" -{YYVALID;} if (!yytrial) -#line 189 "btyacc_demo.y" -{ yyval.code = yystack.l_mark[0].code; } -#line 2147 "btyacc_demo.tab.c" -break; -case 57: - if (!yytrial) -#line 192 "btyacc_demo.y" - { yyval.code = 0; } -#line 2153 "btyacc_demo.tab.c" -break; -case 58: - if (!yytrial) -#line 193 "btyacc_demo.y" - { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); } -#line 2159 "btyacc_demo.tab.c" -break; -case 59: - if (!yytrial) -#line 197 "btyacc_demo.y" - { yyval.code = yystack.l_mark[-1].code; } -#line 2165 "btyacc_demo.tab.c" -break; -#line 2167 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/btyacc_demo.tab.h b/test/btyacc/btyacc_demo.tab.h deleted file mode 100644 index 082f5cdbfa9..00000000000 --- a/test/btyacc/btyacc_demo.tab.h +++ /dev/null @@ -1,51 +0,0 @@ -#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 YYSTYPE { - 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; - -#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; - unsigned source; -} YYLTYPE; -#define YYLTYPE_IS_DECLARED 1 -#endif -#define YYRHSLOC(rhs, k) ((rhs)[k]) -extern YYLTYPE demo_lloc; - -#endif /* _demo__defines_h_ */ diff --git a/test/btyacc/btyacc_destroy1.error b/test/btyacc/btyacc_destroy1.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/btyacc_destroy1.output b/test/btyacc/btyacc_destroy1.output deleted file mode 100644 index 918354cacb1..00000000000 --- a/test/btyacc/btyacc_destroy1.output +++ /dev/null @@ -1,247 +0,0 @@ - 0 $accept : declaration $end - - 1 declaration : class type namelist '(' class ',' type ')' - 2 | type locnamelist '(' class ')' - - 3 class : GLOBAL - 4 | LOCAL - - 5 type : REAL - 6 | INTEGER - - 7 namelist : namelist NAME - 8 | NAME - - 9 locnamelist : namelist '(' LOCAL ',' type ')' - -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 '(' class ',' type ')' (1) - - REAL shift 3 - INTEGER shift 4 - . error - - type goto 8 - - -state 7 - declaration : type . locnamelist '(' class ')' (2) - - NAME shift 9 - . error - - locnamelist goto 10 - namelist goto 11 - - -state 8 - declaration : class type . namelist '(' class ',' type ')' (1) - - NAME shift 9 - . error - - namelist goto 12 - - -state 9 - namelist : NAME . (8) - - . reduce 8 - - -state 10 - declaration : type locnamelist . '(' class ')' (2) - - '(' shift 13 - . error - - -state 11 - namelist : namelist . NAME (7) - locnamelist : namelist . '(' LOCAL ',' type ')' (9) - - NAME shift 14 - '(' shift 15 - . error - - -state 12 - declaration : class type namelist . '(' class ',' type ')' (1) - namelist : namelist . NAME (7) - - NAME shift 14 - '(' shift 16 - . error - - -state 13 - declaration : type locnamelist '(' . class ')' (2) - - GLOBAL shift 1 - LOCAL shift 2 - . error - - class goto 17 - - -state 14 - namelist : namelist NAME . (7) - - . reduce 7 - - -state 15 - locnamelist : namelist '(' . LOCAL ',' type ')' (9) - - LOCAL shift 18 - . error - - -state 16 - declaration : class type namelist '(' . class ',' type ')' (1) - - GLOBAL shift 1 - LOCAL shift 2 - . error - - class goto 19 - - -state 17 - declaration : type locnamelist '(' class . ')' (2) - - ')' shift 20 - . error - - -state 18 - locnamelist : namelist '(' LOCAL . ',' type ')' (9) - - ',' shift 21 - . error - - -state 19 - declaration : class type namelist '(' class . ',' type ')' (1) - - ',' shift 22 - . error - - -state 20 - declaration : type locnamelist '(' class ')' . (2) - - . reduce 2 - - -state 21 - locnamelist : namelist '(' LOCAL ',' . type ')' (9) - - REAL shift 3 - INTEGER shift 4 - . error - - type goto 23 - - -state 22 - declaration : class type namelist '(' class ',' . type ')' (1) - - REAL shift 3 - INTEGER shift 4 - . error - - type goto 24 - - -state 23 - locnamelist : namelist '(' LOCAL ',' type . ')' (9) - - ')' shift 25 - . error - - -state 24 - declaration : class type namelist '(' class ',' type . ')' (1) - - ')' shift 26 - . error - - -state 25 - locnamelist : namelist '(' LOCAL ',' type ')' . (9) - - . reduce 9 - - -state 26 - declaration : class type namelist '(' class ',' type ')' . (1) - - . reduce 1 - - -10 terminals, 6 nonterminals -10 grammar rules, 27 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 40 '(' - 8 44 ',' - 9 41 ')' - 10 262 $accept - 11 263 declaration - 12 264 locnamelist - 13 265 class - 14 266 type - 15 267 namelist diff --git a/test/btyacc/btyacc_destroy1.tab.c b/test/btyacc/btyacc_destroy1.tab.c deleted file mode 100644 index 6775aa3e498..00000000000 --- a/test/btyacc/btyacc_destroy1.tab.c +++ /dev/null @@ -1,1477 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 destroy1_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex destroy1_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror destroy1_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar destroy1_char -#endif /* yychar */ - -#ifndef yyval -#define yyval destroy1_val -#endif /* yyval */ - -#ifndef yylval -#define yylval destroy1_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug destroy1_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs destroy1_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag destroy1_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs destroy1_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen destroy1_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred destroy1_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos destroy1_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto destroy1_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex destroy1_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex destroy1_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex destroy1_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable destroy1_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck destroy1_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname destroy1_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule destroy1_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex destroy1_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable destroy1_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "destroy1_" - -#define YYPURE 0 - -#line 4 "btyacc_destroy1.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; - -struct parser_param { - int *rtrn; - symbol ss; -}; - -extern symbol *mksymbol(type t, class c, name id); - -#ifdef YYBISON -#define YYLEX_DECL() yylex(void) -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 50 "btyacc_destroy1.y" -typedef union YYSTYPE -{ - class cval; - type tval; - namelist * nlist; - name id; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -#line 160 "btyacc_destroy1.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(struct parser_param *param, int flag) -#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(struct parser_param *param, int flag, const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(param, flag, msg) -#endif - -#ifndef YYDESTRUCT_DECL -#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) -#endif -#ifndef YYDESTRUCT_CALL -#define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) -#endif - -extern int YYPARSE_DECL(); - -#define GLOBAL 257 -#define LOCAL 258 -#define REAL 259 -#define INTEGER 260 -#define NAME 261 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT destroy1_lhs[] = { -1, - 0, 0, 2, 2, 3, 3, 4, 4, 1, -}; -static const YYINT destroy1_len[] = { 2, - 8, 5, 1, 1, 1, 1, 2, 1, 6, -}; -static const YYINT destroy1_defred[] = { 0, - 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, - 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 9, 1, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT destroy1_stos[] = { 0, - 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, - 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, - 44, 44, 266, 266, 41, 41, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT destroy1_dgoto[] = { 5, - 10, 6, 7, 11, -}; -static const YYINT destroy1_sindex[] = { -254, - 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, - -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, - -251, -251, -22, -19, 0, 0, -}; -static const YYINT destroy1_rindex[] = { 0, - 0, 0, 0, 0, 0, 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 destroy1_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, -}; -#endif -static const YYINT destroy1_gindex[] = { 0, - 0, -6, -4, 15, -}; -#define YYTABLESIZE 222 -static const YYINT destroy1_table[] = { 15, - 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, - 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, - 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14, 14, -}; -static const YYINT destroy1_check[] = { 40, - 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, - 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, - 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 261, 261, -}; -#if YYBTYACC -static const YYINT destroy1_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -}; -#endif -#define YYFINAL 5 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 261 -#define YYUNDFTOKEN 268 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const destroy1_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","GLOBAL","LOCAL", -"REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", -"namelist","illegal-symbol", -}; -static const char *const destroy1_rule[] = { -"$accept : declaration", -"declaration : class type namelist '(' class ',' type ')'", -"declaration : type locnamelist '(' class ')'", -"class : GLOBAL", -"class : LOCAL", -"type : REAL", -"type : INTEGER", -"namelist : namelist NAME", -"namelist : NAME", -"locnamelist : namelist '(' LOCAL ',' type ')'", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 89 "btyacc_destroy1.y" - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); -#line 492 "btyacc_destroy1.tab.c" - -/* Release memory associated with symbol. */ -#if ! defined YYDESTRUCT_IS_DECLARED -static void -YYDESTRUCT_DECL() -{ - switch (psymb) - { - case 263: -#line 41 "btyacc_destroy1.y" - { - namelist *p = (*val).nlist; - while (p != NULL) - { namelist *pp = p; - p = p->next; - free(pp->s); free(pp); - } - } -#line 511 "btyacc_destroy1.tab.c" - break; - } -} -#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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: - if (!yytrial) -#line 62 "btyacc_destroy1.y" - { yyval.nlist = yystack.l_mark[-5].nlist; } -#line 1190 "btyacc_destroy1.tab.c" -break; -case 2: - if (!yytrial) -#line 64 "btyacc_destroy1.y" - { yyval.nlist = yystack.l_mark[-3].nlist; } -#line 1196 "btyacc_destroy1.tab.c" -break; -case 3: - if (!yytrial) -#line 67 "btyacc_destroy1.y" - { yyval.cval = cGLOBAL; } -#line 1202 "btyacc_destroy1.tab.c" -break; -case 4: - if (!yytrial) -#line 68 "btyacc_destroy1.y" - { yyval.cval = cLOCAL; } -#line 1208 "btyacc_destroy1.tab.c" -break; -case 5: - if (!yytrial) -#line 71 "btyacc_destroy1.y" - { yyval.tval = tREAL; } -#line 1214 "btyacc_destroy1.tab.c" -break; -case 6: - if (!yytrial) -#line 72 "btyacc_destroy1.y" - { yyval.tval = tINTEGER; } -#line 1220 "btyacc_destroy1.tab.c" -break; -case 7: - if (!yytrial) -#line 76 "btyacc_destroy1.y" - { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); - yyval.nlist->next = yystack.l_mark[-1].nlist; - } -#line 1228 "btyacc_destroy1.tab.c" -break; -case 8: - if (!yytrial) -#line 80 "btyacc_destroy1.y" - { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); - yyval.nlist->next = NULL; - } -#line 1236 "btyacc_destroy1.tab.c" -break; -case 9: - if (!yytrial) -#line 86 "btyacc_destroy1.y" - { yyval.nlist = yystack.l_mark[-5].nlist; } -#line 1242 "btyacc_destroy1.tab.c" -break; -#line 1244 "btyacc_destroy1.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/btyacc_destroy1.tab.h b/test/btyacc/btyacc_destroy1.tab.h deleted file mode 100644 index fd25e13b001..00000000000 --- a/test/btyacc/btyacc_destroy1.tab.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _destroy1__defines_h_ -#define _destroy1__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 YYSTYPE -{ - class cval; - type tval; - namelist * nlist; - name id; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE destroy1_lval; - -#endif /* _destroy1__defines_h_ */ diff --git a/test/btyacc/btyacc_destroy2.error b/test/btyacc/btyacc_destroy2.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/btyacc_destroy2.output b/test/btyacc/btyacc_destroy2.output deleted file mode 100644 index 918354cacb1..00000000000 --- a/test/btyacc/btyacc_destroy2.output +++ /dev/null @@ -1,247 +0,0 @@ - 0 $accept : declaration $end - - 1 declaration : class type namelist '(' class ',' type ')' - 2 | type locnamelist '(' class ')' - - 3 class : GLOBAL - 4 | LOCAL - - 5 type : REAL - 6 | INTEGER - - 7 namelist : namelist NAME - 8 | NAME - - 9 locnamelist : namelist '(' LOCAL ',' type ')' - -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 '(' class ',' type ')' (1) - - REAL shift 3 - INTEGER shift 4 - . error - - type goto 8 - - -state 7 - declaration : type . locnamelist '(' class ')' (2) - - NAME shift 9 - . error - - locnamelist goto 10 - namelist goto 11 - - -state 8 - declaration : class type . namelist '(' class ',' type ')' (1) - - NAME shift 9 - . error - - namelist goto 12 - - -state 9 - namelist : NAME . (8) - - . reduce 8 - - -state 10 - declaration : type locnamelist . '(' class ')' (2) - - '(' shift 13 - . error - - -state 11 - namelist : namelist . NAME (7) - locnamelist : namelist . '(' LOCAL ',' type ')' (9) - - NAME shift 14 - '(' shift 15 - . error - - -state 12 - declaration : class type namelist . '(' class ',' type ')' (1) - namelist : namelist . NAME (7) - - NAME shift 14 - '(' shift 16 - . error - - -state 13 - declaration : type locnamelist '(' . class ')' (2) - - GLOBAL shift 1 - LOCAL shift 2 - . error - - class goto 17 - - -state 14 - namelist : namelist NAME . (7) - - . reduce 7 - - -state 15 - locnamelist : namelist '(' . LOCAL ',' type ')' (9) - - LOCAL shift 18 - . error - - -state 16 - declaration : class type namelist '(' . class ',' type ')' (1) - - GLOBAL shift 1 - LOCAL shift 2 - . error - - class goto 19 - - -state 17 - declaration : type locnamelist '(' class . ')' (2) - - ')' shift 20 - . error - - -state 18 - locnamelist : namelist '(' LOCAL . ',' type ')' (9) - - ',' shift 21 - . error - - -state 19 - declaration : class type namelist '(' class . ',' type ')' (1) - - ',' shift 22 - . error - - -state 20 - declaration : type locnamelist '(' class ')' . (2) - - . reduce 2 - - -state 21 - locnamelist : namelist '(' LOCAL ',' . type ')' (9) - - REAL shift 3 - INTEGER shift 4 - . error - - type goto 23 - - -state 22 - declaration : class type namelist '(' class ',' . type ')' (1) - - REAL shift 3 - INTEGER shift 4 - . error - - type goto 24 - - -state 23 - locnamelist : namelist '(' LOCAL ',' type . ')' (9) - - ')' shift 25 - . error - - -state 24 - declaration : class type namelist '(' class ',' type . ')' (1) - - ')' shift 26 - . error - - -state 25 - locnamelist : namelist '(' LOCAL ',' type ')' . (9) - - . reduce 9 - - -state 26 - declaration : class type namelist '(' class ',' type ')' . (1) - - . reduce 1 - - -10 terminals, 6 nonterminals -10 grammar rules, 27 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 40 '(' - 8 44 ',' - 9 41 ')' - 10 262 $accept - 11 263 declaration - 12 264 locnamelist - 13 265 class - 14 266 type - 15 267 namelist diff --git a/test/btyacc/btyacc_destroy2.tab.c b/test/btyacc/btyacc_destroy2.tab.c deleted file mode 100644 index 8b7c153d213..00000000000 --- a/test/btyacc/btyacc_destroy2.tab.c +++ /dev/null @@ -1,1477 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 destroy2_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex destroy2_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror destroy2_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar destroy2_char -#endif /* yychar */ - -#ifndef yyval -#define yyval destroy2_val -#endif /* yyval */ - -#ifndef yylval -#define yylval destroy2_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug destroy2_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs destroy2_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag destroy2_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs destroy2_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen destroy2_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred destroy2_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos destroy2_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto destroy2_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex destroy2_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex destroy2_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex destroy2_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable destroy2_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck destroy2_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname destroy2_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule destroy2_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex destroy2_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable destroy2_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "destroy2_" - -#define YYPURE 0 - -#line 4 "btyacc_destroy2.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; - -struct parser_param { - int *rtrn; - symbol ss; -}; - -extern symbol *mksymbol(type t, class c, name id); - -#ifdef YYBISON -#define YYLEX_DECL() yylex(void) -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 50 "btyacc_destroy2.y" -typedef union YYSTYPE -{ - class cval; - type tval; - namelist * nlist; - name id; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -#line 160 "btyacc_destroy2.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(struct parser_param *param, int flag) -#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(struct parser_param *param, int flag, const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(param, flag, msg) -#endif - -#ifndef YYDESTRUCT_DECL -#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) -#endif -#ifndef YYDESTRUCT_CALL -#define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) -#endif - -extern int YYPARSE_DECL(); - -#define GLOBAL 257 -#define LOCAL 258 -#define REAL 259 -#define INTEGER 260 -#define NAME 261 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT destroy2_lhs[] = { -1, - 0, 0, 2, 2, 3, 3, 4, 4, 1, -}; -static const YYINT destroy2_len[] = { 2, - 8, 5, 1, 1, 1, 1, 2, 1, 6, -}; -static const YYINT destroy2_defred[] = { 0, - 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, - 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 9, 1, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT destroy2_stos[] = { 0, - 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, - 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, - 44, 44, 266, 266, 41, 41, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT destroy2_dgoto[] = { 5, - 10, 6, 7, 11, -}; -static const YYINT destroy2_sindex[] = { -254, - 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, - -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, - -251, -251, -22, -19, 0, 0, -}; -static const YYINT destroy2_rindex[] = { 0, - 0, 0, 0, 0, 0, 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 destroy2_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, -}; -#endif -static const YYINT destroy2_gindex[] = { 0, - 0, -6, -4, 15, -}; -#define YYTABLESIZE 222 -static const YYINT destroy2_table[] = { 15, - 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, - 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, - 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14, 14, -}; -static const YYINT destroy2_check[] = { 40, - 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, - 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, - 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 261, 261, -}; -#if YYBTYACC -static const YYINT destroy2_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -}; -#endif -#define YYFINAL 5 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 261 -#define YYUNDFTOKEN 268 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const destroy2_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","GLOBAL","LOCAL", -"REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", -"namelist","illegal-symbol", -}; -static const char *const destroy2_rule[] = { -"$accept : declaration", -"declaration : class type namelist '(' class ',' type ')'", -"declaration : type locnamelist '(' class ')'", -"class : GLOBAL", -"class : LOCAL", -"type : REAL", -"type : INTEGER", -"namelist : namelist NAME", -"namelist : NAME", -"locnamelist : namelist '(' LOCAL ',' type ')'", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 89 "btyacc_destroy2.y" - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); -#line 492 "btyacc_destroy2.tab.c" - -/* Release memory associated with symbol. */ -#if ! defined YYDESTRUCT_IS_DECLARED -static void -YYDESTRUCT_DECL() -{ - switch (psymb) - { - case 263: -#line 41 "btyacc_destroy2.y" - { - namelist *p = (*val).nlist; - while (p != NULL) - { namelist *pp = p; - p = p->next; - free(pp->s); free(pp); - } - } -#line 511 "btyacc_destroy2.tab.c" - break; - } -} -#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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: - if (!yytrial) -#line 62 "btyacc_destroy2.y" - { yyval.nlist = yystack.l_mark[-5].nlist; } -#line 1190 "btyacc_destroy2.tab.c" -break; -case 2: - if (!yytrial) -#line 64 "btyacc_destroy2.y" - { yyval.nlist = yystack.l_mark[-3].nlist; } -#line 1196 "btyacc_destroy2.tab.c" -break; -case 3: - if (!yytrial) -#line 67 "btyacc_destroy2.y" - { yyval.cval = cGLOBAL; } -#line 1202 "btyacc_destroy2.tab.c" -break; -case 4: - if (!yytrial) -#line 68 "btyacc_destroy2.y" - { yyval.cval = cLOCAL; } -#line 1208 "btyacc_destroy2.tab.c" -break; -case 5: - if (!yytrial) -#line 71 "btyacc_destroy2.y" - { yyval.tval = tREAL; } -#line 1214 "btyacc_destroy2.tab.c" -break; -case 6: - if (!yytrial) -#line 72 "btyacc_destroy2.y" - { yyval.tval = tINTEGER; } -#line 1220 "btyacc_destroy2.tab.c" -break; -case 7: - if (!yytrial) -#line 76 "btyacc_destroy2.y" - { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); - yyval.nlist->next = yystack.l_mark[-1].nlist; - } -#line 1228 "btyacc_destroy2.tab.c" -break; -case 8: - if (!yytrial) -#line 80 "btyacc_destroy2.y" - { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); - yyval.nlist->next = NULL; - } -#line 1236 "btyacc_destroy2.tab.c" -break; -case 9: - if (!yytrial) -#line 86 "btyacc_destroy2.y" - { yyval.nlist = yystack.l_mark[-5].nlist; } -#line 1242 "btyacc_destroy2.tab.c" -break; -#line 1244 "btyacc_destroy2.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/btyacc_destroy2.tab.h b/test/btyacc/btyacc_destroy2.tab.h deleted file mode 100644 index 5f59abdea12..00000000000 --- a/test/btyacc/btyacc_destroy2.tab.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _destroy2__defines_h_ -#define _destroy2__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 YYSTYPE -{ - class cval; - type tval; - namelist * nlist; - name id; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE destroy2_lval; - -#endif /* _destroy2__defines_h_ */ diff --git a/test/btyacc/btyacc_destroy3.error b/test/btyacc/btyacc_destroy3.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/btyacc_destroy3.output b/test/btyacc/btyacc_destroy3.output deleted file mode 100644 index 918354cacb1..00000000000 --- a/test/btyacc/btyacc_destroy3.output +++ /dev/null @@ -1,247 +0,0 @@ - 0 $accept : declaration $end - - 1 declaration : class type namelist '(' class ',' type ')' - 2 | type locnamelist '(' class ')' - - 3 class : GLOBAL - 4 | LOCAL - - 5 type : REAL - 6 | INTEGER - - 7 namelist : namelist NAME - 8 | NAME - - 9 locnamelist : namelist '(' LOCAL ',' type ')' - -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 '(' class ',' type ')' (1) - - REAL shift 3 - INTEGER shift 4 - . error - - type goto 8 - - -state 7 - declaration : type . locnamelist '(' class ')' (2) - - NAME shift 9 - . error - - locnamelist goto 10 - namelist goto 11 - - -state 8 - declaration : class type . namelist '(' class ',' type ')' (1) - - NAME shift 9 - . error - - namelist goto 12 - - -state 9 - namelist : NAME . (8) - - . reduce 8 - - -state 10 - declaration : type locnamelist . '(' class ')' (2) - - '(' shift 13 - . error - - -state 11 - namelist : namelist . NAME (7) - locnamelist : namelist . '(' LOCAL ',' type ')' (9) - - NAME shift 14 - '(' shift 15 - . error - - -state 12 - declaration : class type namelist . '(' class ',' type ')' (1) - namelist : namelist . NAME (7) - - NAME shift 14 - '(' shift 16 - . error - - -state 13 - declaration : type locnamelist '(' . class ')' (2) - - GLOBAL shift 1 - LOCAL shift 2 - . error - - class goto 17 - - -state 14 - namelist : namelist NAME . (7) - - . reduce 7 - - -state 15 - locnamelist : namelist '(' . LOCAL ',' type ')' (9) - - LOCAL shift 18 - . error - - -state 16 - declaration : class type namelist '(' . class ',' type ')' (1) - - GLOBAL shift 1 - LOCAL shift 2 - . error - - class goto 19 - - -state 17 - declaration : type locnamelist '(' class . ')' (2) - - ')' shift 20 - . error - - -state 18 - locnamelist : namelist '(' LOCAL . ',' type ')' (9) - - ',' shift 21 - . error - - -state 19 - declaration : class type namelist '(' class . ',' type ')' (1) - - ',' shift 22 - . error - - -state 20 - declaration : type locnamelist '(' class ')' . (2) - - . reduce 2 - - -state 21 - locnamelist : namelist '(' LOCAL ',' . type ')' (9) - - REAL shift 3 - INTEGER shift 4 - . error - - type goto 23 - - -state 22 - declaration : class type namelist '(' class ',' . type ')' (1) - - REAL shift 3 - INTEGER shift 4 - . error - - type goto 24 - - -state 23 - locnamelist : namelist '(' LOCAL ',' type . ')' (9) - - ')' shift 25 - . error - - -state 24 - declaration : class type namelist '(' class ',' type . ')' (1) - - ')' shift 26 - . error - - -state 25 - locnamelist : namelist '(' LOCAL ',' type ')' . (9) - - . reduce 9 - - -state 26 - declaration : class type namelist '(' class ',' type ')' . (1) - - . reduce 1 - - -10 terminals, 6 nonterminals -10 grammar rules, 27 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 40 '(' - 8 44 ',' - 9 41 ')' - 10 262 $accept - 11 263 declaration - 12 264 locnamelist - 13 265 class - 14 266 type - 15 267 namelist diff --git a/test/btyacc/btyacc_destroy3.tab.c b/test/btyacc/btyacc_destroy3.tab.c deleted file mode 100644 index 7cd56e7bb5b..00000000000 --- a/test/btyacc/btyacc_destroy3.tab.c +++ /dev/null @@ -1,1477 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 destroy3_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex destroy3_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror destroy3_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar destroy3_char -#endif /* yychar */ - -#ifndef yyval -#define yyval destroy3_val -#endif /* yyval */ - -#ifndef yylval -#define yylval destroy3_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug destroy3_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs destroy3_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag destroy3_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs destroy3_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen destroy3_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred destroy3_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos destroy3_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto destroy3_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex destroy3_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex destroy3_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex destroy3_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable destroy3_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck destroy3_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname destroy3_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule destroy3_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex destroy3_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable destroy3_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "destroy3_" - -#define YYPURE 0 - -#line 7 "btyacc_destroy3.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; - -struct parser_param { - int *rtrn; - symbol ss; -}; - -extern symbol *mksymbol(type t, class c, name id); - -#ifdef YYBISON -#define YYLEX_DECL() yylex(void) -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 53 "btyacc_destroy3.y" -typedef union YYSTYPE -{ - class cval; - type tval; - namelist * nlist; - name id; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -#line 160 "btyacc_destroy3.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(struct parser_param *param, int flag) -#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(struct parser_param *param, int flag, const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(param, flag, msg) -#endif - -#ifndef YYDESTRUCT_DECL -#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) -#endif -#ifndef YYDESTRUCT_CALL -#define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) -#endif - -extern int YYPARSE_DECL(); - -#define GLOBAL 257 -#define LOCAL 258 -#define REAL 259 -#define INTEGER 260 -#define NAME 261 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT destroy3_lhs[] = { -1, - 0, 0, 2, 2, 3, 3, 4, 4, 1, -}; -static const YYINT destroy3_len[] = { 2, - 8, 5, 1, 1, 1, 1, 2, 1, 6, -}; -static const YYINT destroy3_defred[] = { 0, - 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, - 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 9, 1, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT destroy3_stos[] = { 0, - 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, - 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, - 44, 44, 266, 266, 41, 41, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT destroy3_dgoto[] = { 5, - 10, 6, 7, 11, -}; -static const YYINT destroy3_sindex[] = { -254, - 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, - -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, - -251, -251, -22, -19, 0, 0, -}; -static const YYINT destroy3_rindex[] = { 0, - 0, 0, 0, 0, 0, 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 destroy3_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, -}; -#endif -static const YYINT destroy3_gindex[] = { 0, - 0, -6, -4, 15, -}; -#define YYTABLESIZE 222 -static const YYINT destroy3_table[] = { 15, - 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, - 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, - 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 14, 14, -}; -static const YYINT destroy3_check[] = { 40, - 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, - 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, - 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 261, 261, -}; -#if YYBTYACC -static const YYINT destroy3_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -}; -#endif -#define YYFINAL 5 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 261 -#define YYUNDFTOKEN 268 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const destroy3_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","GLOBAL","LOCAL", -"REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", -"namelist","illegal-symbol", -}; -static const char *const destroy3_rule[] = { -"$accept : declaration", -"declaration : class type namelist '(' class ',' type ')'", -"declaration : type locnamelist '(' class ')'", -"class : GLOBAL", -"class : LOCAL", -"type : REAL", -"type : INTEGER", -"namelist : namelist NAME", -"namelist : NAME", -"locnamelist : namelist '(' LOCAL ',' type ')'", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 92 "btyacc_destroy3.y" - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); -#line 492 "btyacc_destroy3.tab.c" - -/* Release memory associated with symbol. */ -#if ! defined YYDESTRUCT_IS_DECLARED -static void -YYDESTRUCT_DECL() -{ - switch (psymb) - { - case 263: -#line 44 "btyacc_destroy3.y" - { - namelist *p = (*val).nlist; - while (p != NULL) - { namelist *pp = p; - p = p->next; - free(pp->s); free(pp); - } - } -#line 511 "btyacc_destroy3.tab.c" - break; - } -} -#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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: - if (!yytrial) -#line 65 "btyacc_destroy3.y" - { yyval.nlist = yystack.l_mark[-5].nlist; } -#line 1190 "btyacc_destroy3.tab.c" -break; -case 2: - if (!yytrial) -#line 67 "btyacc_destroy3.y" - { yyval.nlist = yystack.l_mark[-3].nlist; } -#line 1196 "btyacc_destroy3.tab.c" -break; -case 3: - if (!yytrial) -#line 70 "btyacc_destroy3.y" - { yyval.cval = cGLOBAL; } -#line 1202 "btyacc_destroy3.tab.c" -break; -case 4: - if (!yytrial) -#line 71 "btyacc_destroy3.y" - { yyval.cval = cLOCAL; } -#line 1208 "btyacc_destroy3.tab.c" -break; -case 5: - if (!yytrial) -#line 74 "btyacc_destroy3.y" - { yyval.tval = tREAL; } -#line 1214 "btyacc_destroy3.tab.c" -break; -case 6: - if (!yytrial) -#line 75 "btyacc_destroy3.y" - { yyval.tval = tINTEGER; } -#line 1220 "btyacc_destroy3.tab.c" -break; -case 7: - if (!yytrial) -#line 79 "btyacc_destroy3.y" - { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); - yyval.nlist->next = yystack.l_mark[-1].nlist; - } -#line 1228 "btyacc_destroy3.tab.c" -break; -case 8: - if (!yytrial) -#line 83 "btyacc_destroy3.y" - { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); - yyval.nlist->next = NULL; - } -#line 1236 "btyacc_destroy3.tab.c" -break; -case 9: - if (!yytrial) -#line 89 "btyacc_destroy3.y" - { yyval.nlist = yystack.l_mark[-5].nlist; } -#line 1242 "btyacc_destroy3.tab.c" -break; -#line 1244 "btyacc_destroy3.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/btyacc_destroy3.tab.h b/test/btyacc/btyacc_destroy3.tab.h deleted file mode 100644 index 5a84568a6c0..00000000000 --- a/test/btyacc/btyacc_destroy3.tab.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _destroy3__defines_h_ -#define _destroy3__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 YYSTYPE -{ - class cval; - type tval; - namelist * nlist; - name id; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE destroy3_lval; - -#endif /* _destroy3__defines_h_ */ diff --git a/test/btyacc/calc.error b/test/btyacc/calc.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/calc.output b/test/btyacc/calc.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/calc.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/calc.tab.c b/test/btyacc/calc.tab.c deleted file mode 100644 index 89ecffad77d..00000000000 --- a/test/btyacc/calc.tab.c +++ /dev/null @@ -1,1489 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT calc_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 66 "calc.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 511 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 1184 "calc.tab.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1189 "calc.tab.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1194 "calc.tab.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 1199 "calc.tab.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1204 "calc.tab.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1209 "calc.tab.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1214 "calc.tab.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1219 "calc.tab.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1224 "calc.tab.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1229 "calc.tab.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1234 "calc.tab.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 1239 "calc.tab.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1244 "calc.tab.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1249 "calc.tab.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1254 "calc.tab.c" -break; -#line 1256 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc.tab.h b/test/btyacc/calc.tab.h deleted file mode 100644 index 48f8993b83f..00000000000 --- a/test/btyacc/calc.tab.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _calc__defines_h_ -#define _calc__defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _calc__defines_h_ */ diff --git a/test/btyacc/calc1.error b/test/btyacc/calc1.error deleted file mode 100644 index 9c1f7152c30..00000000000 --- a/test/btyacc/calc1.error +++ /dev/null @@ -1,2 +0,0 @@ -YACC: 2 rules never reduced -YACC: 18 shift/reduce conflicts, 26 reduce/reduce conflicts. diff --git a/test/btyacc/calc1.output b/test/btyacc/calc1.output deleted file mode 100644 index d6a869f6d35..00000000000 --- a/test/btyacc/calc1.output +++ /dev/null @@ -1,900 +0,0 @@ - 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/test/btyacc/calc1.tab.c b/test/btyacc/calc1.tab.c deleted file mode 100644 index 98394f988e9..00000000000 --- a/test/btyacc/calc1.tab.c +++ /dev/null @@ -1,1746 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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]; - -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 31 "calc1.y" -typedef union YYSTYPE -{ - 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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT calc1_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 655 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 57 "calc1.y" - { - (void) printf("%15.8f\n", yystack.l_mark[-1].dval); - } -#line 1330 "calc1.tab.c" -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); - } -#line 1337 "calc1.tab.c" -break; -case 5: -#line 65 "calc1.y" - { - dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; - } -#line 1344 "calc1.tab.c" -break; -case 6: -#line 69 "calc1.y" - { - vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; - } -#line 1351 "calc1.tab.c" -break; -case 7: -#line 73 "calc1.y" - { - yyerrok; - } -#line 1358 "calc1.tab.c" -break; -case 9: -#line 80 "calc1.y" - { - yyval.dval = dreg[yystack.l_mark[0].ival]; - } -#line 1365 "calc1.tab.c" -break; -case 10: -#line 84 "calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; - } -#line 1372 "calc1.tab.c" -break; -case 11: -#line 88 "calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; - } -#line 1379 "calc1.tab.c" -break; -case 12: -#line 92 "calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; - } -#line 1386 "calc1.tab.c" -break; -case 13: -#line 96 "calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; - } -#line 1393 "calc1.tab.c" -break; -case 14: -#line 100 "calc1.y" - { - yyval.dval = -yystack.l_mark[0].dval; - } -#line 1400 "calc1.tab.c" -break; -case 15: -#line 104 "calc1.y" - { - yyval.dval = yystack.l_mark[-1].dval; - } -#line 1407 "calc1.tab.c" -break; -case 16: -#line 110 "calc1.y" - { - yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; - } -#line 1414 "calc1.tab.c" -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; - } - } -#line 1427 "calc1.tab.c" -break; -case 18: -#line 124 "calc1.y" - { - yyval.vval = vreg[yystack.l_mark[0].ival]; - } -#line 1434 "calc1.tab.c" -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; - } -#line 1442 "calc1.tab.c" -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; - } -#line 1450 "calc1.tab.c" -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; - } -#line 1458 "calc1.tab.c" -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; - } -#line 1466 "calc1.tab.c" -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 ); - } -#line 1473 "calc1.tab.c" -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 ); - } -#line 1480 "calc1.tab.c" -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 ); - } -#line 1488 "calc1.tab.c" -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 ); - } -#line 1496 "calc1.tab.c" -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; - } -#line 1504 "calc1.tab.c" -break; -case 28: -#line 171 "calc1.y" - { - yyval.vval = yystack.l_mark[-1].vval; - } -#line 1511 "calc1.tab.c" -break; -#line 1513 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc1.tab.h b/test/btyacc/calc1.tab.h deleted file mode 100644 index 0162b210747..00000000000 --- a/test/btyacc/calc1.tab.h +++ /dev/null @@ -1,23 +0,0 @@ -#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 YYSTYPE -{ - int ival; - double dval; - INTERVAL vval; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE calc1_lval; - -#endif /* _calc1__defines_h_ */ diff --git a/test/btyacc/calc2.error b/test/btyacc/calc2.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/calc2.output b/test/btyacc/calc2.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/calc2.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/calc2.tab.c b/test/btyacc/calc2.tab.c deleted file mode 100644 index ffe4d80c1f7..00000000000 --- a/test/btyacc/calc2.tab.c +++ /dev/null @@ -1,1502 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT calc2_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 524 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "calc2.y" - { yyerrok ; } -#line 1197 "calc2.tab.c" -break; -case 4: -#line 39 "calc2.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1202 "calc2.tab.c" -break; -case 5: -#line 41 "calc2.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1207 "calc2.tab.c" -break; -case 6: -#line 45 "calc2.y" - { yyval = yystack.l_mark[-1]; } -#line 1212 "calc2.tab.c" -break; -case 7: -#line 47 "calc2.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1217 "calc2.tab.c" -break; -case 8: -#line 49 "calc2.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1222 "calc2.tab.c" -break; -case 9: -#line 51 "calc2.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1227 "calc2.tab.c" -break; -case 10: -#line 53 "calc2.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1232 "calc2.tab.c" -break; -case 11: -#line 55 "calc2.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1237 "calc2.tab.c" -break; -case 12: -#line 57 "calc2.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1242 "calc2.tab.c" -break; -case 13: -#line 59 "calc2.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1247 "calc2.tab.c" -break; -case 14: -#line 61 "calc2.y" - { yyval = - yystack.l_mark[0]; } -#line 1252 "calc2.tab.c" -break; -case 15: -#line 63 "calc2.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1257 "calc2.tab.c" -break; -case 17: -#line 68 "calc2.y" - { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1262 "calc2.tab.c" -break; -case 18: -#line 70 "calc2.y" - { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1267 "calc2.tab.c" -break; -#line 1269 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc2.tab.h b/test/btyacc/calc2.tab.h deleted file mode 100644 index 3f0ce8e7972..00000000000 --- a/test/btyacc/calc2.tab.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _calc2__defines_h_ -#define _calc2__defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _calc2__defines_h_ */ diff --git a/test/btyacc/calc3.error b/test/btyacc/calc3.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/calc3.output b/test/btyacc/calc3.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/calc3.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/calc3.tab.c b/test/btyacc/calc3.tab.c deleted file mode 100644 index d41506e7f26..00000000000 --- a/test/btyacc/calc3.tab.c +++ /dev/null @@ -1,1516 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT calc3_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const 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 - -#if YYDEBUG -int yydebug; -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -#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 477 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yyerrflag; - int yychar; - YYSTYPE yyval; - YYSTYPE yylval; - int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyloc; /* position returned by actions */ - YYLTYPE yylloc; /* position from the lexer */ -#endif - - /* 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 YYINT *yylexp = 0; - - static YYINT *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[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - - yyerrflag = 0; - yychar = 0; - memset(&yyval, 0, sizeof(yyval)); - memset(&yylval, 0, sizeof(yylval)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(&yyloc, 0, sizeof(yyloc)); - memset(&yylloc, 0, sizeof(yylloc)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 38 "calc3.y" - { yyerrok ; } -#line 1211 "calc3.tab.c" -break; -case 4: -#line 42 "calc3.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1216 "calc3.tab.c" -break; -case 5: -#line 44 "calc3.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1221 "calc3.tab.c" -break; -case 6: -#line 48 "calc3.y" - { yyval = yystack.l_mark[-1]; } -#line 1226 "calc3.tab.c" -break; -case 7: -#line 50 "calc3.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1231 "calc3.tab.c" -break; -case 8: -#line 52 "calc3.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1236 "calc3.tab.c" -break; -case 9: -#line 54 "calc3.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1241 "calc3.tab.c" -break; -case 10: -#line 56 "calc3.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1246 "calc3.tab.c" -break; -case 11: -#line 58 "calc3.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1251 "calc3.tab.c" -break; -case 12: -#line 60 "calc3.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1256 "calc3.tab.c" -break; -case 13: -#line 62 "calc3.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1261 "calc3.tab.c" -break; -case 14: -#line 64 "calc3.y" - { yyval = - yystack.l_mark[0]; } -#line 1266 "calc3.tab.c" -break; -case 15: -#line 66 "calc3.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1271 "calc3.tab.c" -break; -case 17: -#line 71 "calc3.y" - { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1276 "calc3.tab.c" -break; -case 18: -#line 73 "calc3.y" - { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1281 "calc3.tab.c" -break; -#line 1283 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc3.tab.h b/test/btyacc/calc3.tab.h deleted file mode 100644 index 95fbe0b8dc0..00000000000 --- a/test/btyacc/calc3.tab.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _calc3__defines_h_ -#define _calc3__defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _calc3__defines_h_ */ diff --git a/test/btyacc/calc_code_all.error b/test/btyacc/calc_code_all.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/calc_code_all.output b/test/btyacc/calc_code_all.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/calc_code_all.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/calc_code_all.tab.c b/test/btyacc/calc_code_all.tab.c deleted file mode 100644 index db6c86f38a9..00000000000 --- a/test/btyacc/calc_code_all.tab.c +++ /dev/null @@ -1,1517 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 - -/* %code "top" block start */ -#line 5 "calc_code_all.y" -/* CODE-TOP */ -/* %code "top" block end */ -#line 22 "calc_code_all.tab.c" -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" - -#ifndef yyparse -#define yyparse calc_code_all_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_all_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_all_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_all_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_all_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_all_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_all_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_all_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_all_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_all_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_all_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_all_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos calc_code_all_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto calc_code_all_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_all_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_all_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_all_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_all_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_all_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_all_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_all_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex calc_code_all_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable calc_code_all_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "calc_code_all_" - -#define YYPURE 0 - -#line 9 "calc_code_all.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 137 "calc_code_all.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_all_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_all_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_all_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT calc_code_all_stos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT calc_code_all_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_all_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_all_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT calc_code_all_cindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT calc_code_all_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_all_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_all_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT calc_code_all_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_all_name[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const calc_code_all_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -/* %code "requires" block start */ -#line 3 "calc_code_all.y" -/* CODE-REQUIRES */ -/* %code "requires" block end */ -#line 367 "calc_code_all.tab.c" - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ - -/* %code "provides" block start */ -#line 4 "calc_code_all.y" -/* CODE-PROVIDES */ -#line 6 "calc_code_all.y" -/* CODE-PROVIDES2 */ -/* %code "provides" block end */ -#line 488 "calc_code_all.tab.c" - -/* %code "" block start */ -#line 1 "calc_code_all.y" -/* CODE-DEFAULT2 */ -#line 2 "calc_code_all.y" -/* CODE-DEFAULT */ -/* %code "" block end */ -#line 496 "calc_code_all.tab.c" -#line 73 "calc_code_all.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 539 "calc_code_all.tab.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "calc_code_all.y" - { yyerrok ; } -#line 1212 "calc_code_all.tab.c" -break; -case 4: -#line 39 "calc_code_all.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1217 "calc_code_all.tab.c" -break; -case 5: -#line 41 "calc_code_all.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1222 "calc_code_all.tab.c" -break; -case 6: -#line 45 "calc_code_all.y" - { yyval = yystack.l_mark[-1]; } -#line 1227 "calc_code_all.tab.c" -break; -case 7: -#line 47 "calc_code_all.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1232 "calc_code_all.tab.c" -break; -case 8: -#line 49 "calc_code_all.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1237 "calc_code_all.tab.c" -break; -case 9: -#line 51 "calc_code_all.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1242 "calc_code_all.tab.c" -break; -case 10: -#line 53 "calc_code_all.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1247 "calc_code_all.tab.c" -break; -case 11: -#line 55 "calc_code_all.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1252 "calc_code_all.tab.c" -break; -case 12: -#line 57 "calc_code_all.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1257 "calc_code_all.tab.c" -break; -case 13: -#line 59 "calc_code_all.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1262 "calc_code_all.tab.c" -break; -case 14: -#line 61 "calc_code_all.y" - { yyval = - yystack.l_mark[0]; } -#line 1267 "calc_code_all.tab.c" -break; -case 15: -#line 63 "calc_code_all.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1272 "calc_code_all.tab.c" -break; -case 17: -#line 68 "calc_code_all.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1277 "calc_code_all.tab.c" -break; -case 18: -#line 70 "calc_code_all.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1282 "calc_code_all.tab.c" -break; -#line 1284 "calc_code_all.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc_code_all.tab.h b/test/btyacc/calc_code_all.tab.h deleted file mode 100644 index e79ea7ab930..00000000000 --- a/test/btyacc/calc_code_all.tab.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _calc_code_all__defines_h_ -#define _calc_code_all__defines_h_ - -/* %code "requires" block start */ -#line 3 "calc_code_all.y" -/* CODE-REQUIRES */ -/* %code "requires" block end */ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -/* %code "provides" block start */ -#line 4 "calc_code_all.y" -/* CODE-PROVIDES */ -#line 6 "calc_code_all.y" -/* CODE-PROVIDES2 */ -/* %code "provides" block end */ - -#endif /* _calc_code_all__defines_h_ */ diff --git a/test/btyacc/calc_code_default.error b/test/btyacc/calc_code_default.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/calc_code_default.output b/test/btyacc/calc_code_default.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/calc_code_default.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/calc_code_default.tab.c b/test/btyacc/calc_code_default.tab.c deleted file mode 100644 index e3c10d86f5f..00000000000 --- a/test/btyacc/calc_code_default.tab.c +++ /dev/null @@ -1,1497 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" - -#ifndef yyparse -#define yyparse calc_code_default_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_default_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_default_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_default_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_default_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_default_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_default_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_default_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_default_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_default_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_default_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_default_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos calc_code_default_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto calc_code_default_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_default_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_default_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_default_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_default_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_default_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_default_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_default_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex calc_code_default_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable calc_code_default_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "calc_code_default_" - -#define YYPURE 0 - -#line 5 "calc_code_default.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 131 "calc_code_default.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_default_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_default_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_default_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT calc_code_default_stos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT calc_code_default_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_default_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_default_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT calc_code_default_cindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT calc_code_default_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_default_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_default_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT calc_code_default_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_default_name[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const calc_code_default_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ - -/* %code "" block start */ -#line 1 "calc_code_default.y" -/* CODE-DEFAULT */ -#line 2 "calc_code_default.y" -/* CODE-DEFAULT2 */ -/* %code "" block end */ -#line 476 "calc_code_default.tab.c" -#line 69 "calc_code_default.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 519 "calc_code_default.tab.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 31 "calc_code_default.y" - { yyerrok ; } -#line 1192 "calc_code_default.tab.c" -break; -case 4: -#line 35 "calc_code_default.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1197 "calc_code_default.tab.c" -break; -case 5: -#line 37 "calc_code_default.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1202 "calc_code_default.tab.c" -break; -case 6: -#line 41 "calc_code_default.y" - { yyval = yystack.l_mark[-1]; } -#line 1207 "calc_code_default.tab.c" -break; -case 7: -#line 43 "calc_code_default.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1212 "calc_code_default.tab.c" -break; -case 8: -#line 45 "calc_code_default.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1217 "calc_code_default.tab.c" -break; -case 9: -#line 47 "calc_code_default.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1222 "calc_code_default.tab.c" -break; -case 10: -#line 49 "calc_code_default.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1227 "calc_code_default.tab.c" -break; -case 11: -#line 51 "calc_code_default.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1232 "calc_code_default.tab.c" -break; -case 12: -#line 53 "calc_code_default.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1237 "calc_code_default.tab.c" -break; -case 13: -#line 55 "calc_code_default.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1242 "calc_code_default.tab.c" -break; -case 14: -#line 57 "calc_code_default.y" - { yyval = - yystack.l_mark[0]; } -#line 1247 "calc_code_default.tab.c" -break; -case 15: -#line 59 "calc_code_default.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1252 "calc_code_default.tab.c" -break; -case 17: -#line 64 "calc_code_default.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1257 "calc_code_default.tab.c" -break; -case 18: -#line 66 "calc_code_default.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1262 "calc_code_default.tab.c" -break; -#line 1264 "calc_code_default.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc_code_default.tab.h b/test/btyacc/calc_code_default.tab.h deleted file mode 100644 index 6f673cc8bc1..00000000000 --- a/test/btyacc/calc_code_default.tab.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _calc_code_default__defines_h_ -#define _calc_code_default__defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _calc_code_default__defines_h_ */ diff --git a/test/btyacc/calc_code_imports.error b/test/btyacc/calc_code_imports.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/calc_code_imports.output b/test/btyacc/calc_code_imports.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/calc_code_imports.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/calc_code_imports.tab.c b/test/btyacc/calc_code_imports.tab.c deleted file mode 100644 index 4e1c27edfee..00000000000 --- a/test/btyacc/calc_code_imports.tab.c +++ /dev/null @@ -1,1489 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" - -#ifndef yyparse -#define yyparse calc_code_imports_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_imports_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_imports_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_imports_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_imports_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_imports_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_imports_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_imports_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_imports_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_imports_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_imports_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_imports_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos calc_code_imports_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto calc_code_imports_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_imports_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_imports_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_imports_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_imports_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_imports_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_imports_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_imports_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex calc_code_imports_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable calc_code_imports_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "calc_code_imports_" - -#define YYPURE 0 - -#line 5 "calc_code_imports.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 131 "calc_code_imports.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_imports_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_imports_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_imports_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT calc_code_imports_stos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT calc_code_imports_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_imports_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_imports_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT calc_code_imports_cindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT calc_code_imports_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_imports_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_imports_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT calc_code_imports_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_imports_name[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const calc_code_imports_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 69 "calc_code_imports.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 511 "calc_code_imports.tab.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 31 "calc_code_imports.y" - { yyerrok ; } -#line 1184 "calc_code_imports.tab.c" -break; -case 4: -#line 35 "calc_code_imports.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1189 "calc_code_imports.tab.c" -break; -case 5: -#line 37 "calc_code_imports.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1194 "calc_code_imports.tab.c" -break; -case 6: -#line 41 "calc_code_imports.y" - { yyval = yystack.l_mark[-1]; } -#line 1199 "calc_code_imports.tab.c" -break; -case 7: -#line 43 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1204 "calc_code_imports.tab.c" -break; -case 8: -#line 45 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1209 "calc_code_imports.tab.c" -break; -case 9: -#line 47 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1214 "calc_code_imports.tab.c" -break; -case 10: -#line 49 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1219 "calc_code_imports.tab.c" -break; -case 11: -#line 51 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1224 "calc_code_imports.tab.c" -break; -case 12: -#line 53 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1229 "calc_code_imports.tab.c" -break; -case 13: -#line 55 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1234 "calc_code_imports.tab.c" -break; -case 14: -#line 57 "calc_code_imports.y" - { yyval = - yystack.l_mark[0]; } -#line 1239 "calc_code_imports.tab.c" -break; -case 15: -#line 59 "calc_code_imports.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1244 "calc_code_imports.tab.c" -break; -case 17: -#line 64 "calc_code_imports.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1249 "calc_code_imports.tab.c" -break; -case 18: -#line 66 "calc_code_imports.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1254 "calc_code_imports.tab.c" -break; -#line 1256 "calc_code_imports.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc_code_imports.tab.h b/test/btyacc/calc_code_imports.tab.h deleted file mode 100644 index eb8e7bc7339..00000000000 --- a/test/btyacc/calc_code_imports.tab.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _calc_code_imports__defines_h_ -#define _calc_code_imports__defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _calc_code_imports__defines_h_ */ diff --git a/test/btyacc/calc_code_provides.error b/test/btyacc/calc_code_provides.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/calc_code_provides.output b/test/btyacc/calc_code_provides.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/calc_code_provides.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/calc_code_provides.tab.c b/test/btyacc/calc_code_provides.tab.c deleted file mode 100644 index d4895a6dda7..00000000000 --- a/test/btyacc/calc_code_provides.tab.c +++ /dev/null @@ -1,1497 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" - -#ifndef yyparse -#define yyparse calc_code_provides_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_provides_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_provides_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_provides_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_provides_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_provides_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_provides_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_provides_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_provides_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_provides_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_provides_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_provides_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos calc_code_provides_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto calc_code_provides_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_provides_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_provides_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_provides_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_provides_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_provides_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_provides_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_provides_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex calc_code_provides_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable calc_code_provides_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "calc_code_provides_" - -#define YYPURE 0 - -#line 5 "calc_code_provides.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 131 "calc_code_provides.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_provides_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_provides_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_provides_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT calc_code_provides_stos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT calc_code_provides_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_provides_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_provides_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT calc_code_provides_cindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT calc_code_provides_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_provides_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_provides_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT calc_code_provides_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_provides_name[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const calc_code_provides_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ - -/* %code "provides" block start */ -#line 1 "calc_code_provides.y" -/* CODE-PROVIDES */ -#line 2 "calc_code_provides.y" -/* CODE-PROVIDES2 */ -/* %code "provides" block end */ -#line 476 "calc_code_provides.tab.c" -#line 69 "calc_code_provides.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 519 "calc_code_provides.tab.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 31 "calc_code_provides.y" - { yyerrok ; } -#line 1192 "calc_code_provides.tab.c" -break; -case 4: -#line 35 "calc_code_provides.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1197 "calc_code_provides.tab.c" -break; -case 5: -#line 37 "calc_code_provides.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1202 "calc_code_provides.tab.c" -break; -case 6: -#line 41 "calc_code_provides.y" - { yyval = yystack.l_mark[-1]; } -#line 1207 "calc_code_provides.tab.c" -break; -case 7: -#line 43 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1212 "calc_code_provides.tab.c" -break; -case 8: -#line 45 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1217 "calc_code_provides.tab.c" -break; -case 9: -#line 47 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1222 "calc_code_provides.tab.c" -break; -case 10: -#line 49 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1227 "calc_code_provides.tab.c" -break; -case 11: -#line 51 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1232 "calc_code_provides.tab.c" -break; -case 12: -#line 53 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1237 "calc_code_provides.tab.c" -break; -case 13: -#line 55 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1242 "calc_code_provides.tab.c" -break; -case 14: -#line 57 "calc_code_provides.y" - { yyval = - yystack.l_mark[0]; } -#line 1247 "calc_code_provides.tab.c" -break; -case 15: -#line 59 "calc_code_provides.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1252 "calc_code_provides.tab.c" -break; -case 17: -#line 64 "calc_code_provides.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1257 "calc_code_provides.tab.c" -break; -case 18: -#line 66 "calc_code_provides.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1262 "calc_code_provides.tab.c" -break; -#line 1264 "calc_code_provides.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc_code_provides.tab.h b/test/btyacc/calc_code_provides.tab.h deleted file mode 100644 index 1ca968af458..00000000000 --- a/test/btyacc/calc_code_provides.tab.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _calc_code_provides__defines_h_ -#define _calc_code_provides__defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -/* %code "provides" block start */ -#line 1 "calc_code_provides.y" -/* CODE-PROVIDES */ -#line 2 "calc_code_provides.y" -/* CODE-PROVIDES2 */ -/* %code "provides" block end */ - -#endif /* _calc_code_provides__defines_h_ */ diff --git a/test/btyacc/calc_code_requires.error b/test/btyacc/calc_code_requires.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/calc_code_requires.output b/test/btyacc/calc_code_requires.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/calc_code_requires.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/calc_code_requires.tab.c b/test/btyacc/calc_code_requires.tab.c deleted file mode 100644 index f35103d30c4..00000000000 --- a/test/btyacc/calc_code_requires.tab.c +++ /dev/null @@ -1,1497 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" - -#ifndef yyparse -#define yyparse calc_code_requires_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_requires_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_requires_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_requires_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_requires_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_requires_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_requires_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_requires_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_requires_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_requires_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_requires_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_requires_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos calc_code_requires_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto calc_code_requires_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_requires_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_requires_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_requires_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_requires_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_requires_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_requires_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_requires_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex calc_code_requires_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable calc_code_requires_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "calc_code_requires_" - -#define YYPURE 0 - -#line 5 "calc_code_requires.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 131 "calc_code_requires.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_requires_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_requires_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_requires_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT calc_code_requires_stos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT calc_code_requires_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_requires_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_requires_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT calc_code_requires_cindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT calc_code_requires_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_requires_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_requires_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT calc_code_requires_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_requires_name[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const calc_code_requires_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -/* %code "requires" block start */ -#line 1 "calc_code_requires.y" -/* CODE-REQUIRES */ -#line 2 "calc_code_requires.y" -/* CODE-REQUIRES2 */ -/* %code "requires" block end */ -#line 363 "calc_code_requires.tab.c" - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 69 "calc_code_requires.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 519 "calc_code_requires.tab.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 31 "calc_code_requires.y" - { yyerrok ; } -#line 1192 "calc_code_requires.tab.c" -break; -case 4: -#line 35 "calc_code_requires.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1197 "calc_code_requires.tab.c" -break; -case 5: -#line 37 "calc_code_requires.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1202 "calc_code_requires.tab.c" -break; -case 6: -#line 41 "calc_code_requires.y" - { yyval = yystack.l_mark[-1]; } -#line 1207 "calc_code_requires.tab.c" -break; -case 7: -#line 43 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1212 "calc_code_requires.tab.c" -break; -case 8: -#line 45 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1217 "calc_code_requires.tab.c" -break; -case 9: -#line 47 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1222 "calc_code_requires.tab.c" -break; -case 10: -#line 49 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1227 "calc_code_requires.tab.c" -break; -case 11: -#line 51 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1232 "calc_code_requires.tab.c" -break; -case 12: -#line 53 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1237 "calc_code_requires.tab.c" -break; -case 13: -#line 55 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1242 "calc_code_requires.tab.c" -break; -case 14: -#line 57 "calc_code_requires.y" - { yyval = - yystack.l_mark[0]; } -#line 1247 "calc_code_requires.tab.c" -break; -case 15: -#line 59 "calc_code_requires.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1252 "calc_code_requires.tab.c" -break; -case 17: -#line 64 "calc_code_requires.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1257 "calc_code_requires.tab.c" -break; -case 18: -#line 66 "calc_code_requires.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1262 "calc_code_requires.tab.c" -break; -#line 1264 "calc_code_requires.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc_code_requires.tab.h b/test/btyacc/calc_code_requires.tab.h deleted file mode 100644 index d5b711b534a..00000000000 --- a/test/btyacc/calc_code_requires.tab.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _calc_code_requires__defines_h_ -#define _calc_code_requires__defines_h_ - -/* %code "requires" block start */ -#line 1 "calc_code_requires.y" -/* CODE-REQUIRES */ -#line 2 "calc_code_requires.y" -/* CODE-REQUIRES2 */ -/* %code "requires" block end */ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _calc_code_requires__defines_h_ */ diff --git a/test/btyacc/calc_code_top.error b/test/btyacc/calc_code_top.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/calc_code_top.output b/test/btyacc/calc_code_top.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/calc_code_top.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/calc_code_top.tab.c b/test/btyacc/calc_code_top.tab.c deleted file mode 100644 index 5875015a729..00000000000 --- a/test/btyacc/calc_code_top.tab.c +++ /dev/null @@ -1,1497 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 - -/* %code "top" block start */ -#line 1 "calc_code_top.y" -/* CODE-TOP */ -#line 2 "calc_code_top.y" -/* CODE-TOP2 */ -/* %code "top" block end */ -#line 24 "calc_code_top.tab.c" -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" - -#ifndef yyparse -#define yyparse calc_code_top_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_top_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_top_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_top_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_top_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_top_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_top_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_top_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_top_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_top_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_top_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_top_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos calc_code_top_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto calc_code_top_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_top_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_top_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_top_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_top_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_top_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_top_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_top_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex calc_code_top_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable calc_code_top_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "calc_code_top_" - -#define YYPURE 0 - -#line 5 "calc_code_top.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 139 "calc_code_top.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_top_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_top_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_top_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT calc_code_top_stos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT calc_code_top_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_top_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_top_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT calc_code_top_cindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT calc_code_top_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_top_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_top_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT calc_code_top_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_top_name[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const calc_code_top_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 69 "calc_code_top.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 519 "calc_code_top.tab.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 31 "calc_code_top.y" - { yyerrok ; } -#line 1192 "calc_code_top.tab.c" -break; -case 4: -#line 35 "calc_code_top.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1197 "calc_code_top.tab.c" -break; -case 5: -#line 37 "calc_code_top.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1202 "calc_code_top.tab.c" -break; -case 6: -#line 41 "calc_code_top.y" - { yyval = yystack.l_mark[-1]; } -#line 1207 "calc_code_top.tab.c" -break; -case 7: -#line 43 "calc_code_top.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1212 "calc_code_top.tab.c" -break; -case 8: -#line 45 "calc_code_top.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1217 "calc_code_top.tab.c" -break; -case 9: -#line 47 "calc_code_top.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1222 "calc_code_top.tab.c" -break; -case 10: -#line 49 "calc_code_top.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1227 "calc_code_top.tab.c" -break; -case 11: -#line 51 "calc_code_top.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1232 "calc_code_top.tab.c" -break; -case 12: -#line 53 "calc_code_top.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1237 "calc_code_top.tab.c" -break; -case 13: -#line 55 "calc_code_top.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1242 "calc_code_top.tab.c" -break; -case 14: -#line 57 "calc_code_top.y" - { yyval = - yystack.l_mark[0]; } -#line 1247 "calc_code_top.tab.c" -break; -case 15: -#line 59 "calc_code_top.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1252 "calc_code_top.tab.c" -break; -case 17: -#line 64 "calc_code_top.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1257 "calc_code_top.tab.c" -break; -case 18: -#line 66 "calc_code_top.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1262 "calc_code_top.tab.c" -break; -#line 1264 "calc_code_top.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/calc_code_top.tab.h b/test/btyacc/calc_code_top.tab.h deleted file mode 100644 index 8be78b276e3..00000000000 --- a/test/btyacc/calc_code_top.tab.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _calc_code_top__defines_h_ -#define _calc_code_top__defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _calc_code_top__defines_h_ */ diff --git a/test/btyacc/code_calc.code.c b/test/btyacc/code_calc.code.c deleted file mode 100644 index d3d72a53977..00000000000 --- a/test/btyacc/code_calc.code.c +++ /dev/null @@ -1,1362 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 4 "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 -#undef yytname -#define yytname yyname -#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 int 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 || defined(yytname) -extern const char *const yyname[]; -#endif -#if YYDEBUG -extern const char *const yyrule[]; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 70 "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 384 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 32 "code_calc.y" - { yyerrok ; } -#line 1057 "code_calc.code.c" -break; -case 4: -#line 36 "code_calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1062 "code_calc.code.c" -break; -case 5: -#line 38 "code_calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1067 "code_calc.code.c" -break; -case 6: -#line 42 "code_calc.y" - { yyval = yystack.l_mark[-1]; } -#line 1072 "code_calc.code.c" -break; -case 7: -#line 44 "code_calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1077 "code_calc.code.c" -break; -case 8: -#line 46 "code_calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1082 "code_calc.code.c" -break; -case 9: -#line 48 "code_calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1087 "code_calc.code.c" -break; -case 10: -#line 50 "code_calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1092 "code_calc.code.c" -break; -case 11: -#line 52 "code_calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1097 "code_calc.code.c" -break; -case 12: -#line 54 "code_calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1102 "code_calc.code.c" -break; -case 13: -#line 56 "code_calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1107 "code_calc.code.c" -break; -case 14: -#line 58 "code_calc.y" - { yyval = - yystack.l_mark[0]; } -#line 1112 "code_calc.code.c" -break; -case 15: -#line 60 "code_calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1117 "code_calc.code.c" -break; -case 17: -#line 65 "code_calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1122 "code_calc.code.c" -break; -case 18: -#line 67 "code_calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1127 "code_calc.code.c" -break; -#line 1129 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/code_calc.error b/test/btyacc/code_calc.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/code_calc.output b/test/btyacc/code_calc.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/code_calc.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/code_calc.tab.c b/test/btyacc/code_calc.tab.c deleted file mode 100644 index c6c5048a40d..00000000000 --- a/test/btyacc/code_calc.tab.c +++ /dev/null @@ -1,165 +0,0 @@ -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" -typedef int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -const YYINT calc_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -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", -}; -#if YYDEBUG -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/test/btyacc/code_calc.tab.h b/test/btyacc/code_calc.tab.h deleted file mode 100644 index 0b129daa6a2..00000000000 --- a/test/btyacc/code_calc.tab.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _calc__defines_h_ -#define _calc__defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#undef yytname -#define yytname yyname - -#endif /* _calc__defines_h_ */ diff --git a/test/btyacc/code_error.code.c b/test/btyacc/code_error.code.c deleted file mode 100644 index ac48dbb523b..00000000000 --- a/test/btyacc/code_error.code.c +++ /dev/null @@ -1,1256 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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 || defined(yytname) -extern const char *const yyname[]; -#endif -#if YYDEBUG -extern const char *const yyrule[]; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 354 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/code_error.error b/test/btyacc/code_error.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/code_error.output b/test/btyacc/code_error.output deleted file mode 100644 index 1e56c214a6c..00000000000 --- a/test/btyacc/code_error.output +++ /dev/null @@ -1,34 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -2 terminals, 2 nonterminals -2 grammar rules, 3 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 $accept - 3 258 S diff --git a/test/btyacc/code_error.tab.c b/test/btyacc/code_error.tab.c deleted file mode 100644 index 1037951653e..00000000000 --- a/test/btyacc/code_error.tab.c +++ /dev/null @@ -1,61 +0,0 @@ -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" -typedef int YYINT; -const YYINT error_lhs[] = { -1, - 0, -}; -const YYINT error_len[] = { 2, - 1, -}; -const YYINT error_defred[] = { 0, - 1, 0, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -const YYINT error_stos[] = { 0, - 256, 258, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -const YYINT error_ctable[] = { -1, -}; -#endif -#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/test/btyacc/code_error.tab.h b/test/btyacc/code_error.tab.h deleted file mode 100644 index f9e5ad278cc..00000000000 --- a/test/btyacc/code_error.tab.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _error__defines_h_ -#define _error__defines_h_ - - -#endif /* _error__defines_h_ */ diff --git a/test/btyacc/defines1.calc.c b/test/btyacc/defines1.calc.c deleted file mode 100644 index 66ea979d0ce..00000000000 --- a/test/btyacc/defines1.calc.c +++ /dev/null @@ -1,1396 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "calc.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 34 "y.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT yystos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT yycindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT yyctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 66 "calc.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 418 "y.tab.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 1091 "y.tab.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1096 "y.tab.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1101 "y.tab.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 1106 "y.tab.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1111 "y.tab.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1116 "y.tab.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1121 "y.tab.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1126 "y.tab.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1131 "y.tab.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1136 "y.tab.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1141 "y.tab.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 1146 "y.tab.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1151 "y.tab.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1156 "y.tab.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1161 "y.tab.c" -break; -#line 1163 "y.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/defines1.calc.h b/test/btyacc/defines1.calc.h deleted file mode 100644 index 64c392589c0..00000000000 --- a/test/btyacc/defines1.calc.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _yy_defines_h_ -#define _yy_defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _yy_defines_h_ */ diff --git a/test/btyacc/defines1.error b/test/btyacc/defines1.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/defines1.output b/test/btyacc/defines1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/defines2.calc.c b/test/btyacc/defines2.calc.c deleted file mode 100644 index 66ea979d0ce..00000000000 --- a/test/btyacc/defines2.calc.c +++ /dev/null @@ -1,1396 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "calc.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 34 "y.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT yystos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT yycindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT yyctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 66 "calc.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 418 "y.tab.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 1091 "y.tab.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1096 "y.tab.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1101 "y.tab.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 1106 "y.tab.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1111 "y.tab.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1116 "y.tab.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1121 "y.tab.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1126 "y.tab.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1131 "y.tab.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1136 "y.tab.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1141 "y.tab.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 1146 "y.tab.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1151 "y.tab.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1156 "y.tab.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1161 "y.tab.c" -break; -#line 1163 "y.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/defines2.calc.h b/test/btyacc/defines2.calc.h deleted file mode 100644 index 64c392589c0..00000000000 --- a/test/btyacc/defines2.calc.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _yy_defines_h_ -#define _yy_defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _yy_defines_h_ */ diff --git a/test/btyacc/defines2.error b/test/btyacc/defines2.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/defines2.output b/test/btyacc/defines2.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/defines3.calc.c b/test/btyacc/defines3.calc.c deleted file mode 100644 index 5902efe905f..00000000000 --- a/test/btyacc/defines3.calc.c +++ /dev/null @@ -1,1396 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "calc.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 34 "prefix.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT yystos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT yycindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT yyctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 66 "calc.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 418 "prefix.tab.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 1091 "prefix.tab.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1096 "prefix.tab.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1101 "prefix.tab.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 1106 "prefix.tab.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1111 "prefix.tab.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1116 "prefix.tab.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1121 "prefix.tab.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1126 "prefix.tab.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1131 "prefix.tab.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1136 "prefix.tab.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1141 "prefix.tab.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 1146 "prefix.tab.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1151 "prefix.tab.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1156 "prefix.tab.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1161 "prefix.tab.c" -break; -#line 1163 "prefix.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/defines3.calc.h b/test/btyacc/defines3.calc.h deleted file mode 100644 index 64c392589c0..00000000000 --- a/test/btyacc/defines3.calc.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _yy_defines_h_ -#define _yy_defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _yy_defines_h_ */ diff --git a/test/btyacc/defines3.error b/test/btyacc/defines3.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/defines3.output b/test/btyacc/defines3.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/empty.error b/test/btyacc/empty.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/empty.output b/test/btyacc/empty.output deleted file mode 100644 index bb2b6a9e348..00000000000 --- a/test/btyacc/empty.output +++ /dev/null @@ -1,28 +0,0 @@ - 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/test/btyacc/empty.tab.c b/test/btyacc/empty.tab.c deleted file mode 100644 index d42eb64eb79..00000000000 --- a/test/btyacc/empty.tab.c +++ /dev/null @@ -1,1275 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int YYINT; -static const YYINT empty_lhs[] = { -1, - 0, -}; -static const YYINT empty_len[] = { 2, - 0, -}; -static const YYINT empty_defred[] = { 1, - 0, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT empty_stos[] = { 0, - 258, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT empty_ctable[] = { -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 13 "empty.y" - -#include - -static int -YYLEX_DECL() { - return -1; -} - -static void -YYERROR_DECL() { - printf("%s\n",s); -} -#line 373 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/empty.tab.h b/test/btyacc/empty.tab.h deleted file mode 100644 index 14683cfeab2..00000000000 --- a/test/btyacc/empty.tab.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _empty__defines_h_ -#define _empty__defines_h_ - - -#endif /* _empty__defines_h_ */ diff --git a/test/btyacc/err_inherit1.error b/test/btyacc/err_inherit1.error deleted file mode 100644 index 203b9063e90..00000000000 --- a/test/btyacc/err_inherit1.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 64 of "./err_inherit1.y", unterminated argument list -namelist($c, $t - ^ diff --git a/test/btyacc/err_inherit1.output b/test/btyacc/err_inherit1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_inherit1.tab.c b/test/btyacc/err_inherit1.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_inherit1.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_inherit1.tab.h b/test/btyacc/err_inherit1.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_inherit2.error b/test/btyacc/err_inherit2.error deleted file mode 100644 index c016b63f179..00000000000 --- a/test/btyacc/err_inherit2.error +++ /dev/null @@ -1,5 +0,0 @@ -YACC: w - line 64 of "./err_inherit2.y", number of arguments of namelist doesn't agree with previous declaration -YACC: w - line 64 of "./err_inherit2.y", type of argument 1 to namelist doesn't agree with previous declaration -YACC: e - line 64 of "./err_inherit2.y", bad formal argument list -namelist($c, $t, extra): namelist NAME - ^ diff --git a/test/btyacc/err_inherit2.output b/test/btyacc/err_inherit2.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_inherit2.tab.c b/test/btyacc/err_inherit2.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_inherit2.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_inherit2.tab.h b/test/btyacc/err_inherit2.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_inherit3.error b/test/btyacc/err_inherit3.error deleted file mode 100644 index e0ab28a9179..00000000000 --- a/test/btyacc/err_inherit3.error +++ /dev/null @@ -1,23 +0,0 @@ -YACC: w - line 64 of "./err_inherit3.y", number of arguments of namelist doesn't agree with previous declaration -YACC: w - line 64 of "./err_inherit3.y", wrong number of arguments for namelist -namelist: namelist($c) NAME - ^ -YACC: w - line 64 of "./err_inherit3.y", unknown argument $c -YACC: w - line 64 of "./err_inherit3.y", untyped argument $c -YACC: w - line 65 of "./err_inherit3.y", unknown argument $t - { $$->s = mksymbol($t, $c, $2); - ^ -YACC: w - line 65 of "./err_inherit3.y", unknown argument $c - { $$->s = mksymbol($t, $c, $2); - ^ -YACC: w - line 69 of "./err_inherit3.y", unknown argument $t - { $$->s = mksymbol($t, $c, $1); - ^ -YACC: w - line 69 of "./err_inherit3.y", untyped argument $t -YACC: w - line 69 of "./err_inherit3.y", unknown argument $c - { $$->s = mksymbol($t, $c, $1); - ^ -YACC: w - line 69 of "./err_inherit3.y", untyped argument $c -YACC: w - line 0 of "./err_inherit3.y", start symbol declaration requires arguments -YACC: 1 rule never reduced -YACC: 3 shift/reduce conflicts. diff --git a/test/btyacc/err_inherit3.output b/test/btyacc/err_inherit3.output deleted file mode 100644 index 3a362a96c40..00000000000 --- a/test/btyacc/err_inherit3.output +++ /dev/null @@ -1,216 +0,0 @@ - 0 $accept : declaration $end - - 1 $$1 : - - 2 $$2 : - - 3 declaration : class type $$1 $$2 namelist - 4 | type locnamelist - - 5 class : GLOBAL - 6 | LOCAL - - 7 type : REAL - 8 | INTEGER - - 9 $$3 : - - 10 namelist : $$3 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 . (5) - - . reduce 5 - - -state 2 - class : LOCAL . (6) - - . reduce 6 - - -state 3 - type : REAL . (7) - - . reduce 7 - - -state 4 - type : INTEGER . (8) - - . reduce 8 - - -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 . locnamelist (4) - $$4 : . (12) - - . reduce 12 - - locnamelist goto 9 - $$4 goto 10 - - -state 8 - declaration : class type . $$1 $$2 namelist (3) - $$1 : . (1) - - . reduce 1 - - $$1 goto 11 - - -state 9 - declaration : type locnamelist . (4) - - . reduce 4 - - -state 10 - locnamelist : $$4 . $$2 namelist (13) - $$2 : . (2) - - . reduce 2 - - $$2 goto 12 - - -state 11 - declaration : class type $$1 . $$2 namelist (3) - $$2 : . (2) - - . reduce 2 - - $$2 goto 13 - - -12: shift/reduce conflict (shift 14, reduce 9) on NAME -state 12 - locnamelist : $$4 $$2 . namelist (13) - $$3 : . (9) - - NAME shift 14 - - namelist goto 15 - $$3 goto 16 - - -13: shift/reduce conflict (shift 14, reduce 9) on NAME -state 13 - declaration : class type $$1 $$2 . namelist (3) - $$3 : . (9) - - NAME shift 14 - - namelist goto 17 - $$3 goto 16 - - -state 14 - namelist : NAME . (11) - - . reduce 11 - - -state 15 - locnamelist : $$4 $$2 namelist . (13) - - . reduce 13 - - -16: shift/reduce conflict (shift 14, reduce 9) on NAME -state 16 - namelist : $$3 . namelist NAME (10) - $$3 : . (9) - - NAME shift 14 - - namelist goto 18 - $$3 goto 16 - - -state 17 - declaration : class type $$1 $$2 namelist . (3) - - . reduce 3 - - -state 18 - namelist : $$3 namelist . NAME (10) - - NAME shift 19 - . error - - -state 19 - namelist : $$3 namelist NAME . (10) - - . reduce 10 - - -Rules never reduced: - $$3 : (9) - - -State 12 contains 1 shift/reduce conflict. -State 13 contains 1 shift/reduce conflict. -State 16 contains 1 shift/reduce conflict. - - -7 terminals, 10 nonterminals -14 grammar rules, 20 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/test/btyacc/err_inherit3.tab.c b/test/btyacc/err_inherit3.tab.c deleted file mode 100644 index d0ca88d9005..00000000000 --- a/test/btyacc/err_inherit3.tab.c +++ /dev/null @@ -1,1445 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 39 "err_inherit3.y" -typedef union YYSTYPE -{ - 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 int YYINT; -static const YYINT err_inherit3_lhs[] = { -1, - 5, 6, 0, 0, 3, 3, 4, 4, 7, 1, - 1, 8, 2, -}; -static const YYINT err_inherit3_len[] = { 2, - 0, 0, 5, 2, 1, 1, 1, 1, 0, 3, - 1, 0, 3, -}; -static const YYINT err_inherit3_defred[] = { 0, - 5, 6, 7, 8, 0, 0, 12, 1, 4, 2, - 2, 0, 0, 11, 13, 0, 3, 0, 10, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT err_inherit3_stos[] = { 0, - 257, 258, 259, 260, 263, 266, 267, 267, 265, 271, - 268, 269, 269, 261, 264, 270, 264, 264, 261, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT err_inherit3_dgoto[] = { 5, - 15, 9, 6, 7, 11, 12, 16, 10, -}; -static const YYINT err_inherit3_sindex[] = { -257, - 0, 0, 0, 0, 0, -254, 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, -}; -#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, -}; -#endif -static const YYINT err_inherit3_gindex[] = { 0, - -9, 0, 0, 4, 0, 1, 0, 0, -}; -#define YYTABLESIZE 12 -static const YYINT err_inherit3_table[] = { 1, - 2, 3, 4, 17, 3, 4, 18, 14, 19, 8, - 0, 13, -}; -static const YYINT err_inherit3_check[] = { 257, - 258, 259, 260, 13, 259, 260, 16, 261, 261, 6, - -1, 11, -}; -#if YYBTYACC -static const YYINT err_inherit3_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -}; -#endif -#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 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","illegal-symbol", -}; -static const char *const err_inherit3_rule[] = { -"$accept : declaration", -"$$1 :", -"$$2 :", -"declaration : class type $$1 $$2 namelist", -"declaration : type locnamelist", -"class : GLOBAL", -"class : LOCAL", -"type : REAL", -"type : INTEGER", -"$$3 :", -"namelist : $$3 namelist NAME", -"namelist : NAME", -"$$4 :", -"locnamelist : $$4 $$2 namelist", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 78 "err_inherit3.y" - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); -#line 425 "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); - } - } -#line 444 "err_inherit3.tab.c" - break; - 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); - } - } -#line 456 "err_inherit3.tab.c" - break; - 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); - } - } -#line 468 "err_inherit3.tab.c" - break; - } -} -#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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: -#line 50 "err_inherit3.y" -yyval.cval = yystack.l_mark[-1].cval; -#line 1146 "err_inherit3.tab.c" -break; -case 2: -#line 50 "err_inherit3.y" -yyval.tval = yystack.l_mark[-1].tval; -#line 1151 "err_inherit3.tab.c" -break; -case 3: -#line 51 "err_inherit3.y" - { yyval.nlist = yystack.l_mark[0].nlist; } -#line 1156 "err_inherit3.tab.c" -break; -case 4: -#line 53 "err_inherit3.y" - { yyval.nlist = yystack.l_mark[0].nlist; } -#line 1161 "err_inherit3.tab.c" -break; -case 5: -#line 56 "err_inherit3.y" - { yyval.cval = cGLOBAL; } -#line 1166 "err_inherit3.tab.c" -break; -case 6: -#line 57 "err_inherit3.y" - { yyval.cval = cLOCAL; } -#line 1171 "err_inherit3.tab.c" -break; -case 7: -#line 60 "err_inherit3.y" - { yyval.tval = tREAL; } -#line 1176 "err_inherit3.tab.c" -break; -case 8: -#line 61 "err_inherit3.y" - { yyval.tval = tINTEGER; } -#line 1181 "err_inherit3.tab.c" -break; -case 9: -#line 64 "err_inherit3.y" -yyval.cval = yystack.l_mark[-2]; -#line 1186 "err_inherit3.tab.c" -break; -case 10: -#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; - } -#line 1193 "err_inherit3.tab.c" -break; -case 11: -#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; - } -#line 1200 "err_inherit3.tab.c" -break; -case 12: -#line 74 "err_inherit3.y" -yyval.cval = cLOCAL; -#line 1205 "err_inherit3.tab.c" -break; -case 13: -#line 75 "err_inherit3.y" - { yyval.nlist = yystack.l_mark[0].nlist; } -#line 1210 "err_inherit3.tab.c" -break; -#line 1212 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/err_inherit3.tab.h b/test/btyacc/err_inherit3.tab.h deleted file mode 100644 index 1018167b685..00000000000 --- a/test/btyacc/err_inherit3.tab.h +++ /dev/null @@ -1,25 +0,0 @@ -#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 YYSTYPE -{ - 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/test/btyacc/err_inherit4.error b/test/btyacc/err_inherit4.error deleted file mode 100644 index 20aa216ba23..00000000000 --- a/test/btyacc/err_inherit4.error +++ /dev/null @@ -1,13 +0,0 @@ -YACC: w - line 32 of "./err_inherit4.y", destructor redeclared -%destructor { - ^ -YACC: w - line 77 of "./err_inherit4.y", wrong number of default arguments for namelist - { $$ = $1; @$ = @2; } - ^ -YACC: w - line 77 of "./err_inherit4.y", wrong type for default argument 2 to namelist - { $$ = $1; @$ = @2; } - ^ -YACC: w - line 77 of "./err_inherit4.y", wrong type for default argument 1 to namelist - { $$ = $1; @$ = @2; } - ^ -YACC: w - line 77 of "./err_inherit4.y", @2 references beyond the end of the current rule diff --git a/test/btyacc/err_inherit4.output b/test/btyacc/err_inherit4.output deleted file mode 100644 index ef7ccb88d50..00000000000 --- a/test/btyacc/err_inherit4.output +++ /dev/null @@ -1,165 +0,0 @@ - 0 $accept : declaration $end - - 1 $$1 : - - 2 $$2 : - - 3 declaration : class type $$1 $$2 namelist - 4 | type locnamelist - - 5 class : GLOBAL - 6 | LOCAL - - 7 type : REAL - 8 | INTEGER - - 9 namelist : namelist NAME - 10 | NAME - - 11 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 . (5) - - . reduce 5 - - -state 2 - class : LOCAL . (6) - - . reduce 6 - - -state 3 - type : REAL . (7) - - . reduce 7 - - -state 4 - type : INTEGER . (8) - - . reduce 8 - - -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 . locnamelist (4) - - NAME shift 9 - . error - - namelist goto 10 - locnamelist goto 11 - - -state 8 - declaration : class type . $$1 $$2 namelist (3) - $$1 : . (1) - - . reduce 1 - - $$1 goto 12 - - -state 9 - namelist : NAME . (10) - - . reduce 10 - - -state 10 - namelist : namelist . NAME (9) - locnamelist : namelist . (11) - - NAME shift 13 - $end reduce 11 - - -state 11 - declaration : type locnamelist . (4) - - . reduce 4 - - -state 12 - declaration : class type $$1 . $$2 namelist (3) - $$2 : . (2) - - . reduce 2 - - $$2 goto 14 - - -state 13 - namelist : namelist NAME . (9) - - . reduce 9 - - -state 14 - declaration : class type $$1 $$2 . namelist (3) - - NAME shift 9 - . error - - namelist goto 15 - - -state 15 - declaration : class type $$1 $$2 namelist . (3) - namelist : namelist . NAME (9) - - NAME shift 13 - $end reduce 3 - - -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/test/btyacc/err_inherit4.tab.c b/test/btyacc/err_inherit4.tab.c deleted file mode 100644 index 3fd7e55b6aa..00000000000 --- a/test/btyacc/err_inherit4.tab.c +++ /dev/null @@ -1,1433 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 41 "err_inherit4.y" -typedef union YYSTYPE -{ - 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; - unsigned source; -} YYLTYPE; -#define YYLTYPE_IS_DECLARED 1 -#endif -#define YYRHSLOC(rhs, k) ((rhs)[k]) - -/* 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 int YYINT; -static const YYINT err_inherit4_lhs[] = { -1, - 5, 6, 0, 0, 3, 3, 4, 4, 1, 1, - 2, -}; -static const YYINT err_inherit4_len[] = { 2, - 0, 0, 5, 2, 1, 1, 1, 1, 2, 1, - 1, -}; -static const YYINT err_inherit4_defred[] = { 0, - 5, 6, 7, 8, 0, 0, 0, 1, 10, 0, - 4, 2, 9, 0, 0, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT err_inherit4_stos[] = { 0, - 257, 258, 259, 260, 263, 266, 267, 267, 261, 264, - 265, 268, 261, 269, 264, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT err_inherit4_dgoto[] = { 5, - 10, 11, 6, 7, 12, 14, -}; -static const YYINT err_inherit4_sindex[] = { -257, - 0, 0, 0, 0, 0, -255, -254, 0, 0, -253, - 0, 0, 0, -254, -253, -}; -static const YYINT err_inherit4_rindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, - 0, 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, -}; -#endif -static const YYINT err_inherit4_gindex[] = { 0, - -4, 0, 0, 5, 0, 0, -}; -#define YYTABLESIZE 11 -static const YYINT err_inherit4_table[] = { 1, - 2, 3, 4, 3, 4, 11, 9, 13, 3, 15, - 8, -}; -static const YYINT err_inherit4_check[] = { 257, - 258, 259, 260, 259, 260, 0, 261, 261, 0, 14, - 6, -}; -#if YYBTYACC -static const YYINT err_inherit4_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#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 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","illegal-symbol", -}; -static const char *const err_inherit4_rule[] = { -"$accept : declaration", -"$$1 :", -"$$2 :", -"declaration : class type $$1 $$2 namelist", -"declaration : type locnamelist", -"class : GLOBAL", -"class : LOCAL", -"type : REAL", -"type : INTEGER", -"namelist : namelist NAME", -"namelist : NAME", -"locnamelist : namelist", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 80 "err_inherit4.y" - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); -#line 444 "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" - { } -#line 456 "err_inherit4.tab.c" - break; - case 264: -#line 28 "err_inherit4.y" - { } -#line 461 "err_inherit4.tab.c" - break; - case 265: -#line 28 "err_inherit4.y" - { } -#line 466 "err_inherit4.tab.c" - break; - } -} -#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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: -#line 52 "err_inherit4.y" -yyval.cval = yystack.l_mark[-1].cval; -#line 1144 "err_inherit4.tab.c" -break; -case 2: -#line 52 "err_inherit4.y" -yyval.tval = yystack.l_mark[-1].tval; -#line 1149 "err_inherit4.tab.c" -break; -case 3: -#line 53 "err_inherit4.y" - { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[0]; } -#line 1154 "err_inherit4.tab.c" -break; -case 4: -#line 55 "err_inherit4.y" - { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[-3]; } -#line 1159 "err_inherit4.tab.c" -break; -case 5: -#line 58 "err_inherit4.y" - { yyval.cval = cGLOBAL; } -#line 1164 "err_inherit4.tab.c" -break; -case 6: -#line 59 "err_inherit4.y" - { yyval.cval = cLOCAL; } -#line 1169 "err_inherit4.tab.c" -break; -case 7: -#line 62 "err_inherit4.y" - { yyval.tval = tREAL; } -#line 1174 "err_inherit4.tab.c" -break; -case 8: -#line 63 "err_inherit4.y" - { yyval.tval = tINTEGER; } -#line 1179 "err_inherit4.tab.c" -break; -case 9: -#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; - } -#line 1186 "err_inherit4.tab.c" -break; -case 10: -#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; - } -#line 1193 "err_inherit4.tab.c" -break; -case 11: -#line 77 "err_inherit4.y" - { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[1]; } -#line 1198 "err_inherit4.tab.c" -break; -#line 1200 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/err_inherit4.tab.h b/test/btyacc/err_inherit4.tab.h deleted file mode 100644 index b8c5c281761..00000000000 --- a/test/btyacc/err_inherit4.tab.h +++ /dev/null @@ -1,40 +0,0 @@ -#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 YYSTYPE -{ - class cval; - type tval; - namelist * nlist; - name id; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE err_inherit4_lval; - -#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; - unsigned source; -} YYLTYPE; -#define YYLTYPE_IS_DECLARED 1 -#endif -#define YYRHSLOC(rhs, k) ((rhs)[k]) -extern YYLTYPE err_inherit4_lloc; - -#endif /* _err_inherit4__defines_h_ */ diff --git a/test/btyacc/err_inherit5.error b/test/btyacc/err_inherit5.error deleted file mode 100644 index ceabc34591b..00000000000 --- a/test/btyacc/err_inherit5.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 74 of "./err_inherit5.y", illegal @$ or @N reference diff --git a/test/btyacc/err_inherit5.output b/test/btyacc/err_inherit5.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_inherit5.tab.c b/test/btyacc/err_inherit5.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_inherit5.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_inherit5.tab.h b/test/btyacc/err_inherit5.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax1.error b/test/btyacc/err_syntax1.error deleted file mode 100644 index 5df5c22ef17..00000000000 --- a/test/btyacc/err_syntax1.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 1 of "./err_syntax1.y", syntax error - ?% { - ^ diff --git a/test/btyacc/err_syntax1.output b/test/btyacc/err_syntax1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax1.tab.c b/test/btyacc/err_syntax1.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax1.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax1.tab.h b/test/btyacc/err_syntax1.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax10.error b/test/btyacc/err_syntax10.error deleted file mode 100644 index 61a72c0408a..00000000000 --- a/test/btyacc/err_syntax10.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: w - line 7 of "./err_syntax10.y", the type of '(' has been redeclared -YACC: w - line 7 of "./err_syntax10.y", the type of '*' has been redeclared -YACC: w - line 7 of "./err_syntax10.y", the type of '&' has been redeclared diff --git a/test/btyacc/err_syntax10.output b/test/btyacc/err_syntax10.output deleted file mode 100644 index 3d9210a70ed..00000000000 --- a/test/btyacc/err_syntax10.output +++ /dev/null @@ -1,37 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -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/test/btyacc/err_syntax10.tab.c b/test/btyacc/err_syntax10.tab.c deleted file mode 100644 index f025eadecd6..00000000000 --- a/test/btyacc/err_syntax10.tab.c +++ /dev/null @@ -1,1274 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT err_syntax10_stos[] = { 0, - 256, 258, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT err_syntax10_ctable[] = { -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 372 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/err_syntax10.tab.h b/test/btyacc/err_syntax10.tab.h deleted file mode 100644 index b9f412593fd..00000000000 --- a/test/btyacc/err_syntax10.tab.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _err_syntax10__defines_h_ -#define _err_syntax10__defines_h_ - - -#endif /* _err_syntax10__defines_h_ */ diff --git a/test/btyacc/err_syntax11.error b/test/btyacc/err_syntax11.error deleted file mode 100644 index b2dd79c5050..00000000000 --- a/test/btyacc/err_syntax11.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - line 7 of "./err_syntax11.y", the precedence of '|' has been redeclared diff --git a/test/btyacc/err_syntax11.output b/test/btyacc/err_syntax11.output deleted file mode 100644 index bc5e66d9886..00000000000 --- a/test/btyacc/err_syntax11.output +++ /dev/null @@ -1,35 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -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/test/btyacc/err_syntax11.tab.c b/test/btyacc/err_syntax11.tab.c deleted file mode 100644 index 41f794fd7cd..00000000000 --- a/test/btyacc/err_syntax11.tab.c +++ /dev/null @@ -1,1280 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT err_syntax11_stos[] = { 0, - 256, 258, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT err_syntax11_ctable[] = { -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 378 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/err_syntax11.tab.h b/test/btyacc/err_syntax11.tab.h deleted file mode 100644 index bfe5d07a7df..00000000000 --- a/test/btyacc/err_syntax11.tab.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _err_syntax11__defines_h_ -#define _err_syntax11__defines_h_ - - -#endif /* _err_syntax11__defines_h_ */ diff --git a/test/btyacc/err_syntax12.error b/test/btyacc/err_syntax12.error deleted file mode 100644 index 358960bdb9e..00000000000 --- a/test/btyacc/err_syntax12.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - line 7 of "./err_syntax12.y", the value of text has been redeclared diff --git a/test/btyacc/err_syntax12.output b/test/btyacc/err_syntax12.output deleted file mode 100644 index 6e792d6dfde..00000000000 --- a/test/btyacc/err_syntax12.output +++ /dev/null @@ -1,35 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -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/test/btyacc/err_syntax12.tab.c b/test/btyacc/err_syntax12.tab.c deleted file mode 100644 index fe194ce2a0e..00000000000 --- a/test/btyacc/err_syntax12.tab.c +++ /dev/null @@ -1,1286 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT err_syntax12_stos[] = { 0, - 256, 458, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT err_syntax12_ctable[] = { -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 384 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/err_syntax12.tab.h b/test/btyacc/err_syntax12.tab.h deleted file mode 100644 index 6fda3d1e968..00000000000 --- a/test/btyacc/err_syntax12.tab.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _err_syntax12__defines_h_ -#define _err_syntax12__defines_h_ - -#define text 456 - -#endif /* _err_syntax12__defines_h_ */ diff --git a/test/btyacc/err_syntax13.error b/test/btyacc/err_syntax13.error deleted file mode 100644 index 9ffa8b40c27..00000000000 --- a/test/btyacc/err_syntax13.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 7 of "./err_syntax13.y", the start symbol text is a token diff --git a/test/btyacc/err_syntax13.output b/test/btyacc/err_syntax13.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax13.tab.c b/test/btyacc/err_syntax13.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax13.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax13.tab.h b/test/btyacc/err_syntax13.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax14.error b/test/btyacc/err_syntax14.error deleted file mode 100644 index 73e9f7c8319..00000000000 --- a/test/btyacc/err_syntax14.error +++ /dev/null @@ -1,2 +0,0 @@ -YACC: w - line 7 of "./err_syntax14.y", the start symbol has been redeclared -YACC: e - the start symbol text2 is undefined diff --git a/test/btyacc/err_syntax14.output b/test/btyacc/err_syntax14.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax14.tab.c b/test/btyacc/err_syntax14.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax14.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax14.tab.h b/test/btyacc/err_syntax14.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax15.error b/test/btyacc/err_syntax15.error deleted file mode 100644 index 36dc03fef8b..00000000000 --- a/test/btyacc/err_syntax15.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 9 of "./err_syntax15.y", no grammar has been specified diff --git a/test/btyacc/err_syntax15.output b/test/btyacc/err_syntax15.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax15.tab.c b/test/btyacc/err_syntax15.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax15.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax15.tab.h b/test/btyacc/err_syntax15.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax16.error b/test/btyacc/err_syntax16.error deleted file mode 100644 index 6ff15897045..00000000000 --- a/test/btyacc/err_syntax16.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 14 of "./err_syntax16.y", a token appears on the lhs of a production diff --git a/test/btyacc/err_syntax16.output b/test/btyacc/err_syntax16.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax16.tab.c b/test/btyacc/err_syntax16.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax16.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax16.tab.h b/test/btyacc/err_syntax16.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax17.error b/test/btyacc/err_syntax17.error deleted file mode 100644 index 8a8b64b0712..00000000000 --- a/test/btyacc/err_syntax17.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 8 of "./err_syntax17.y", unterminated action -S: { error - ^ diff --git a/test/btyacc/err_syntax17.output b/test/btyacc/err_syntax17.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax17.tab.c b/test/btyacc/err_syntax17.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax17.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax17.tab.h b/test/btyacc/err_syntax17.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax18.error b/test/btyacc/err_syntax18.error deleted file mode 100644 index c52fd71a1ec..00000000000 --- a/test/btyacc/err_syntax18.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - line 9 of "./err_syntax18.y", $4 references beyond the end of the current rule diff --git a/test/btyacc/err_syntax18.output b/test/btyacc/err_syntax18.output deleted file mode 100644 index 216fb71b6f9..00000000000 --- a/test/btyacc/err_syntax18.output +++ /dev/null @@ -1,52 +0,0 @@ - 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/test/btyacc/err_syntax18.tab.c b/test/btyacc/err_syntax18.tab.c deleted file mode 100644 index 633a96c1958..00000000000 --- a/test/btyacc/err_syntax18.tab.c +++ /dev/null @@ -1,1289 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT err_syntax18_stos[] = { 0, - 40, 258, 258, 41, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT err_syntax18_ctable[] = { -1, - -1, -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 381 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: -#line 9 "err_syntax18.y" - { yyval = yystack.l_mark[1]; } -#line 1054 "err_syntax18.tab.c" -break; -#line 1056 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/err_syntax18.tab.h b/test/btyacc/err_syntax18.tab.h deleted file mode 100644 index f08352a9b17..00000000000 --- a/test/btyacc/err_syntax18.tab.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _err_syntax18__defines_h_ -#define _err_syntax18__defines_h_ - - -#endif /* _err_syntax18__defines_h_ */ diff --git a/test/btyacc/err_syntax19.error b/test/btyacc/err_syntax19.error deleted file mode 100644 index 2499b7fc4f1..00000000000 --- a/test/btyacc/err_syntax19.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 9 of "./err_syntax19.y", illegal $-name - { $$ = $; } - ^ diff --git a/test/btyacc/err_syntax19.output b/test/btyacc/err_syntax19.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax19.tab.c b/test/btyacc/err_syntax19.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax19.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax19.tab.h b/test/btyacc/err_syntax19.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax2.error b/test/btyacc/err_syntax2.error deleted file mode 100644 index 29fe56c28b4..00000000000 --- a/test/btyacc/err_syntax2.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 1 of "./err_syntax2.y", unmatched /* -%{ /* - ^ diff --git a/test/btyacc/err_syntax2.output b/test/btyacc/err_syntax2.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax2.tab.c b/test/btyacc/err_syntax2.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax2.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax2.tab.h b/test/btyacc/err_syntax2.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax20.error b/test/btyacc/err_syntax20.error deleted file mode 100644 index 76dac8152de..00000000000 --- a/test/btyacc/err_syntax20.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - the symbol recur is undefined diff --git a/test/btyacc/err_syntax20.output b/test/btyacc/err_syntax20.output deleted file mode 100644 index f0378d42e95..00000000000 --- a/test/btyacc/err_syntax20.output +++ /dev/null @@ -1,51 +0,0 @@ - 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/test/btyacc/err_syntax20.tab.c b/test/btyacc/err_syntax20.tab.c deleted file mode 100644 index 2c249c4c252..00000000000 --- a/test/btyacc/err_syntax20.tab.c +++ /dev/null @@ -1,1284 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT err_syntax20_stos[] = { 0, - 40, 259, 257, 41, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT err_syntax20_ctable[] = { -1, - -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 376 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: -#line 12 "err_syntax20.y" - { yystack.l_mark[-1].rechk = 3; } -#line 1049 "err_syntax20.tab.c" -break; -#line 1051 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/err_syntax20.tab.h b/test/btyacc/err_syntax20.tab.h deleted file mode 100644 index fb019706fb2..00000000000 --- a/test/btyacc/err_syntax20.tab.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _err_syntax20__defines_h_ -#define _err_syntax20__defines_h_ - -#define recur 257 - -#endif /* _err_syntax20__defines_h_ */ diff --git a/test/btyacc/err_syntax21.error b/test/btyacc/err_syntax21.error deleted file mode 100644 index 9b0dc17b662..00000000000 --- a/test/btyacc/err_syntax21.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 12 of "./err_syntax21.y", $0 is untyped diff --git a/test/btyacc/err_syntax21.output b/test/btyacc/err_syntax21.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax21.tab.c b/test/btyacc/err_syntax21.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax21.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax21.tab.h b/test/btyacc/err_syntax21.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax22.error b/test/btyacc/err_syntax22.error deleted file mode 100644 index 8622aa73f59..00000000000 --- a/test/btyacc/err_syntax22.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 17 of "./err_syntax22.y", $2 (recur) is untyped diff --git a/test/btyacc/err_syntax22.output b/test/btyacc/err_syntax22.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax22.tab.c b/test/btyacc/err_syntax22.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax22.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax22.tab.h b/test/btyacc/err_syntax22.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax23.error b/test/btyacc/err_syntax23.error deleted file mode 100644 index 3ccbbd1fee8..00000000000 --- a/test/btyacc/err_syntax23.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 18 of "./err_syntax23.y", $$ is untyped diff --git a/test/btyacc/err_syntax23.output b/test/btyacc/err_syntax23.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax23.tab.c b/test/btyacc/err_syntax23.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax23.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax23.tab.h b/test/btyacc/err_syntax23.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax24.error b/test/btyacc/err_syntax24.error deleted file mode 100644 index e8bbfeca35f..00000000000 --- a/test/btyacc/err_syntax24.error +++ /dev/null @@ -1,2 +0,0 @@ -YACC: w - line 21 of "./err_syntax24.y", the default action for expr assigns an undefined value to $$ -YACC: e - line 22 of "./err_syntax24.y", $$ is untyped diff --git a/test/btyacc/err_syntax24.output b/test/btyacc/err_syntax24.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax24.tab.c b/test/btyacc/err_syntax24.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax24.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax24.tab.h b/test/btyacc/err_syntax24.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax25.error b/test/btyacc/err_syntax25.error deleted file mode 100644 index 234a7b9fcd3..00000000000 --- a/test/btyacc/err_syntax25.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 11 of "./err_syntax25.y", too many %union declarations -%union { -^ diff --git a/test/btyacc/err_syntax25.output b/test/btyacc/err_syntax25.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax25.tab.c b/test/btyacc/err_syntax25.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax25.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax25.tab.h b/test/btyacc/err_syntax25.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax26.error b/test/btyacc/err_syntax26.error deleted file mode 100644 index c9a09ad1992..00000000000 --- a/test/btyacc/err_syntax26.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 6 of "./err_syntax26.y", unexpected end-of-file diff --git a/test/btyacc/err_syntax26.output b/test/btyacc/err_syntax26.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax26.tab.c b/test/btyacc/err_syntax26.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax26.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax26.tab.h b/test/btyacc/err_syntax26.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax27.error b/test/btyacc/err_syntax27.error deleted file mode 100644 index 2a277087c35..00000000000 --- a/test/btyacc/err_syntax27.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 3 of "./err_syntax27.y", missing '}' diff --git a/test/btyacc/err_syntax27.output b/test/btyacc/err_syntax27.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax27.tab.c b/test/btyacc/err_syntax27.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax27.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax27.tab.h b/test/btyacc/err_syntax27.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax3.error b/test/btyacc/err_syntax3.error deleted file mode 100644 index 7e4871b87ad..00000000000 --- a/test/btyacc/err_syntax3.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax3.y", unterminated string -%token '(' '*' '& - ^ diff --git a/test/btyacc/err_syntax3.output b/test/btyacc/err_syntax3.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax3.tab.c b/test/btyacc/err_syntax3.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax3.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax3.tab.h b/test/btyacc/err_syntax3.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax4.error b/test/btyacc/err_syntax4.error deleted file mode 100644 index 6a10d4040eb..00000000000 --- a/test/btyacc/err_syntax4.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 1 of "./err_syntax4.y", unmatched %{ -%{ -^ diff --git a/test/btyacc/err_syntax4.output b/test/btyacc/err_syntax4.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax4.tab.c b/test/btyacc/err_syntax4.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax4.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax4.tab.h b/test/btyacc/err_syntax4.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax5.error b/test/btyacc/err_syntax5.error deleted file mode 100644 index 37a8500b053..00000000000 --- a/test/btyacc/err_syntax5.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax5.y", unterminated %union declaration -%union { -^ diff --git a/test/btyacc/err_syntax5.output b/test/btyacc/err_syntax5.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax5.tab.c b/test/btyacc/err_syntax5.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax5.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax5.tab.h b/test/btyacc/err_syntax5.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax6.error b/test/btyacc/err_syntax6.error deleted file mode 100644 index bde624a7159..00000000000 --- a/test/btyacc/err_syntax6.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax6.y", illegal tag -%token '\777' - ^ diff --git a/test/btyacc/err_syntax7.output b/test/btyacc/err_syntax7.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax7.tab.c b/test/btyacc/err_syntax7.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax7.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax7.tab.h b/test/btyacc/err_syntax7.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax7a.error b/test/btyacc/err_syntax7a.error deleted file mode 100644 index 213711e11ff..00000000000 --- a/test/btyacc/err_syntax7a.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax7a.y", illegal character -%token '\xfff' - ^ diff --git a/test/btyacc/err_syntax7a.output b/test/btyacc/err_syntax7a.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax7a.tab.c b/test/btyacc/err_syntax7a.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax7a.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax7a.tab.h b/test/btyacc/err_syntax7a.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax7b.error b/test/btyacc/err_syntax7b.error deleted file mode 100644 index 19b617ccca1..00000000000 --- a/test/btyacc/err_syntax7b.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax7b.y", illegal character -%token '\x.' - ^ diff --git a/test/btyacc/err_syntax7b.output b/test/btyacc/err_syntax7b.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax7b.tab.c b/test/btyacc/err_syntax7b.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax7b.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax7b.tab.h b/test/btyacc/err_syntax7b.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax8.error b/test/btyacc/err_syntax8.error deleted file mode 100644 index c6a4cc943fa..00000000000 --- a/test/btyacc/err_syntax8.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 6 of "./err_syntax8.y", illegal use of reserved symbol . diff --git a/test/btyacc/err_syntax8.output b/test/btyacc/err_syntax8.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax8.tab.c b/test/btyacc/err_syntax8.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax8.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax8.tab.h b/test/btyacc/err_syntax8.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax8a.error b/test/btyacc/err_syntax8a.error deleted file mode 100644 index ed503e90451..00000000000 --- a/test/btyacc/err_syntax8a.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 6 of "./err_syntax8a.y", illegal use of reserved symbol $$123 diff --git a/test/btyacc/err_syntax8a.output b/test/btyacc/err_syntax8a.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax8a.tab.c b/test/btyacc/err_syntax8a.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax8a.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax8a.tab.h b/test/btyacc/err_syntax8a.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax9.error b/test/btyacc/err_syntax9.error deleted file mode 100644 index 1f74b7ea0a2..00000000000 --- a/test/btyacc/err_syntax9.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 7 of "./err_syntax9.y", the start symbol text cannot be declared to be a token diff --git a/test/btyacc/err_syntax9.output b/test/btyacc/err_syntax9.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/err_syntax9.tab.c b/test/btyacc/err_syntax9.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/btyacc/err_syntax9.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/btyacc/err_syntax9.tab.h b/test/btyacc/err_syntax9.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/error.error b/test/btyacc/error.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/error.output b/test/btyacc/error.output deleted file mode 100644 index 1e56c214a6c..00000000000 --- a/test/btyacc/error.output +++ /dev/null @@ -1,34 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -2 terminals, 2 nonterminals -2 grammar rules, 3 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 $accept - 3 258 S diff --git a/test/btyacc/error.tab.c b/test/btyacc/error.tab.c deleted file mode 100644 index cfd6fc01026..00000000000 --- a/test/btyacc/error.tab.c +++ /dev/null @@ -1,1279 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int YYINT; -static const YYINT error_lhs[] = { -1, - 0, -}; -static const YYINT error_len[] = { 2, - 1, -}; -static const YYINT error_defred[] = { 0, - 1, 0, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT error_stos[] = { 0, - 256, 258, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT error_ctable[] = { -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 377 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/error.tab.h b/test/btyacc/error.tab.h deleted file mode 100644 index f9e5ad278cc..00000000000 --- a/test/btyacc/error.tab.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _error__defines_h_ -#define _error__defines_h_ - - -#endif /* _error__defines_h_ */ diff --git a/test/btyacc/expr.oxout.error b/test/btyacc/expr.oxout.error deleted file mode 100644 index 58fdb1c267f..00000000000 --- a/test/btyacc/expr.oxout.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - line 6 of "expr.Y", the precedence of '*' has been redeclared diff --git a/test/btyacc/expr.oxout.output b/test/btyacc/expr.oxout.output deleted file mode 100644 index e5021d2de45..00000000000 --- a/test/btyacc/expr.oxout.output +++ /dev/null @@ -1,227 +0,0 @@ - 0 $accept : yyyAugNonterm $end - - 1 $$1 : - - 2 yyyAugNonterm : $$1 s - - 3 s : expr - - 4 expr : expr '*' expr - 5 | expr '+' expr - 6 | expr '/' expr - 7 | expr '-' expr - 8 | '(' expr ')' - 9 | ID - 10 | CONST - -state 0 - $accept : . yyyAugNonterm $end (0) - $$1 : . (1) - - . reduce 1 - - yyyAugNonterm goto 1 - $$1 goto 2 - - -state 1 - $accept : yyyAugNonterm . $end (0) - - $end accept - - -state 2 - yyyAugNonterm : $$1 . s (2) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - s goto 6 - expr goto 7 - - -state 3 - expr : ID . (9) - - . reduce 9 - - -state 4 - expr : CONST . (10) - - . reduce 10 - - -state 5 - expr : '(' . expr ')' (8) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 8 - - -state 6 - yyyAugNonterm : $$1 s . (2) - - . reduce 2 - - -state 7 - s : expr . (3) - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - - '+' shift 9 - '-' shift 10 - '*' shift 11 - '/' shift 12 - $end reduce 3 - - -state 8 - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - expr : '(' expr . ')' (8) - - '+' shift 9 - '-' shift 10 - '*' shift 11 - '/' shift 12 - ')' shift 13 - . error - - -state 9 - expr : expr '+' . expr (5) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 14 - - -state 10 - expr : expr '-' . expr (7) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 15 - - -state 11 - expr : expr '*' . expr (4) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 16 - - -state 12 - expr : expr '/' . expr (6) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 17 - - -state 13 - expr : '(' expr ')' . (8) - - . reduce 8 - - -state 14 - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr '+' expr . (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - - '*' shift 11 - '/' shift 12 - $end reduce 5 - '+' reduce 5 - '-' reduce 5 - ')' reduce 5 - - -state 15 - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - expr : expr '-' expr . (7) - - '*' shift 11 - '/' shift 12 - $end reduce 7 - '+' reduce 7 - '-' reduce 7 - ')' reduce 7 - - -state 16 - expr : expr . '*' expr (4) - expr : expr '*' expr . (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - - . reduce 4 - - -state 17 - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr '/' expr . (6) - expr : expr . '-' expr (7) - - '*' shift 11 - $end reduce 6 - '+' reduce 6 - '-' reduce 6 - '/' reduce 6 - ')' reduce 6 - - -10 terminals, 5 nonterminals -11 grammar rules, 18 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 ID - 3 258 CONST - 4 43 '+' - 5 45 '-' - 6 42 '*' - 7 47 '/' - 8 40 '(' - 9 41 ')' - 10 259 $accept - 11 260 yyyAugNonterm - 12 261 s - 13 262 $$1 - 14 263 expr diff --git a/test/btyacc/expr.oxout.tab.c b/test/btyacc/expr.oxout.tab.c deleted file mode 100644 index 92952b1092c..00000000000 --- a/test/btyacc/expr.oxout.tab.c +++ /dev/null @@ -1,2768 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 expr_oxout_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex expr_oxout_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror expr_oxout_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar expr_oxout_char -#endif /* yychar */ - -#ifndef yyval -#define yyval expr_oxout_val -#endif /* yyval */ - -#ifndef yylval -#define yylval expr_oxout_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug expr_oxout_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs expr_oxout_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag expr_oxout_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs expr_oxout_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen expr_oxout_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred expr_oxout_defred -#endif /* yydefred */ - -#ifndef yystos -#define yystos expr_oxout_stos -#endif /* yystos */ - -#ifndef yydgoto -#define yydgoto expr_oxout_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex expr_oxout_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex expr_oxout_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex expr_oxout_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable expr_oxout_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck expr_oxout_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname expr_oxout_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule expr_oxout_rule -#endif /* yyrule */ - -#if YYBTYACC - -#ifndef yycindex -#define yycindex expr_oxout_cindex -#endif /* yycindex */ - -#ifndef yyctable -#define yyctable expr_oxout_ctable -#endif /* yyctable */ - -#endif /* YYBTYACC */ - -#define YYPREFIX "expr_oxout_" - -#define YYPURE 0 - -#line 5 "expr.oxout.y" -#include -#include -#line 8 "expr.Y" - -#include "expr.oxout.h" -#include - -extern int yylex(void); -extern void yyerror(const char *); -#line 27 "expr.oxout.y" -#include -#define yyyR USHRT_MAX -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 31 "expr.oxout.y" -typedef union YYSTYPE { -struct yyyOxAttrbs { -struct yyyStackItem *yyyOxStackItem; -} yyyOxAttrbs; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -#line 38 "expr.oxout.y" -#include -#include - -static int yyyYok = 1; - -extern yyyFT yyyRCIL[]; - -void yyyExecuteRRsection(yyyGNT *rootNode); -void yyyYoxInit(void); -void yyyDecorate(void); -struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ -void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); -void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); -void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); -void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); -void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); -void yyyabort(void); - -#line 166 "expr.oxout.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 ID 257 -#define CONST 258 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT expr_oxout_lhs[] = { -1, - 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, -}; -static const YYINT expr_oxout_len[] = { 2, - 0, 2, 1, 3, 3, 3, 3, 3, 1, 1, -}; -static const YYINT expr_oxout_defred[] = { 1, - 0, 0, 9, 10, 0, 2, 0, 0, 0, 0, - 0, 0, 8, 0, 0, 4, 0, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT expr_oxout_stos[] = { 0, - 260, 262, 257, 258, 40, 261, 263, 263, 43, 45, - 42, 47, 41, 263, 263, 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT expr_oxout_dgoto[] = { 1, - 6, 2, 7, -}; -static const YYINT expr_oxout_sindex[] = { 0, - 0, -40, 0, 0, -40, 0, -18, -24, -40, -40, - -40, -40, 0, -37, -37, 0, -39, -}; -static const YYINT expr_oxout_rindex[] = { 0, - 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, - 0, 0, 0, 2, 8, 0, 1, -}; -#if YYBTYACC -static const YYINT expr_oxout_cindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -}; -#endif -static const YYINT expr_oxout_gindex[] = { 0, - 0, 0, 4, -}; -#define YYTABLESIZE 218 -static const YYINT expr_oxout_table[] = { 5, - 6, 5, 11, 0, 11, 3, 0, 7, 8, 12, - 0, 0, 14, 15, 16, 17, 13, 11, 9, 0, - 10, 0, 12, 11, 9, 0, 10, 0, 12, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 6, 5, 6, 5, 6, 5, 6, 7, 0, - 7, 0, 7, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3, 4, -}; -static const YYINT expr_oxout_check[] = { 40, - 0, 0, 42, -1, 42, 0, -1, 0, 5, 47, - -1, -1, 9, 10, 11, 12, 41, 42, 43, -1, - 45, -1, 47, 42, 43, -1, 45, -1, 47, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 41, 41, 43, 43, 45, 45, 47, 41, -1, - 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 257, 258, -}; -#if YYBTYACC -static const YYINT expr_oxout_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 258 -#define YYUNDFTOKEN 264 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const expr_oxout_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,"error","ID", -"CONST","$accept","yyyAugNonterm","s","$$1","expr","illegal-symbol", -}; -static const char *const expr_oxout_rule[] = { -"$accept : yyyAugNonterm", -"$$1 :", -"yyyAugNonterm : $$1 s", -"s : expr", -"expr : expr '*' expr", -"expr : expr '+' expr", -"expr : expr '/' expr", -"expr : expr '-' expr", -"expr : '(' expr ')'", -"expr : ID", -"expr : CONST", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 53 "expr.Y" - - -int yyparse(void); - -int main() - {yyparse(); - } - - - -#line 138 "expr.oxout.y" -long yyySSALspaceSize = 20000; -long yyyRSmaxSize = 1000; -long yyyTravStackMaxSize = 2000; - -struct yyySolvedSAlistCell {yyyWAT attrbNum; - long next; - }; - -#define yyyLambdaSSAL 0 -long yyySSALCfreeList = yyyLambdaSSAL; -long yyyNewSSALC = 1; - -struct yyySolvedSAlistCell *yyySSALspace; - -long yyyNbytesStackStg; - - - -yyyFT yyyRCIL[1]; - -short yyyIIIEL[] = {0, -0,2,6,10,14,18,22,24, -}; - -long yyyIIEL[] = { -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,1, -}; - -long yyyIEL[] = { -0,0,0, -}; - -yyyFT yyyEntL[1]; - -void yyyfatal(char *msg) -{fputs(msg,stderr);exit(-1);} - - - -#define yyySSALof 'S' -#define yyyRSof 'q' -#define yyyTSof 't' - - - -void yyyHandleOverflow(char which) - {char *msg1 = "?", *msg2; - long oldSize = 0, newSize; - switch(which) - { - case yyySSALof : - msg1 = "SSAL overflow: "; - oldSize = yyySSALspaceSize; - break; - case yyyRSof : - msg1 = "ready set overflow: "; - oldSize = yyyRSmaxSize; - break; - case yyyTSof : - msg1 = "traversal stack overflow: "; - oldSize = yyyTravStackMaxSize; - break; - default :; - } - newSize = (3*oldSize)/2; - if (newSize < 100) newSize = 100; - fputs(msg1,stderr); - fprintf(stderr,"size was %ld.\n",oldSize); - msg2 = " Have to modify evaluator: -Y%c%ld.\n"; - fprintf(stderr,msg2,which,newSize); - exit(-1); - } - - - -void yyySignalEnts(yyyGNT *node,long startP,long stopP) - {yyyGNT *dumNode; - - while (startP < stopP) - { - if (!yyyEntL[startP]) dumNode = node; - else dumNode = (node->cL)[yyyEntL[startP]-1]; - if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] - ) - ) - ) - { - if (++yyyRSTop == yyyAfterRS) - {yyyHandleOverflow(yyyRSof); - break; - } - yyyRSTop->node = dumNode; - yyyRSTop->whichSym = yyyEntL[startP]; - yyyRSTop->wa = yyyEntL[startP+1]; - } - startP += 2; - } - } - - - - - - -void yyySolveAndSignal() { -long yyyiDum,*yyypL; -int yyyws,yyywa; -yyyGNT *yyyRSTopN,*yyyRefN; -yyyParent yyyRSTopNp; - - -yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; -yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; -yyywa = yyyRSTop->wa; -yyyRSTop--; -switch(yyyRefN->prodNum) { -case 1: /***yacc rule 1***/ - switch (yyyws) { - } -break; -case 2: /***yacc rule 2***/ - switch (yyyws) { - } -break; -case 3: /***yacc rule 3***/ - switch (yyyws) { - } -break; -case 4: /***yacc rule 4***/ - switch (yyyws) { - } -break; -case 5: /***yacc rule 5***/ - switch (yyyws) { - } -break; -case 6: /***yacc rule 6***/ - switch (yyyws) { - } -break; -case 7: /***yacc rule 7***/ - switch (yyyws) { - case 1: /**/ - switch (yyywa) { - } - break; - } -break; -case 8: /***yacc rule 8***/ - switch (yyyws) { - case 1: /**/ - switch (yyywa) { - } - break; - } -break; -} /* switch */ - -if (yyyws) /* the just-solved instance was inherited. */ - {if (yyyRSTopN->prodNum) - {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; - yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], - yyyIEL[yyyiDum+1] - ); - } - } - else /* the just-solved instance was synthesized. */ - {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ - {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + - yyyRSTopN->whichSym - ] + - yyywa; - yyySignalEnts(yyyRSTopNp.noderef, - yyyIEL[yyyiDum], - yyyIEL[yyyiDum+1] - ); - } - else /* node is still on the stack--it has no parent yet. */ - {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); - if (yyySSALCfreeList == yyyLambdaSSAL) - {yyySSALspace[yyyNewSSALC].next = *yyypL; - if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) - yyyHandleOverflow(yyySSALof); - } - else - {yyyiDum = yyySSALCfreeList; - yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; - yyySSALspace[yyyiDum].next = *yyypL; - *yyypL = yyyiDum; - } - yyySSALspace[*yyypL].attrbNum = yyywa; - } - } - -} /* yyySolveAndSignal */ - - - - - - -#define condStg unsigned int conds; -#define yyyClearConds {yyyTST->conds = 0;} -#define yyySetCond(n) {yyyTST->conds += (1<<(n));} -#define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) - - - -struct yyyTravStackItem {yyyGNT *node; - char isReady; - condStg - }; - - - -void yyyDoTraversals(yyyGNT *rootNode) -{struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; - yyyGNT *yyyTSTn,**yyyCLptr2; - int yyyi,yyyRL,yyyPass; - int i; - - if (!yyyYok) return; - if ((yyyTravStack = - ((struct yyyTravStackItem *) - calloc((size_t)yyyTravStackMaxSize, - (size_t)sizeof(struct yyyTravStackItem) - ) - ) - ) - == - (struct yyyTravStackItem *)NULL - ) - {fputs("malloc error in traversal stack allocation\n",stderr); - exit(-1); - } - -yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; -yyyTravStack++; - - -for (yyyi=0; yyyi<2; yyyi++) { -yyyTST = yyyTravStack; -yyyTST->node = rootNode; -yyyTST->isReady = 0; -yyyClearConds - -while(yyyTST >= yyyTravStack) - {yyyTSTn = yyyTST->node; - if (yyyTST->isReady) - {yyyPass = 1; - goto yyyTravSwitch; -yyyTpop: - yyyTST--; - } - else - {yyyPass = 0; - goto yyyTravSwitch; -yyyTpush: - yyyTST->isReady = 1; - if (yyyTSTn->prodNum) - {if (yyyRL) - {yyyCLptr2 = yyyTSTn->cL; - i = yyyTSTn->cLlen; - while (i--) - {if (++yyyTST == yyyAfterTravStack) - yyyHandleOverflow(yyyTSof); - else - {yyyTST->node = *yyyCLptr2; - yyyTST->isReady = 0; - yyyClearConds - } - yyyCLptr2++; - } - } /* right to left */ - else /* left to right */ - {i = yyyTSTn->cLlen; - yyyCLptr2 = yyyTSTn->cL + i; - while (i--) - {yyyCLptr2--; - if (++yyyTST == yyyAfterTravStack) - yyyHandleOverflow(yyyTSof); - else - {yyyTST->node = *yyyCLptr2; - yyyTST->isReady = 0; - yyyClearConds - } - } - } /* left to right */ - } - } /* else */ - continue; -yyyTravSwitch: - switch(yyyTSTn->prodNum) { -case 1: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - -if (! -#line 24 "expr.Y" - (1) -#line 444 "expr.oxout.y" -) yyySetCond(1) -yyySetCond(2) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 24 "expr.Y" - -#line 453 "expr.oxout.y" -} -if (yyyCond(1) != yyyPass) { -#line 24 "expr.Y" - printf("\n"); - -#line 459 "expr.oxout.y" -} -if (yyyCond(2) != yyyPass) { -#line 25 "expr.Y" - printf("prefix: "); - -#line 465 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; -if ( -#line 23 "expr.Y" - (1) -#line 477 "expr.oxout.y" -) yyySetCond(2) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 22 "expr.Y" - printf("\n"); - -#line 486 "expr.oxout.y" -} -if (yyyCond(1) != yyyPass) { -#line 23 "expr.Y" - -#line 491 "expr.oxout.y" -} -if (yyyCond(2) != yyyPass) { -#line 23 "expr.Y" - printf("postfix: "); - -#line 497 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 2: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 29 "expr.Y" - printf(" * "); - -#line 518 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 28 "expr.Y" - printf(" * "); - -#line 533 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 3: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 32 "expr.Y" - printf(" + "); - -#line 554 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 33 "expr.Y" - printf(" + "); - -#line 569 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 4: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 37 "expr.Y" - printf(" / "); - -#line 590 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 36 "expr.Y" - printf(" / "); - -#line 605 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 5: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 41 "expr.Y" - printf(" - "); - -#line 626 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 40 "expr.Y" - printf(" - "); - -#line 641 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 6: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - - break; - } - break; - } - -break; -case 7: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 46 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 685 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 45 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 700 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 8: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 50 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 721 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 49 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 736 "expr.oxout.y" -} - break; - } - break; - } - -break; - } /* switch */ - if (yyyPass) goto yyyTpop; else goto yyyTpush; - } /* while */ - } /* for */ -} /* yyyDoTraversals */ - -void yyyExecuteRRsection(yyyGNT *rootNode) { - int yyyi; - long cycleSum = 0; - long nNZrc = 0; - - if (!yyyYok) return; - yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); - if (nNZrc) - { - fputs("\n\n\n**********\n",stderr); - fputs("cycle detected in completed parse tree",stderr); - fputs(" after decoration.\n",stderr); -#if CYCLE_VERBOSE - fprintf(stderr, - "number of unsolved attribute instances == %ld.\n", - nNZrc - ); - fprintf(stderr, - "total number of remaining dependencies == %ld.\n", - cycleSum - ); - fputs("average number of remaining dependencies\n",stderr); - fprintf(stderr," per unsolved instance == %f.\n", - ((float)(cycleSum)/(float)(nNZrc)) - ); -#endif - fprintf(stderr, - "searching parse tree for %ld unsolved instances:\n", - nNZrc - ); - yyyUnsolvedInstSearchTravAux(rootNode); - } - yyyDoTraversals(rootNode); -} /* yyyExecuteRRsection */ - - - -yyyWAT yyyLRCIL[2] = {0,0, -}; - - - -void yyyYoxInit(void) - { - static int yyyInitDone = 0; - if (yyyInitDone) return; - - if ((yyyRS = (yyyRSitem *) - calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(yyyRSitem)) - ) - == - ((yyyRSitem *) NULL) - ) - yyyfatal("malloc error in ox ready set space allocation\n"); - yyyRS++; - yyyAfterRS = yyyRS + yyyRSmaxSize; - - - if ((yyySSALspace = (struct yyySolvedSAlistCell *) - calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) - ) - == - ((struct yyySolvedSAlistCell *) NULL) - ) - yyyfatal("malloc error in stack solved list space allocation\n"); - yyyInitDone = 1; - - yyyRSTop = yyyRS - 1; - } /* yyyYoxInit */ - - - -void yyyDecorate(void) - { - while (yyyRSTop >= yyyRS) - yyySolveAndSignal(); - } - - - -void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) - {yyyWST i; - yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; - yyyGNT *gnpDum; - va_list ap; - - *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); - if (*yyyOxStackItem == (yyySIT *) NULL) - yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); - (*yyyOxStackItem)->node = - (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); - if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) - yyyfatal("malloc error in ox node space allocation\n"); - (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; - (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; - (*yyyOxStackItem)->node->parentIsStack = 1; - (*yyyOxStackItem)->node->cLlen = yyyRHSlength; - (*yyyOxStackItem)->node->cL = - (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); - if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) - yyyfatal("malloc error in ox child list space allocation\n"); - (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; - (*yyyOxStackItem)->node->refCountList = - (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); - if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) - yyyfatal("malloc error in ox reference count list space allocation\n"); - (*yyyOxStackItem)->node->prodNum = (int) yyyProdNum; - va_start(ap, yyval_OxAttrbs); - for (i=1;i<=yyyRHSlength;i++) - {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; - gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; - gnpDum->whichSym = i; - gnpDum->parent.noderef = (*yyyOxStackItem)->node; - gnpDum->parentIsStack = 0; - } - va_end(ap); - } - - - -#define yyyDECORfREQ 50 - - - -void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) - {yyyWST i; - yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; - long SSALptr,SSALptrHead,*cPtrPtr; - long *pL; - yyyGNT *gnpDum; - long iTemp; - long nextP; - static unsigned short intNodeCount = yyyDECORfREQ; - va_list ap; - - nextP = startP; - while (nextP < stopP) - {if (yyyRCIL[nextP] == yyyR) - {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; - } - else - {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; - } - nextP += 3; - } - pL = yyyIIEL + yyyIIIEL[yyyProdNum]; - va_start(ap, yyval_OxAttrbs); - for (i=1;i<=yyyRHSlength;i++) - {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; - pL++; - SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); - if (SSALptr != yyyLambdaSSAL) - {*cPtrPtr = yyyLambdaSSAL; - do - { - iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); - yyySignalEnts(yyyOxStackItem->node, - yyyIEL[iTemp], - yyyIEL[iTemp+1] - ); - SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); - } - while (SSALptr != yyyLambdaSSAL); - *cPtrPtr = yyySSALCfreeList; - yyySSALCfreeList = SSALptrHead; - } - } - va_end(ap); - nextP = startP + 2; - while (nextP < stopP) - {if (!yyyRCIL[nextP]) - {if (yyyRCIL[nextP-2] == yyyR) - {pL = &(yyyOxStackItem->solvedSAlist); - if (yyySSALCfreeList == yyyLambdaSSAL) - {yyySSALspace[yyyNewSSALC].next = *pL; - if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) - yyyHandleOverflow(yyySSALof); - } - else - {iTemp = yyySSALCfreeList; - yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; - yyySSALspace[iTemp].next = *pL; - *pL = iTemp; - } - yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; - } - else - {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) - { - iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; - yyySignalEnts(gnpDum, - yyyIEL[iTemp], - yyyIEL[iTemp+1] - ); - } - } - } - nextP += 3; - } - if (!--intNodeCount) - {intNodeCount = yyyDECORfREQ; - yyyDecorate(); - } - } - - - -void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *mylval) - {yyyRCT *rcPdum; - yyySIT **yyyOxStackItem = &mylval->yyyOxAttrbs.yyyOxStackItem; - (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); - if ((*yyyOxStackItem) == (yyySIT *) NULL) - yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); - (*yyyOxStackItem)->node = - (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) - ; - if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) - yyyfatal("malloc error in ox node space allocation\n"); - (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; - (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; - (*yyyOxStackItem)->node->parentIsStack = 1; - (*yyyOxStackItem)->node->cLlen = 0; - (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; - (*yyyOxStackItem)->node->refCountListLen = nAttrbs; - rcPdum = (*yyyOxStackItem)->node->refCountList = - (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); - if (rcPdum == (yyyRCT *) NULL) - yyyfatal("malloc error in ox reference count list space allocation\n"); - while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; - (*yyyOxStackItem)->node->prodNum = 0; - (*yyyOxStackItem)->node->whichSym = 0; - } - - - -void yyyabort(void) - {yyyYok = 0; - } - - - - - -#define yyyLastProdNum 8 - - -#define yyyNsorts 1 - - -int yyyProdsInd[] = { - 0, - 0, 2, 6, 10, 14, 18, 22, 24, - 26, -}; - - -int yyyProds[][2] = { -{ 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, -{ 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, -{ 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, -{ 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, -{ 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, -{ 567, 1}, -}; - - -int yyySortsInd[] = { - 0, - 0, - 1, -}; - - -int yyySorts[] = { - 413, -}; - - - -char *yyyStringTab[] = { -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"s",0,0,0, -0,0,"y",0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"LRpre",0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"'('",0,0,0, -0,0,0,0,"')'", -0,0,0,0,0, -0,0,"'*'","lexeme",0, -0,0,0,0,0, -"'+'",0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"'-'",0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,"'/'",0,0, -0,0,0,0,0, -0,0,"expr",0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"printf",0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,"CONST","LRpost",0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,"ID", -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0, -}; - - - -#define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) - -#define yyyGSoccurStr(prodNum,symPos) \ - (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) - -#define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) - -#define yyySortOf(prodNum,symPos) \ - (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) - -#define yyyAttrbStr(prodNum,symPos,attrbNum) \ - (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ - (attrbNum) \ - ] \ - ] \ - ) - - - -void yyyShowProd(int i) - {int j,nSyms; - - nSyms = yyySizeofProd(i); - for (j=0; j\n",stderr); - else - putc('\n',stderr); - } - } - } - - - -void yyyCheckNodeInstancesSolved(yyyGNT *np) - {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; - int nUnsolvedInsts = 0; - - if (np->prodNum != 0) - {inTerminalNode = 0; - prodNum = np->prodNum; - symPos = 0; - } - else - {inTerminalNode = 1; - prodNum = np->parent.noderef->prodNum; - symPos = np->whichSym; - } - mysort = yyySortOf(prodNum,symPos); - sortSize = yyySizeofSort(mysort); - for (i=0; irefCountList)[i] != 0) nUnsolvedInsts += 1; - if (nUnsolvedInsts) - {fprintf(stderr, - "\nFound node that has %d unsolved attribute instance(s).\n", - nUnsolvedInsts - ); - fprintf(stderr,"Node is labeled \"%s\".\n", - yyyGSoccurStr(prodNum,symPos)); - if (inTerminalNode) - {fputs("Node is terminal. Its parent production is:\n ",stderr); - yyyShowProd(prodNum); - } - else - {fputs("Node is nonterminal. ",stderr); - if (!(np->parentIsStack)) - {fprintf(stderr, - "Node is %dth child in its parent production:\n ", - np->whichSym - ); - yyyShowProd(np->parent.noderef->prodNum); - } - fputs("Node is on left hand side of this production:\n ",stderr); - yyyShowProd(np->prodNum); - } - fputs("The following instances are unsolved:\n",stderr); - for (i=0; irefCountList)[i] != 0) - fprintf(stderr," %-16s still has %1d dependencies.\n", - yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); - } - } - - - -void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) - {yyyGNT **yyyCLpdum; - yyyRCT *rcp; - int i; - - /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ - rcp = pNode->refCountList; - i = pNode->refCountListLen; - while (i--) - if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} - yyyCLpdum = pNode->cL; - i = pNode->cLlen; - while (i--) - { - yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); - yyyCLpdum++; - } - } - - - -void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) - {yyyGNT **yyyCLpdum; - int i; - - yyyCheckNodeInstancesSolved(pNode); - yyyCLpdum = pNode->cL; - i = pNode->cLlen; - while (i--) - { - yyyUnsolvedInstSearchTravAux(*yyyCLpdum); - yyyCLpdum++; - } - } - - - -void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) - {yyyGNT **yyyCLpdum; - int i; - - yyyCLpdum = pNode->cL; - i = pNode->cLlen; - while (i--) - { - yyyUnsolvedInstSearchTravAux(*yyyCLpdum); - yyyCLpdum++; - } - } - - - -#line 1797 "expr.oxout.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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: -#line 64 "expr.oxout.y" - {yyyYoxInit();} -#line 2470 "expr.oxout.tab.c" -break; -case 2: -#line 66 "expr.oxout.y" - { - yyyDecorate(); yyyExecuteRRsection(yystack.l_mark[0].yyyOxAttrbs.yyyOxStackItem->node); - } -#line 2477 "expr.oxout.tab.c" -break; -case 3: -#line 73 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(1,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(1,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 2484 "expr.oxout.tab.c" -break; -case 4: -#line 80 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(2,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(2,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 2491 "expr.oxout.tab.c" -break; -case 5: -#line 87 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(3,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(3,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 2498 "expr.oxout.tab.c" -break; -case 6: -#line 94 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(4,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(4,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 2505 "expr.oxout.tab.c" -break; -case 7: -#line 101 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(5,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(5,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 2512 "expr.oxout.tab.c" -break; -case 8: -#line 108 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(6,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(6,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 2519 "expr.oxout.tab.c" -break; -case 9: -#line 114 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(7,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(7,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 2526 "expr.oxout.tab.c" -break; -case 10: -#line 121 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 2533 "expr.oxout.tab.c" -break; -#line 2535 "expr.oxout.tab.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/expr.oxout.tab.h b/test/btyacc/expr.oxout.tab.h deleted file mode 100644 index cafc41cae56..00000000000 --- a/test/btyacc/expr.oxout.tab.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _expr_oxout__defines_h_ -#define _expr_oxout__defines_h_ - -#define ID 257 -#define CONST 258 -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE { -struct yyyOxAttrbs { -struct yyyStackItem *yyyOxStackItem; -} yyyOxAttrbs; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE expr_oxout_lval; - -#endif /* _expr_oxout__defines_h_ */ diff --git a/test/btyacc/grammar.dot b/test/btyacc/grammar.dot deleted file mode 100644 index 1988e12ddd6..00000000000 --- a/test/btyacc/grammar.dot +++ /dev/null @@ -1,906 +0,0 @@ -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/test/btyacc/grammar.error b/test/btyacc/grammar.error deleted file mode 100644 index d442f8abaeb..00000000000 --- a/test/btyacc/grammar.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 1 shift/reduce conflict, 29 reduce/reduce conflicts. diff --git a/test/btyacc/grammar.output b/test/btyacc/grammar.output deleted file mode 100644 index 8000cca1ae2..00000000000 --- a/test/btyacc/grammar.output +++ /dev/null @@ -1,2304 +0,0 @@ - 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/test/btyacc/grammar.tab.c b/test/btyacc/grammar.tab.c deleted file mode 100644 index 0dec5d6bcaf..00000000000 --- a/test/btyacc/grammar.tab.c +++ /dev/null @@ -1,3010 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3) - -/* 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 409 "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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT grammar_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -}; -#endif -#define YYFINAL 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 1015 "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 occurrences 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 1351 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 10: -#line 378 "grammar.y" - { - yyerrok; - } -#line 2026 "grammar.tab.c" -break; -case 11: -#line 382 "grammar.y" - { - yyerrok; - } -#line 2033 "grammar.tab.c" -break; -case 13: -#line 393 "grammar.y" - { - /* Provide an empty action here so bison will not complain about - * incompatible types in the default action it normally would - * have generated. - */ - } -#line 2043 "grammar.tab.c" -break; -case 14: -#line 400 "grammar.y" - { - /* empty */ - } -#line 2050 "grammar.tab.c" -break; -case 15: -#line 407 "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(); - } -#line 2064 "grammar.tab.c" -break; -case 16: -#line 418 "grammar.y" - { - if (func_params != NULL) { - set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); - } 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(); - } -#line 2081 "grammar.tab.c" -break; -case 17: -#line 432 "grammar.y" - { - cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags; - free_decl_spec(&yystack.l_mark[0].decl_spec); - } -#line 2089 "grammar.tab.c" -break; -case 18: -#line 437 "grammar.y" - { - end_typedef(); - } -#line 2096 "grammar.tab.c" -break; -case 19: -#line 444 "grammar.y" - { - begin_typedef(); - } -#line 2103 "grammar.tab.c" -break; -case 20: -#line 448 "grammar.y" - { - begin_typedef(); - } -#line 2110 "grammar.tab.c" -break; -case 23: -#line 460 "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); - } -#line 2125 "grammar.tab.c" -break; -case 24: -#line 472 "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); - } -#line 2137 "grammar.tab.c" -break; -case 25: -#line 484 "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; - } -#line 2151 "grammar.tab.c" -break; -case 26: -#line 495 "grammar.y" - { - /* If we're converting to K&R and we've got a nominally K&R - * function which has a parameter which is ANSI (i.e., a prototyped - * 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); - } -#line 2178 "grammar.tab.c" -break; -case 28: -#line 520 "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; - } -#line 2191 "grammar.tab.c" -break; -case 29: -#line 530 "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); - } -#line 2210 "grammar.tab.c" -break; -case 36: -#line 561 "grammar.y" - { - join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec); - free(yystack.l_mark[-1].decl_spec.text); - free(yystack.l_mark[0].decl_spec.text); - } -#line 2219 "grammar.tab.c" -break; -case 40: -#line 576 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2226 "grammar.tab.c" -break; -case 41: -#line 580 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN); - } -#line 2233 "grammar.tab.c" -break; -case 42: -#line 584 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2240 "grammar.tab.c" -break; -case 43: -#line 588 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC); - } -#line 2247 "grammar.tab.c" -break; -case 44: -#line 592 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE); - } -#line 2254 "grammar.tab.c" -break; -case 45: -#line 596 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK); - } -#line 2261 "grammar.tab.c" -break; -case 46: -#line 603 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); - } -#line 2268 "grammar.tab.c" -break; -case 47: -#line 607 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2275 "grammar.tab.c" -break; -case 48: -#line 611 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT); - } -#line 2282 "grammar.tab.c" -break; -case 49: -#line 615 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2289 "grammar.tab.c" -break; -case 50: -#line 619 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2296 "grammar.tab.c" -break; -case 51: -#line 623 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT); - } -#line 2303 "grammar.tab.c" -break; -case 52: -#line 627 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2310 "grammar.tab.c" -break; -case 53: -#line 631 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2317 "grammar.tab.c" -break; -case 54: -#line 635 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2324 "grammar.tab.c" -break; -case 55: -#line 639 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); - } -#line 2331 "grammar.tab.c" -break; -case 56: -#line 643 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2338 "grammar.tab.c" -break; -case 57: -#line 647 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2345 "grammar.tab.c" -break; -case 58: -#line 651 "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); - } -#line 2355 "grammar.tab.c" -break; -case 61: -#line 663 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 2362 "grammar.tab.c" -break; -case 62: -#line 667 "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); - } -#line 2375 "grammar.tab.c" -break; -case 63: -#line 680 "grammar.y" - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-2].text.text, TEXT_LEN, yystack.l_mark[-1].text.text); - new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); - } -#line 2385 "grammar.tab.c" -break; -case 64: -#line 687 "grammar.y" - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); - new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); - } -#line 2395 "grammar.tab.c" -break; -case 65: -#line 694 "grammar.y" - { - (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); - new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); - } -#line 2403 "grammar.tab.c" -break; -case 66: -#line 702 "grammar.y" - { - imply_typedef(yyval.text.text); - } -#line 2410 "grammar.tab.c" -break; -case 67: -#line 706 "grammar.y" - { - imply_typedef(yyval.text.text); - } -#line 2417 "grammar.tab.c" -break; -case 68: -#line 713 "grammar.y" - { - new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator); - } -#line 2424 "grammar.tab.c" -break; -case 69: -#line 717 "grammar.y" - { - add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator); - } -#line 2431 "grammar.tab.c" -break; -case 70: -#line 724 "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; - } -#line 2443 "grammar.tab.c" -break; -case 71: -#line 733 "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); - } - } -#line 2454 "grammar.tab.c" -break; -case 73: -#line 745 "grammar.y" - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, yystack.l_mark[-1].text.text); - new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); - } -#line 2464 "grammar.tab.c" -break; -case 74: -#line 752 "grammar.y" - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); - new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); - } -#line 2474 "grammar.tab.c" -break; -case 75: -#line 759 "grammar.y" - { - (void)sprintf(buf, "enum %.*s", TEXT_LEN, yystack.l_mark[0].text.text); - new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); - } -#line 2482 "grammar.tab.c" -break; -case 76: -#line 767 "grammar.y" - { - imply_typedef("enum"); - yyval.text = yystack.l_mark[0].text; - } -#line 2490 "grammar.tab.c" -break; -case 79: -#line 780 "grammar.y" - { - yyval.declarator = yystack.l_mark[0].declarator; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - yyval.declarator->begin = yystack.l_mark[-1].text.begin; - yyval.declarator->pointer = TRUE; - } -#line 2502 "grammar.tab.c" -break; -case 81: -#line 793 "grammar.y" - { - yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin); - } -#line 2509 "grammar.tab.c" -break; -case 82: -#line 797 "grammar.y" - { - yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - yyval.declarator->begin = yystack.l_mark[-2].text.begin; - } -#line 2520 "grammar.tab.c" -break; -case 83: -#line 805 "grammar.y" - { - yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - } -#line 2530 "grammar.tab.c" -break; -case 84: -#line 812 "grammar.y" - { - yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); - yyval.declarator->params = yystack.l_mark[-1].param_list; - 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; - } -#line 2541 "grammar.tab.c" -break; -case 85: -#line 820 "grammar.y" - { - yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); - yyval.declarator->params = yystack.l_mark[-1].param_list; - 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; - } -#line 2552 "grammar.tab.c" -break; -case 86: -#line 831 "grammar.y" - { - (void)sprintf(yyval.text.text, "*%.*s", TEXT_LEN, yystack.l_mark[0].text.text); - yyval.text.begin = yystack.l_mark[-1].text.begin; - } -#line 2560 "grammar.tab.c" -break; -case 87: -#line 836 "grammar.y" - { - (void)sprintf(yyval.text.text, "*%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); - yyval.text.begin = yystack.l_mark[-2].text.begin; - } -#line 2568 "grammar.tab.c" -break; -case 88: -#line 844 "grammar.y" - { - strcpy(yyval.text.text, ""); - yyval.text.begin = 0L; - } -#line 2576 "grammar.tab.c" -break; -case 90: -#line 853 "grammar.y" - { - (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text); - yyval.text.begin = yystack.l_mark[0].decl_spec.begin; - free(yystack.l_mark[0].decl_spec.text); - } -#line 2585 "grammar.tab.c" -break; -case 91: -#line 859 "grammar.y" - { - (void)sprintf(yyval.text.text, "%.*s%.*s ", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].decl_spec.text); - yyval.text.begin = yystack.l_mark[-1].text.begin; - free(yystack.l_mark[0].decl_spec.text); - } -#line 2594 "grammar.tab.c" -break; -case 93: -#line 869 "grammar.y" - { - add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "..."); - } -#line 2601 "grammar.tab.c" -break; -case 94: -#line 876 "grammar.y" - { - new_param_list(&yyval.param_list, yystack.l_mark[0].parameter); - } -#line 2608 "grammar.tab.c" -break; -case 95: -#line 880 "grammar.y" - { - add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter); - } -#line 2615 "grammar.tab.c" -break; -case 96: -#line 887 "grammar.y" - { - check_untagged(&yystack.l_mark[-1].decl_spec); - yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); - } -#line 2623 "grammar.tab.c" -break; -case 97: -#line 892 "grammar.y" - { - check_untagged(&yystack.l_mark[-1].decl_spec); - yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); - } -#line 2631 "grammar.tab.c" -break; -case 98: -#line 897 "grammar.y" - { - check_untagged(&yystack.l_mark[0].decl_spec); - yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0); - } -#line 2639 "grammar.tab.c" -break; -case 99: -#line 905 "grammar.y" - { - new_ident_list(&yyval.param_list); - } -#line 2646 "grammar.tab.c" -break; -case 101: -#line 913 "grammar.y" - { - new_ident_list(&yyval.param_list); - add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text); - } -#line 2654 "grammar.tab.c" -break; -case 102: -#line 918 "grammar.y" - { - add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text); - } -#line 2661 "grammar.tab.c" -break; -case 103: -#line 925 "grammar.y" - { - yyval.text = yystack.l_mark[0].text; - } -#line 2668 "grammar.tab.c" -break; -case 104: -#line 929 "grammar.y" - { -#if OPT_LINTLIBRARY - if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */ - yyval.text = yystack.l_mark[0].text; - } else -#endif - (void)sprintf(yyval.text.text, "&%.*s", TEXT_LEN, yystack.l_mark[0].text.text); - yyval.text.begin = yystack.l_mark[-1].text.begin; - } -#line 2681 "grammar.tab.c" -break; -case 105: -#line 942 "grammar.y" - { - yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); - } -#line 2688 "grammar.tab.c" -break; -case 106: -#line 946 "grammar.y" - { - yyval.declarator = yystack.l_mark[0].declarator; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - yyval.declarator->begin = yystack.l_mark[-1].text.begin; - } -#line 2699 "grammar.tab.c" -break; -case 108: -#line 958 "grammar.y" - { - yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - yyval.declarator->begin = yystack.l_mark[-2].text.begin; - } -#line 2710 "grammar.tab.c" -break; -case 109: -#line 966 "grammar.y" - { - yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - } -#line 2720 "grammar.tab.c" -break; -case 110: -#line 973 "grammar.y" - { - yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); - } -#line 2727 "grammar.tab.c" -break; -case 111: -#line 977 "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; - } -#line 2738 "grammar.tab.c" -break; -case 112: -#line 985 "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; - } -#line 2748 "grammar.tab.c" -break; -case 113: -#line 992 "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; - } -#line 2762 "grammar.tab.c" -break; -case 114: -#line 1003 "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; - } -#line 2775 "grammar.tab.c" -break; -#line 2777 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/grammar.tab.h b/test/btyacc/grammar.tab.h deleted file mode 100644 index f82e0d3f410..00000000000 --- a/test/btyacc/grammar.tab.h +++ /dev/null @@ -1,40 +0,0 @@ -#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/test/btyacc/help.error b/test/btyacc/help.error deleted file mode 100644 index c4d890b024c..00000000000 --- a/test/btyacc/help.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: error message -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/btyacc/help.output b/test/btyacc/help.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/inherit0.error b/test/btyacc/inherit0.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/inherit0.output b/test/btyacc/inherit0.output deleted file mode 100644 index ee5ca2e500b..00000000000 --- a/test/btyacc/inherit0.output +++ /dev/null @@ -1,165 +0,0 @@ - 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/test/btyacc/inherit0.tab.c b/test/btyacc/inherit0.tab.c deleted file mode 100644 index 5ea73cbcfdd..00000000000 --- a/test/btyacc/inherit0.tab.c +++ /dev/null @@ -1,1354 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT inherit0_stos[] = { 0, - 257, 258, 259, 260, 263, 264, 265, 265, 267, 268, - 261, 266, 269, 261, 266, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT inherit0_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 46 "inherit0.y" - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); -#line 396 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: -#line 20 "inherit0.y" - { yyval = yystack.l_mark[0]; } -#line 1069 "inherit0.tab.c" -break; -case 2: -#line 22 "inherit0.y" - { yyval = yystack.l_mark[0]; } -#line 1074 "inherit0.tab.c" -break; -case 3: -#line 25 "inherit0.y" - { yyval = 1; } -#line 1079 "inherit0.tab.c" -break; -case 4: -#line 26 "inherit0.y" - { yyval = 2; } -#line 1084 "inherit0.tab.c" -break; -case 5: -#line 29 "inherit0.y" - { yyval = 1; } -#line 1089 "inherit0.tab.c" -break; -case 6: -#line 30 "inherit0.y" - { yyval = 2; } -#line 1094 "inherit0.tab.c" -break; -case 7: -#line 34 "inherit0.y" - { mksymbol(yystack.l_mark[-2], yystack.l_mark[-3], yystack.l_mark[0]); } -#line 1099 "inherit0.tab.c" -break; -case 8: -#line 36 "inherit0.y" - { mksymbol(yystack.l_mark[-1], yystack.l_mark[-2], yystack.l_mark[0]); } -#line 1104 "inherit0.tab.c" -break; -case 9: -#line 40 "inherit0.y" - { yyval = 2; } -#line 1109 "inherit0.tab.c" -break; -case 10: -#line 41 "inherit0.y" - { yyval = yystack.l_mark[-2]; } -#line 1114 "inherit0.tab.c" -break; -case 11: -#line 43 "inherit0.y" - { yyval = yystack.l_mark[0]; } -#line 1119 "inherit0.tab.c" -break; -#line 1121 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/inherit0.tab.h b/test/btyacc/inherit0.tab.h deleted file mode 100644 index 50ecd392f8b..00000000000 --- a/test/btyacc/inherit0.tab.h +++ /dev/null @@ -1,10 +0,0 @@ -#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/test/btyacc/inherit1.error b/test/btyacc/inherit1.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/inherit1.output b/test/btyacc/inherit1.output deleted file mode 100644 index 349f1657d94..00000000000 --- a/test/btyacc/inherit1.output +++ /dev/null @@ -1,165 +0,0 @@ - 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/test/btyacc/inherit1.tab.c b/test/btyacc/inherit1.tab.c deleted file mode 100644 index 17bd7ffbee8..00000000000 --- a/test/btyacc/inherit1.tab.c +++ /dev/null @@ -1,1379 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 32 "inherit1.y" -typedef union YYSTYPE -{ - 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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT inherit1_stos[] = { 0, - 257, 258, 259, 260, 263, 266, 267, 267, 265, 268, - 261, 264, 269, 261, 264, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT inherit1_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 74 "inherit1.y" - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); -#line 417 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: -#line 44 "inherit1.y" - { yyval.nlist = yystack.l_mark[0].nlist; } -#line 1090 "inherit1.tab.c" -break; -case 2: -#line 46 "inherit1.y" - { yyval.nlist = yystack.l_mark[0].nlist; } -#line 1095 "inherit1.tab.c" -break; -case 3: -#line 49 "inherit1.y" - { yyval.cval = cGLOBAL; } -#line 1100 "inherit1.tab.c" -break; -case 4: -#line 50 "inherit1.y" - { yyval.cval = cLOCAL; } -#line 1105 "inherit1.tab.c" -break; -case 5: -#line 53 "inherit1.y" - { yyval.tval = tREAL; } -#line 1110 "inherit1.tab.c" -break; -case 6: -#line 54 "inherit1.y" - { yyval.tval = tINTEGER; } -#line 1115 "inherit1.tab.c" -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; - } -#line 1122 "inherit1.tab.c" -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; - } -#line 1129 "inherit1.tab.c" -break; -case 9: -#line 68 "inherit1.y" - { yyval.cval = cLOCAL; } -#line 1134 "inherit1.tab.c" -break; -case 10: -#line 69 "inherit1.y" - { yyval.tval = yystack.l_mark[-2].tval; } -#line 1139 "inherit1.tab.c" -break; -case 11: -#line 71 "inherit1.y" - { yyval.nlist = yystack.l_mark[0].nlist; } -#line 1144 "inherit1.tab.c" -break; -#line 1146 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/inherit1.tab.h b/test/btyacc/inherit1.tab.h deleted file mode 100644 index 41b0e2937d3..00000000000 --- a/test/btyacc/inherit1.tab.h +++ /dev/null @@ -1,25 +0,0 @@ -#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 YYSTYPE -{ - class cval; - type tval; - namelist * nlist; - name id; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE inherit1_lval; - -#endif /* _inherit1__defines_h_ */ diff --git a/test/btyacc/inherit2.error b/test/btyacc/inherit2.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/inherit2.output b/test/btyacc/inherit2.output deleted file mode 100644 index b5df0008ddb..00000000000 --- a/test/btyacc/inherit2.output +++ /dev/null @@ -1,186 +0,0 @@ - 0 $accept : declaration $end - - 1 $$1 : - - 2 $$2 : - - 3 declaration : class type $$1 $$2 namelist - 4 | type locnamelist - - 5 class : GLOBAL - 6 | LOCAL - - 7 type : REAL - 8 | INTEGER - - 9 namelist : namelist NAME - 10 | NAME - - 11 $$3 : - - 12 locnamelist : $$3 $$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 . (5) - - . reduce 5 - - -state 2 - class : LOCAL . (6) - - . reduce 6 - - -state 3 - type : REAL . (7) - - . reduce 7 - - -state 4 - type : INTEGER . (8) - - . reduce 8 - - -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 . locnamelist (4) - $$3 : . (11) - - . reduce 11 - - locnamelist goto 9 - $$3 goto 10 - - -state 8 - declaration : class type . $$1 $$2 namelist (3) - $$1 : . (1) - - . reduce 1 - - $$1 goto 11 - - -state 9 - declaration : type locnamelist . (4) - - . reduce 4 - - -state 10 - locnamelist : $$3 . $$2 namelist (12) - $$2 : . (2) - - . reduce 2 - - $$2 goto 12 - - -state 11 - declaration : class type $$1 . $$2 namelist (3) - $$2 : . (2) - - . reduce 2 - - $$2 goto 13 - - -state 12 - locnamelist : $$3 $$2 . namelist (12) - - NAME shift 14 - . error - - namelist goto 15 - - -state 13 - declaration : class type $$1 $$2 . namelist (3) - - NAME shift 14 - . error - - namelist goto 16 - - -state 14 - namelist : NAME . (10) - - . reduce 10 - - -state 15 - namelist : namelist . NAME (9) - locnamelist : $$3 $$2 namelist . (12) - - NAME shift 17 - $end reduce 12 - - -state 16 - declaration : class type $$1 $$2 namelist . (3) - namelist : namelist . NAME (9) - - NAME shift 17 - $end reduce 3 - - -state 17 - namelist : namelist NAME . (9) - - . reduce 9 - - -7 terminals, 9 nonterminals -13 grammar rules, 18 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/test/btyacc/inherit2.tab.c b/test/btyacc/inherit2.tab.c deleted file mode 100644 index c6a542e3eb3..00000000000 --- a/test/btyacc/inherit2.tab.c +++ /dev/null @@ -1,1439 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 39 "inherit2.y" -typedef union YYSTYPE -{ - 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 int YYINT; -static const YYINT inherit2_lhs[] = { -1, - 5, 6, 0, 0, 3, 3, 4, 4, 1, 1, - 7, 2, -}; -static const YYINT inherit2_len[] = { 2, - 0, 0, 5, 2, 1, 1, 1, 1, 2, 1, - 0, 3, -}; -static const YYINT inherit2_defred[] = { 0, - 5, 6, 7, 8, 0, 0, 11, 1, 4, 2, - 2, 0, 0, 10, 0, 0, 9, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT inherit2_stos[] = { 0, - 257, 258, 259, 260, 263, 266, 267, 267, 265, 270, - 268, 269, 269, 261, 264, 264, 261, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT inherit2_dgoto[] = { 5, - 15, 9, 6, 7, 11, 12, 10, -}; -static const YYINT inherit2_sindex[] = { -257, - 0, 0, 0, 0, 0, -255, 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, 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, -}; -#endif -static const YYINT inherit2_gindex[] = { 0, - -3, 0, 0, 5, 0, 1, 0, -}; -#define YYTABLESIZE 12 -static const YYINT inherit2_table[] = { 1, - 2, 3, 4, 3, 4, 12, 14, 17, 3, 16, - 8, 13, -}; -static const YYINT inherit2_check[] = { 257, - 258, 259, 260, 259, 260, 0, 261, 261, 0, 13, - 6, 11, -}; -#if YYBTYACC -static const YYINT inherit2_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -}; -#endif -#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 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","illegal-symbol", -}; -static const char *const inherit2_rule[] = { -"$accept : declaration", -"$$1 :", -"$$2 :", -"declaration : class type $$1 $$2 namelist", -"declaration : type locnamelist", -"class : GLOBAL", -"class : LOCAL", -"type : REAL", -"type : INTEGER", -"namelist : namelist NAME", -"namelist : NAME", -"$$3 :", -"locnamelist : $$3 $$2 namelist", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 78 "inherit2.y" - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); -#line 424 "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); - } - } -#line 443 "inherit2.tab.c" - break; - case 264: -#line 30 "inherit2.y" - { - namelist *p = (*val).nlist; - while (p != NULL) - { namelist *pp = p; - p = p->next; - free(pp->s); free(pp); - } - } -#line 455 "inherit2.tab.c" - break; - case 265: -#line 30 "inherit2.y" - { - namelist *p = (*val).nlist; - while (p != NULL) - { namelist *pp = p; - p = p->next; - free(pp->s); free(pp); - } - } -#line 467 "inherit2.tab.c" - break; - } -} -#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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 1: -#line 50 "inherit2.y" -yyval.cval = yystack.l_mark[-1].cval; -#line 1145 "inherit2.tab.c" -break; -case 2: -#line 50 "inherit2.y" -yyval.tval = yystack.l_mark[-1].tval; -#line 1150 "inherit2.tab.c" -break; -case 3: -#line 51 "inherit2.y" - { yyval.nlist = yystack.l_mark[0].nlist; } -#line 1155 "inherit2.tab.c" -break; -case 4: -#line 53 "inherit2.y" - { yyval.nlist = yystack.l_mark[0].nlist; } -#line 1160 "inherit2.tab.c" -break; -case 5: -#line 56 "inherit2.y" - { yyval.cval = cGLOBAL; } -#line 1165 "inherit2.tab.c" -break; -case 6: -#line 57 "inherit2.y" - { yyval.cval = cLOCAL; } -#line 1170 "inherit2.tab.c" -break; -case 7: -#line 60 "inherit2.y" - { yyval.tval = tREAL; } -#line 1175 "inherit2.tab.c" -break; -case 8: -#line 61 "inherit2.y" - { yyval.tval = tINTEGER; } -#line 1180 "inherit2.tab.c" -break; -case 9: -#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; - } -#line 1187 "inherit2.tab.c" -break; -case 10: -#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; - } -#line 1194 "inherit2.tab.c" -break; -case 11: -#line 74 "inherit2.y" -yyval.cval = cLOCAL; -#line 1199 "inherit2.tab.c" -break; -case 12: -#line 75 "inherit2.y" - { yyval.nlist = yystack.l_mark[0].nlist; } -#line 1204 "inherit2.tab.c" -break; -#line 1206 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/inherit2.tab.h b/test/btyacc/inherit2.tab.h deleted file mode 100644 index 333dab588b3..00000000000 --- a/test/btyacc/inherit2.tab.h +++ /dev/null @@ -1,25 +0,0 @@ -#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 YYSTYPE -{ - class cval; - type tval; - namelist * nlist; - name id; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE inherit2_lval; - -#endif /* _inherit2__defines_h_ */ diff --git a/test/btyacc/no_b_opt.error b/test/btyacc/no_b_opt.error deleted file mode 100644 index c4d890b024c..00000000000 --- a/test/btyacc/no_b_opt.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: error message -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/btyacc/no_b_opt.output b/test/btyacc/no_b_opt.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_b_opt1.error b/test/btyacc/no_b_opt1.error deleted file mode 100644 index 87286c2661e..00000000000 --- a/test/btyacc/no_b_opt1.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/test/btyacc/no_b_opt1.output b/test/btyacc/no_b_opt1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_code_c.error b/test/btyacc/no_code_c.error deleted file mode 100644 index 87286c2661e..00000000000 --- a/test/btyacc/no_code_c.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/test/btyacc/no_code_c.output b/test/btyacc/no_code_c.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_defines.error b/test/btyacc/no_defines.error deleted file mode 100644 index 773985d66f3..00000000000 --- a/test/btyacc/no_defines.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.h" diff --git a/test/btyacc/no_defines.output b/test/btyacc/no_defines.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_graph.error b/test/btyacc/no_graph.error deleted file mode 100644 index d5575f40042..00000000000 --- a/test/btyacc/no_graph.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.dot" diff --git a/test/btyacc/no_graph.output b/test/btyacc/no_graph.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_include.error b/test/btyacc/no_include.error deleted file mode 100644 index 3ece4a454e3..00000000000 --- a/test/btyacc/no_include.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.i" diff --git a/test/btyacc/no_include.output b/test/btyacc/no_include.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_opts.error b/test/btyacc/no_opts.error deleted file mode 100644 index ad3131a69ab..00000000000 --- a/test/btyacc/no_opts.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.y" diff --git a/test/btyacc/no_opts.output b/test/btyacc/no_opts.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_output.error b/test/btyacc/no_output.error deleted file mode 100644 index a2f142a9d53..00000000000 --- a/test/btyacc/no_output.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/test/btyacc/no_output.output b/test/btyacc/no_output.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_output1.error b/test/btyacc/no_output1.error deleted file mode 100644 index a2f142a9d53..00000000000 --- a/test/btyacc/no_output1.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/test/btyacc/no_output1.output b/test/btyacc/no_output1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_output2.error b/test/btyacc/no_output2.error deleted file mode 100644 index c4d890b024c..00000000000 --- a/test/btyacc/no_output2.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: error message -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/btyacc/no_output2.output b/test/btyacc/no_output2.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_p_opt.error b/test/btyacc/no_p_opt.error deleted file mode 100644 index c4d890b024c..00000000000 --- a/test/btyacc/no_p_opt.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: error message -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/btyacc/no_p_opt.output b/test/btyacc/no_p_opt.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_p_opt1.error b/test/btyacc/no_p_opt1.error deleted file mode 100644 index 87286c2661e..00000000000 --- a/test/btyacc/no_p_opt1.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/test/btyacc/no_p_opt1.output b/test/btyacc/no_p_opt1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/no_verbose.error b/test/btyacc/no_verbose.error deleted file mode 100644 index a2f142a9d53..00000000000 --- a/test/btyacc/no_verbose.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/test/btyacc/no_verbose.output b/test/btyacc/no_verbose.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/nostdin.error b/test/btyacc/nostdin.error deleted file mode 100644 index 7f74f49a89b..00000000000 --- a/test/btyacc/nostdin.error +++ /dev/null @@ -1,30 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/btyacc/nostdin.output b/test/btyacc/nostdin.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/ok_syntax1.error b/test/btyacc/ok_syntax1.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/ok_syntax1.output b/test/btyacc/ok_syntax1.output deleted file mode 100644 index 61935519b0c..00000000000 --- a/test/btyacc/ok_syntax1.output +++ /dev/null @@ -1,511 +0,0 @@ - 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/test/btyacc/ok_syntax1.tab.c b/test/btyacc/ok_syntax1.tab.c deleted file mode 100644 index f5c3c18c818..00000000000 --- a/test/btyacc/ok_syntax1.tab.c +++ /dev/null @@ -1,1539 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 - -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 43 "ok_syntax1.y" -typedef union YYSTYPE -{ - 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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT ok_syntax1_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -#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 500 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yyerrflag; - int yychar; - YYSTYPE yyval; - YYSTYPE yylval; - int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyloc; /* position returned by actions */ - YYLTYPE yylloc; /* position from the lexer */ -#endif - - /* 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 YYINT *yylexp = 0; - - static YYINT *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[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - - yyerrflag = 0; - yychar = 0; - memset(&yyval, 0, sizeof(yyval)); - memset(&yylval, 0, sizeof(yylval)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(&yyloc, 0, sizeof(yyloc)); - memset(&yylloc, 0, sizeof(yylloc)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 66 "ok_syntax1.y" - { yyerrok ; } -#line 1234 "ok_syntax1.tab.c" -break; -case 4: -#line 70 "ok_syntax1.y" - { printf("%d\n",yystack.l_mark[0].ival);} -#line 1239 "ok_syntax1.tab.c" -break; -case 5: -#line 72 "ok_syntax1.y" - { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; } -#line 1244 "ok_syntax1.tab.c" -break; -case 6: -#line 76 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-1].ival; } -#line 1249 "ok_syntax1.tab.c" -break; -case 7: -#line 78 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; } -#line 1254 "ok_syntax1.tab.c" -break; -case 8: -#line 80 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; } -#line 1259 "ok_syntax1.tab.c" -break; -case 9: -#line 82 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; } -#line 1264 "ok_syntax1.tab.c" -break; -case 10: -#line 84 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; } -#line 1269 "ok_syntax1.tab.c" -break; -case 11: -#line 86 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; } -#line 1274 "ok_syntax1.tab.c" -break; -case 12: -#line 88 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; } -#line 1279 "ok_syntax1.tab.c" -break; -case 13: -#line 90 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; } -#line 1284 "ok_syntax1.tab.c" -break; -case 14: -#line 92 "ok_syntax1.y" - { yyval.ival = - yystack.l_mark[0].ival; } -#line 1289 "ok_syntax1.tab.c" -break; -case 15: -#line 94 "ok_syntax1.y" - { yyval.ival = regs[yystack.l_mark[0].ival]; } -#line 1294 "ok_syntax1.tab.c" -break; -case 17: -#line 99 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; } -#line 1299 "ok_syntax1.tab.c" -break; -case 18: -#line 101 "ok_syntax1.y" - { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } -#line 1304 "ok_syntax1.tab.c" -break; -#line 1306 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/ok_syntax1.tab.h b/test/btyacc/ok_syntax1.tab.h deleted file mode 100644 index 9f7028913ee..00000000000 --- a/test/btyacc/ok_syntax1.tab.h +++ /dev/null @@ -1,34 +0,0 @@ -#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 YYSTYPE -{ - char * cval; - int ival; - double dval; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ - -#endif /* _ok_syntax1__defines_h_ */ diff --git a/test/btyacc/pure_calc.error b/test/btyacc/pure_calc.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/pure_calc.output b/test/btyacc/pure_calc.output deleted file mode 100644 index c689eec0535..00000000000 --- a/test/btyacc/pure_calc.output +++ /dev/null @@ -1,485 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 DIGIT - 3 258 LETTER - 4 124 '|' - 5 38 '&' - 6 43 '+' - 7 45 '-' - 8 42 '*' - 9 47 '/' - 10 37 '%' - 11 259 UMINUS - 12 10 '\n' - 13 61 '=' - 14 40 '(' - 15 41 ')' - 16 260 $accept - 17 261 list - 18 262 stat - 19 263 expr - 20 264 number diff --git a/test/btyacc/pure_calc.tab.c b/test/btyacc/pure_calc.tab.c deleted file mode 100644 index 15a14b6c3f2..00000000000 --- a/test/btyacc/pure_calc.tab.c +++ /dev/null @@ -1,1512 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT calc_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_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 - -#if YYDEBUG -int yydebug; -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -#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 473 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yyerrflag; - int yychar; - YYSTYPE yyval; - YYSTYPE yylval; - int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyloc; /* position returned by actions */ - YYLTYPE yylloc; /* position from the lexer */ -#endif - - /* 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 YYINT *yylexp = 0; - - static YYINT *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[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - - yyerrflag = 0; - yychar = 0; - memset(&yyval, 0, sizeof(yyval)); - memset(&yylval, 0, sizeof(yylval)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(&yyloc, 0, sizeof(yyloc)); - memset(&yylloc, 0, sizeof(yylloc)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 34 "pure_calc.y" - { yyerrok ; } -#line 1207 "pure_calc.tab.c" -break; -case 4: -#line 38 "pure_calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1212 "pure_calc.tab.c" -break; -case 5: -#line 40 "pure_calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1217 "pure_calc.tab.c" -break; -case 6: -#line 44 "pure_calc.y" - { yyval = yystack.l_mark[-1]; } -#line 1222 "pure_calc.tab.c" -break; -case 7: -#line 46 "pure_calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1227 "pure_calc.tab.c" -break; -case 8: -#line 48 "pure_calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1232 "pure_calc.tab.c" -break; -case 9: -#line 50 "pure_calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1237 "pure_calc.tab.c" -break; -case 10: -#line 52 "pure_calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1242 "pure_calc.tab.c" -break; -case 11: -#line 54 "pure_calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1247 "pure_calc.tab.c" -break; -case 12: -#line 56 "pure_calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1252 "pure_calc.tab.c" -break; -case 13: -#line 58 "pure_calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1257 "pure_calc.tab.c" -break; -case 14: -#line 60 "pure_calc.y" - { yyval = - yystack.l_mark[0]; } -#line 1262 "pure_calc.tab.c" -break; -case 15: -#line 62 "pure_calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1267 "pure_calc.tab.c" -break; -case 17: -#line 67 "pure_calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1272 "pure_calc.tab.c" -break; -case 18: -#line 69 "pure_calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1277 "pure_calc.tab.c" -break; -#line 1279 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/pure_calc.tab.h b/test/btyacc/pure_calc.tab.h deleted file mode 100644 index 48f8993b83f..00000000000 --- a/test/btyacc/pure_calc.tab.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _calc__defines_h_ -#define _calc__defines_h_ - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 - -#endif /* _calc__defines_h_ */ diff --git a/test/btyacc/pure_error.error b/test/btyacc/pure_error.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/pure_error.output b/test/btyacc/pure_error.output deleted file mode 100644 index 1e56c214a6c..00000000000 --- a/test/btyacc/pure_error.output +++ /dev/null @@ -1,34 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -2 terminals, 2 nonterminals -2 grammar rules, 3 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 $accept - 3 258 S diff --git a/test/btyacc/pure_error.tab.c b/test/btyacc/pure_error.tab.c deleted file mode 100644 index 70a160e4353..00000000000 --- a/test/btyacc/pure_error.tab.c +++ /dev/null @@ -1,1304 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int YYINT; -static const YYINT error_lhs[] = { -1, - 0, -}; -static const YYINT error_len[] = { 2, - 1, -}; -static const YYINT error_defred[] = { 0, - 1, 0, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT error_stos[] = { 0, - 256, 258, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT error_ctable[] = { -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -#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 341 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yyerrflag; - int yychar; - YYSTYPE yyval; - YYSTYPE yylval; - int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyloc; /* position returned by actions */ - YYLTYPE yylloc; /* position from the lexer */ -#endif - - /* 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 YYINT *yylexp = 0; - - static YYINT *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[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - - yyerrflag = 0; - yychar = 0; - memset(&yyval, 0, sizeof(yyval)); - memset(&yylval, 0, sizeof(yylval)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(&yyloc, 0, sizeof(yyloc)); - memset(&yylloc, 0, sizeof(yylloc)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/pure_error.tab.h b/test/btyacc/pure_error.tab.h deleted file mode 100644 index f9e5ad278cc..00000000000 --- a/test/btyacc/pure_error.tab.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _error__defines_h_ -#define _error__defines_h_ - - -#endif /* _error__defines_h_ */ diff --git a/test/btyacc/quote_calc-s.error b/test/btyacc/quote_calc-s.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/btyacc/quote_calc-s.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc-s.output b/test/btyacc/quote_calc-s.output deleted file mode 100644 index 6c25d091109..00000000000 --- a/test/btyacc/quote_calc-s.output +++ /dev/null @@ -1,593 +0,0 @@ - 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/test/btyacc/quote_calc-s.tab.c b/test/btyacc/quote_calc-s.tab.c deleted file mode 100644 index ae472304b9e..00000000000 --- a/test/btyacc/quote_calc-s.tab.c +++ /dev/null @@ -1,1507 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT quote_calc_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 529 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "quote_calc.y" - { yyerrok ; } -#line 1202 "quote_calc-s.tab.c" -break; -case 4: -#line 39 "quote_calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1207 "quote_calc-s.tab.c" -break; -case 5: -#line 41 "quote_calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1212 "quote_calc-s.tab.c" -break; -case 6: -#line 45 "quote_calc.y" - { yyval = yystack.l_mark[-1]; } -#line 1217 "quote_calc-s.tab.c" -break; -case 7: -#line 47 "quote_calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1222 "quote_calc-s.tab.c" -break; -case 8: -#line 49 "quote_calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1227 "quote_calc-s.tab.c" -break; -case 9: -#line 51 "quote_calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1232 "quote_calc-s.tab.c" -break; -case 10: -#line 53 "quote_calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1237 "quote_calc-s.tab.c" -break; -case 11: -#line 55 "quote_calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1242 "quote_calc-s.tab.c" -break; -case 12: -#line 57 "quote_calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1247 "quote_calc-s.tab.c" -break; -case 13: -#line 59 "quote_calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1252 "quote_calc-s.tab.c" -break; -case 14: -#line 61 "quote_calc.y" - { yyval = - yystack.l_mark[0]; } -#line 1257 "quote_calc-s.tab.c" -break; -case 15: -#line 63 "quote_calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1262 "quote_calc-s.tab.c" -break; -case 17: -#line 68 "quote_calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1267 "quote_calc-s.tab.c" -break; -case 18: -#line 70 "quote_calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1272 "quote_calc-s.tab.c" -break; -#line 1274 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/quote_calc-s.tab.h b/test/btyacc/quote_calc-s.tab.h deleted file mode 100644 index 827bd8d11b2..00000000000 --- a/test/btyacc/quote_calc-s.tab.h +++ /dev/null @@ -1,14 +0,0 @@ -#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/test/btyacc/quote_calc.error b/test/btyacc/quote_calc.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/btyacc/quote_calc.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc.output b/test/btyacc/quote_calc.output deleted file mode 100644 index 6c25d091109..00000000000 --- a/test/btyacc/quote_calc.output +++ /dev/null @@ -1,593 +0,0 @@ - 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/test/btyacc/quote_calc.tab.c b/test/btyacc/quote_calc.tab.c deleted file mode 100644 index cee23e65d92..00000000000 --- a/test/btyacc/quote_calc.tab.c +++ /dev/null @@ -1,1513 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT quote_calc_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 535 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "quote_calc.y" - { yyerrok ; } -#line 1208 "quote_calc.tab.c" -break; -case 4: -#line 39 "quote_calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1213 "quote_calc.tab.c" -break; -case 5: -#line 41 "quote_calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1218 "quote_calc.tab.c" -break; -case 6: -#line 45 "quote_calc.y" - { yyval = yystack.l_mark[-1]; } -#line 1223 "quote_calc.tab.c" -break; -case 7: -#line 47 "quote_calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1228 "quote_calc.tab.c" -break; -case 8: -#line 49 "quote_calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1233 "quote_calc.tab.c" -break; -case 9: -#line 51 "quote_calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1238 "quote_calc.tab.c" -break; -case 10: -#line 53 "quote_calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1243 "quote_calc.tab.c" -break; -case 11: -#line 55 "quote_calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1248 "quote_calc.tab.c" -break; -case 12: -#line 57 "quote_calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1253 "quote_calc.tab.c" -break; -case 13: -#line 59 "quote_calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1258 "quote_calc.tab.c" -break; -case 14: -#line 61 "quote_calc.y" - { yyval = - yystack.l_mark[0]; } -#line 1263 "quote_calc.tab.c" -break; -case 15: -#line 63 "quote_calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1268 "quote_calc.tab.c" -break; -case 17: -#line 68 "quote_calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1273 "quote_calc.tab.c" -break; -case 18: -#line 70 "quote_calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1278 "quote_calc.tab.c" -break; -#line 1280 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/quote_calc.tab.h b/test/btyacc/quote_calc.tab.h deleted file mode 100644 index 2067aeea909..00000000000 --- a/test/btyacc/quote_calc.tab.h +++ /dev/null @@ -1,20 +0,0 @@ -#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/test/btyacc/quote_calc2-s.error b/test/btyacc/quote_calc2-s.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/btyacc/quote_calc2-s.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc2-s.output b/test/btyacc/quote_calc2-s.output deleted file mode 100644 index ce0b8f1baf5..00000000000 --- a/test/btyacc/quote_calc2-s.output +++ /dev/null @@ -1,593 +0,0 @@ - 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/test/btyacc/quote_calc2-s.tab.c b/test/btyacc/quote_calc2-s.tab.c deleted file mode 100644 index a9f939fa062..00000000000 --- a/test/btyacc/quote_calc2-s.tab.c +++ /dev/null @@ -1,1507 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT quote_calc2_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 529 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "quote_calc2.y" - { yyerrok ; } -#line 1202 "quote_calc2-s.tab.c" -break; -case 4: -#line 39 "quote_calc2.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1207 "quote_calc2-s.tab.c" -break; -case 5: -#line 41 "quote_calc2.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1212 "quote_calc2-s.tab.c" -break; -case 6: -#line 45 "quote_calc2.y" - { yyval = yystack.l_mark[-1]; } -#line 1217 "quote_calc2-s.tab.c" -break; -case 7: -#line 47 "quote_calc2.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1222 "quote_calc2-s.tab.c" -break; -case 8: -#line 49 "quote_calc2.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1227 "quote_calc2-s.tab.c" -break; -case 9: -#line 51 "quote_calc2.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1232 "quote_calc2-s.tab.c" -break; -case 10: -#line 53 "quote_calc2.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1237 "quote_calc2-s.tab.c" -break; -case 11: -#line 55 "quote_calc2.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1242 "quote_calc2-s.tab.c" -break; -case 12: -#line 57 "quote_calc2.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1247 "quote_calc2-s.tab.c" -break; -case 13: -#line 59 "quote_calc2.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1252 "quote_calc2-s.tab.c" -break; -case 14: -#line 61 "quote_calc2.y" - { yyval = - yystack.l_mark[0]; } -#line 1257 "quote_calc2-s.tab.c" -break; -case 15: -#line 63 "quote_calc2.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1262 "quote_calc2-s.tab.c" -break; -case 17: -#line 68 "quote_calc2.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1267 "quote_calc2-s.tab.c" -break; -case 18: -#line 70 "quote_calc2.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1272 "quote_calc2-s.tab.c" -break; -#line 1274 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/quote_calc2-s.tab.h b/test/btyacc/quote_calc2-s.tab.h deleted file mode 100644 index 90c0c1a2d4c..00000000000 --- a/test/btyacc/quote_calc2-s.tab.h +++ /dev/null @@ -1,14 +0,0 @@ -#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/test/btyacc/quote_calc2.error b/test/btyacc/quote_calc2.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/btyacc/quote_calc2.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc2.output b/test/btyacc/quote_calc2.output deleted file mode 100644 index ce0b8f1baf5..00000000000 --- a/test/btyacc/quote_calc2.output +++ /dev/null @@ -1,593 +0,0 @@ - 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/test/btyacc/quote_calc2.tab.c b/test/btyacc/quote_calc2.tab.c deleted file mode 100644 index c414970b42b..00000000000 --- a/test/btyacc/quote_calc2.tab.c +++ /dev/null @@ -1,1513 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT quote_calc2_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 535 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "quote_calc2.y" - { yyerrok ; } -#line 1208 "quote_calc2.tab.c" -break; -case 4: -#line 39 "quote_calc2.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1213 "quote_calc2.tab.c" -break; -case 5: -#line 41 "quote_calc2.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1218 "quote_calc2.tab.c" -break; -case 6: -#line 45 "quote_calc2.y" - { yyval = yystack.l_mark[-1]; } -#line 1223 "quote_calc2.tab.c" -break; -case 7: -#line 47 "quote_calc2.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1228 "quote_calc2.tab.c" -break; -case 8: -#line 49 "quote_calc2.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1233 "quote_calc2.tab.c" -break; -case 9: -#line 51 "quote_calc2.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1238 "quote_calc2.tab.c" -break; -case 10: -#line 53 "quote_calc2.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1243 "quote_calc2.tab.c" -break; -case 11: -#line 55 "quote_calc2.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1248 "quote_calc2.tab.c" -break; -case 12: -#line 57 "quote_calc2.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1253 "quote_calc2.tab.c" -break; -case 13: -#line 59 "quote_calc2.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1258 "quote_calc2.tab.c" -break; -case 14: -#line 61 "quote_calc2.y" - { yyval = - yystack.l_mark[0]; } -#line 1263 "quote_calc2.tab.c" -break; -case 15: -#line 63 "quote_calc2.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1268 "quote_calc2.tab.c" -break; -case 17: -#line 68 "quote_calc2.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1273 "quote_calc2.tab.c" -break; -case 18: -#line 70 "quote_calc2.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1278 "quote_calc2.tab.c" -break; -#line 1280 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/quote_calc2.tab.h b/test/btyacc/quote_calc2.tab.h deleted file mode 100644 index 0c9db245c3c..00000000000 --- a/test/btyacc/quote_calc2.tab.h +++ /dev/null @@ -1,20 +0,0 @@ -#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/test/btyacc/quote_calc3-s.error b/test/btyacc/quote_calc3-s.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/btyacc/quote_calc3-s.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc3-s.output b/test/btyacc/quote_calc3-s.output deleted file mode 100644 index 4809ca4c810..00000000000 --- a/test/btyacc/quote_calc3-s.output +++ /dev/null @@ -1,593 +0,0 @@ - 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/test/btyacc/quote_calc3-s.tab.c b/test/btyacc/quote_calc3-s.tab.c deleted file mode 100644 index 73c6357a182..00000000000 --- a/test/btyacc/quote_calc3-s.tab.c +++ /dev/null @@ -1,1508 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT quote_calc3_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 530 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "quote_calc3.y" - { yyerrok ; } -#line 1203 "quote_calc3-s.tab.c" -break; -case 4: -#line 39 "quote_calc3.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1208 "quote_calc3-s.tab.c" -break; -case 5: -#line 41 "quote_calc3.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1213 "quote_calc3-s.tab.c" -break; -case 6: -#line 45 "quote_calc3.y" - { yyval = yystack.l_mark[-1]; } -#line 1218 "quote_calc3-s.tab.c" -break; -case 7: -#line 47 "quote_calc3.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1223 "quote_calc3-s.tab.c" -break; -case 8: -#line 49 "quote_calc3.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1228 "quote_calc3-s.tab.c" -break; -case 9: -#line 51 "quote_calc3.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1233 "quote_calc3-s.tab.c" -break; -case 10: -#line 53 "quote_calc3.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1238 "quote_calc3-s.tab.c" -break; -case 11: -#line 55 "quote_calc3.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1243 "quote_calc3-s.tab.c" -break; -case 12: -#line 57 "quote_calc3.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1248 "quote_calc3-s.tab.c" -break; -case 13: -#line 59 "quote_calc3.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1253 "quote_calc3-s.tab.c" -break; -case 14: -#line 61 "quote_calc3.y" - { yyval = - yystack.l_mark[0]; } -#line 1258 "quote_calc3-s.tab.c" -break; -case 15: -#line 63 "quote_calc3.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1263 "quote_calc3-s.tab.c" -break; -case 17: -#line 68 "quote_calc3.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1268 "quote_calc3-s.tab.c" -break; -case 18: -#line 70 "quote_calc3.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1273 "quote_calc3-s.tab.c" -break; -#line 1275 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/quote_calc3-s.tab.h b/test/btyacc/quote_calc3-s.tab.h deleted file mode 100644 index 022d59c6782..00000000000 --- a/test/btyacc/quote_calc3-s.tab.h +++ /dev/null @@ -1,14 +0,0 @@ -#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/test/btyacc/quote_calc3.error b/test/btyacc/quote_calc3.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/btyacc/quote_calc3.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc3.output b/test/btyacc/quote_calc3.output deleted file mode 100644 index 4809ca4c810..00000000000 --- a/test/btyacc/quote_calc3.output +++ /dev/null @@ -1,593 +0,0 @@ - 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/test/btyacc/quote_calc3.tab.c b/test/btyacc/quote_calc3.tab.c deleted file mode 100644 index 36bdc0d7e4a..00000000000 --- a/test/btyacc/quote_calc3.tab.c +++ /dev/null @@ -1,1508 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT quote_calc3_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 530 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "quote_calc3.y" - { yyerrok ; } -#line 1203 "quote_calc3.tab.c" -break; -case 4: -#line 39 "quote_calc3.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1208 "quote_calc3.tab.c" -break; -case 5: -#line 41 "quote_calc3.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1213 "quote_calc3.tab.c" -break; -case 6: -#line 45 "quote_calc3.y" - { yyval = yystack.l_mark[-1]; } -#line 1218 "quote_calc3.tab.c" -break; -case 7: -#line 47 "quote_calc3.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1223 "quote_calc3.tab.c" -break; -case 8: -#line 49 "quote_calc3.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1228 "quote_calc3.tab.c" -break; -case 9: -#line 51 "quote_calc3.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1233 "quote_calc3.tab.c" -break; -case 10: -#line 53 "quote_calc3.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1238 "quote_calc3.tab.c" -break; -case 11: -#line 55 "quote_calc3.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1243 "quote_calc3.tab.c" -break; -case 12: -#line 57 "quote_calc3.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1248 "quote_calc3.tab.c" -break; -case 13: -#line 59 "quote_calc3.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1253 "quote_calc3.tab.c" -break; -case 14: -#line 61 "quote_calc3.y" - { yyval = - yystack.l_mark[0]; } -#line 1258 "quote_calc3.tab.c" -break; -case 15: -#line 63 "quote_calc3.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1263 "quote_calc3.tab.c" -break; -case 17: -#line 68 "quote_calc3.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1268 "quote_calc3.tab.c" -break; -case 18: -#line 70 "quote_calc3.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1273 "quote_calc3.tab.c" -break; -#line 1275 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/quote_calc3.tab.h b/test/btyacc/quote_calc3.tab.h deleted file mode 100644 index 022d59c6782..00000000000 --- a/test/btyacc/quote_calc3.tab.h +++ /dev/null @@ -1,14 +0,0 @@ -#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/test/btyacc/quote_calc4-s.error b/test/btyacc/quote_calc4-s.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/btyacc/quote_calc4-s.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc4-s.output b/test/btyacc/quote_calc4-s.output deleted file mode 100644 index 5f1f610d8cb..00000000000 --- a/test/btyacc/quote_calc4-s.output +++ /dev/null @@ -1,593 +0,0 @@ - 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/test/btyacc/quote_calc4-s.tab.c b/test/btyacc/quote_calc4-s.tab.c deleted file mode 100644 index 111d7473a6f..00000000000 --- a/test/btyacc/quote_calc4-s.tab.c +++ /dev/null @@ -1,1508 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT quote_calc4_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 530 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "quote_calc4.y" - { yyerrok ; } -#line 1203 "quote_calc4-s.tab.c" -break; -case 4: -#line 39 "quote_calc4.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1208 "quote_calc4-s.tab.c" -break; -case 5: -#line 41 "quote_calc4.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1213 "quote_calc4-s.tab.c" -break; -case 6: -#line 45 "quote_calc4.y" - { yyval = yystack.l_mark[-1]; } -#line 1218 "quote_calc4-s.tab.c" -break; -case 7: -#line 47 "quote_calc4.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1223 "quote_calc4-s.tab.c" -break; -case 8: -#line 49 "quote_calc4.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1228 "quote_calc4-s.tab.c" -break; -case 9: -#line 51 "quote_calc4.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1233 "quote_calc4-s.tab.c" -break; -case 10: -#line 53 "quote_calc4.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1238 "quote_calc4-s.tab.c" -break; -case 11: -#line 55 "quote_calc4.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1243 "quote_calc4-s.tab.c" -break; -case 12: -#line 57 "quote_calc4.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1248 "quote_calc4-s.tab.c" -break; -case 13: -#line 59 "quote_calc4.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1253 "quote_calc4-s.tab.c" -break; -case 14: -#line 61 "quote_calc4.y" - { yyval = - yystack.l_mark[0]; } -#line 1258 "quote_calc4-s.tab.c" -break; -case 15: -#line 63 "quote_calc4.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1263 "quote_calc4-s.tab.c" -break; -case 17: -#line 68 "quote_calc4.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1268 "quote_calc4-s.tab.c" -break; -case 18: -#line 70 "quote_calc4.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1273 "quote_calc4-s.tab.c" -break; -#line 1275 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/quote_calc4-s.tab.h b/test/btyacc/quote_calc4-s.tab.h deleted file mode 100644 index 9279e7019ca..00000000000 --- a/test/btyacc/quote_calc4-s.tab.h +++ /dev/null @@ -1,14 +0,0 @@ -#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/test/btyacc/quote_calc4.error b/test/btyacc/quote_calc4.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/btyacc/quote_calc4.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc4.output b/test/btyacc/quote_calc4.output deleted file mode 100644 index 5f1f610d8cb..00000000000 --- a/test/btyacc/quote_calc4.output +++ /dev/null @@ -1,593 +0,0 @@ - 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/test/btyacc/quote_calc4.tab.c b/test/btyacc/quote_calc4.tab.c deleted file mode 100644 index c102d1bac67..00000000000 --- a/test/btyacc/quote_calc4.tab.c +++ /dev/null @@ -1,1508 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT quote_calc4_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 530 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 35 "quote_calc4.y" - { yyerrok ; } -#line 1203 "quote_calc4.tab.c" -break; -case 4: -#line 39 "quote_calc4.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1208 "quote_calc4.tab.c" -break; -case 5: -#line 41 "quote_calc4.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1213 "quote_calc4.tab.c" -break; -case 6: -#line 45 "quote_calc4.y" - { yyval = yystack.l_mark[-1]; } -#line 1218 "quote_calc4.tab.c" -break; -case 7: -#line 47 "quote_calc4.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1223 "quote_calc4.tab.c" -break; -case 8: -#line 49 "quote_calc4.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1228 "quote_calc4.tab.c" -break; -case 9: -#line 51 "quote_calc4.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1233 "quote_calc4.tab.c" -break; -case 10: -#line 53 "quote_calc4.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1238 "quote_calc4.tab.c" -break; -case 11: -#line 55 "quote_calc4.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1243 "quote_calc4.tab.c" -break; -case 12: -#line 57 "quote_calc4.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1248 "quote_calc4.tab.c" -break; -case 13: -#line 59 "quote_calc4.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1253 "quote_calc4.tab.c" -break; -case 14: -#line 61 "quote_calc4.y" - { yyval = - yystack.l_mark[0]; } -#line 1258 "quote_calc4.tab.c" -break; -case 15: -#line 63 "quote_calc4.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1263 "quote_calc4.tab.c" -break; -case 17: -#line 68 "quote_calc4.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1268 "quote_calc4.tab.c" -break; -case 18: -#line 70 "quote_calc4.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1273 "quote_calc4.tab.c" -break; -#line 1275 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/quote_calc4.tab.h b/test/btyacc/quote_calc4.tab.h deleted file mode 100644 index 9279e7019ca..00000000000 --- a/test/btyacc/quote_calc4.tab.h +++ /dev/null @@ -1,14 +0,0 @@ -#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/test/btyacc/rename_debug.c b/test/btyacc/rename_debug.c deleted file mode 100644 index 958ae6a44c0..00000000000 --- a/test/btyacc/rename_debug.c +++ /dev/null @@ -1,1142 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int YYINT; -static const YYINT yylhs[] = { -1, - 0, -}; -static const YYINT yylen[] = { 2, - 1, -}; -static const YYINT yydefred[] = { 0, - 1, 0, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT yystos[] = { 0, - 256, 258, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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[] = { -1, -}; -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 241 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/rename_debug.error b/test/btyacc/rename_debug.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/rename_debug.h b/test/btyacc/rename_debug.h deleted file mode 100644 index ba44e7d75a7..00000000000 --- a/test/btyacc/rename_debug.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _yy_defines_h_ -#define _yy_defines_h_ - -#define YYERRCODE 256 - -#endif /* _yy_defines_h_ */ diff --git a/test/btyacc/rename_debug.i b/test/btyacc/rename_debug.i deleted file mode 100644 index ce4871a0e68..00000000000 --- a/test/btyacc/rename_debug.i +++ /dev/null @@ -1,71 +0,0 @@ -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "code_debug.y" - -#ifdef YYBISON -int yylex(void); -static void yyerror(const char *); -#endif - - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#ifndef YYDEBUG -#define YYDEBUG 1 -#endif - -#if YYDEBUG -extern int yydebug; -#endif - -extern int yyerrflag; -extern int yychar; -extern YYSTYPE yyval; -extern YYSTYPE yylval; -extern int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -extern YYLTYPE yyloc; /* position returned by actions */ -extern YYLTYPE yylloc; /* position from the lexer */ -#endif diff --git a/test/btyacc/rename_debug.output b/test/btyacc/rename_debug.output deleted file mode 100644 index 1e56c214a6c..00000000000 --- a/test/btyacc/rename_debug.output +++ /dev/null @@ -1,34 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -2 terminals, 2 nonterminals -2 grammar rules, 3 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 $accept - 3 258 S diff --git a/test/btyacc/stdin1.calc.c b/test/btyacc/stdin1.calc.c deleted file mode 100644 index 6bfc240ef6d..00000000000 --- a/test/btyacc/stdin1.calc.c +++ /dev/null @@ -1,1396 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "(null)" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 34 "stdin1.calc.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT yystos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT yycindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT yyctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 66 "(null)" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 418 "stdin1.calc.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 28 "(null)" - { yyerrok ; } -#line 1091 "stdin1.calc.c" -break; -case 4: -#line 32 "(null)" - { printf("%d\n",yystack.l_mark[0]);} -#line 1096 "stdin1.calc.c" -break; -case 5: -#line 34 "(null)" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1101 "stdin1.calc.c" -break; -case 6: -#line 38 "(null)" - { yyval = yystack.l_mark[-1]; } -#line 1106 "stdin1.calc.c" -break; -case 7: -#line 40 "(null)" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1111 "stdin1.calc.c" -break; -case 8: -#line 42 "(null)" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1116 "stdin1.calc.c" -break; -case 9: -#line 44 "(null)" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1121 "stdin1.calc.c" -break; -case 10: -#line 46 "(null)" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1126 "stdin1.calc.c" -break; -case 11: -#line 48 "(null)" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1131 "stdin1.calc.c" -break; -case 12: -#line 50 "(null)" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1136 "stdin1.calc.c" -break; -case 13: -#line 52 "(null)" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1141 "stdin1.calc.c" -break; -case 14: -#line 54 "(null)" - { yyval = - yystack.l_mark[0]; } -#line 1146 "stdin1.calc.c" -break; -case 15: -#line 56 "(null)" - { yyval = regs[yystack.l_mark[0]]; } -#line 1151 "stdin1.calc.c" -break; -case 17: -#line 61 "(null)" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1156 "stdin1.calc.c" -break; -case 18: -#line 63 "(null)" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1161 "stdin1.calc.c" -break; -#line 1163 "stdin1.calc.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/stdin1.error b/test/btyacc/stdin1.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/stdin1.output b/test/btyacc/stdin1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/stdin2.calc.c b/test/btyacc/stdin2.calc.c deleted file mode 100644 index 39f073974ea..00000000000 --- a/test/btyacc/stdin2.calc.c +++ /dev/null @@ -1,1396 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#undef YYBTYACC -#define YYBTYACC 0 -#define YYDEBUGSTR YYPREFIX "debug" -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "calc.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 34 "stdin2.calc.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -static const YYINT yystos[] = { 0, - 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, - 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, - 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, - 263, 263, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -#if YYBTYACC -static const YYINT yycindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; -#endif -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#if YYBTYACC -static const YYINT yyctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -#endif -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, -0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", -"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 66 "calc.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 418 "stdin2.calc.c" - -/* For use in generated program */ -#define yydepth (int)(yystack.s_mark - yystack.s_base) -#if YYBTYACC -#define yytrial (yyps->save) -#endif /* YYBTYACC */ - -#if YYDEBUG -#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 1091 "stdin2.calc.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 1096 "stdin2.calc.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 1101 "stdin2.calc.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 1106 "stdin2.calc.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 1111 "stdin2.calc.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 1116 "stdin2.calc.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 1121 "stdin2.calc.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 1126 "stdin2.calc.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 1131 "stdin2.calc.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 1136 "stdin2.calc.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 1141 "stdin2.calc.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 1146 "stdin2.calc.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 1151 "stdin2.calc.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 1156 "stdin2.calc.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 1161 "stdin2.calc.c" -break; -#line 1163 "stdin2.calc.c" - default: - break; - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); -#endif - fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); - } -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/stdin2.error b/test/btyacc/stdin2.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/stdin2.output b/test/btyacc/stdin2.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/btyacc/varsyntax_calc1.error b/test/btyacc/varsyntax_calc1.error deleted file mode 100644 index 9c1f7152c30..00000000000 --- a/test/btyacc/varsyntax_calc1.error +++ /dev/null @@ -1,2 +0,0 @@ -YACC: 2 rules never reduced -YACC: 18 shift/reduce conflicts, 26 reduce/reduce conflicts. diff --git a/test/btyacc/varsyntax_calc1.output b/test/btyacc/varsyntax_calc1.output deleted file mode 100644 index d6a869f6d35..00000000000 --- a/test/btyacc/varsyntax_calc1.output +++ /dev/null @@ -1,900 +0,0 @@ - 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/test/btyacc/varsyntax_calc1.tab.c b/test/btyacc/varsyntax_calc1.tab.c deleted file mode 100644 index 27fa6a38c82..00000000000 --- a/test/btyacc/varsyntax_calc1.tab.c +++ /dev/null @@ -1,1747 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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]; - -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 32 "varsyntax_calc1.y" -typedef union YYSTYPE -{ - 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 int 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, -}; -#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) -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, -}; -#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ -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, -}; -#if YYBTYACC -static const YYINT varsyntax_calc1_ctable[] = { -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -}; -#endif -#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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -YYLTYPE yyloc; /* position returned by actions */ -YYLTYPE yylloc; /* position from the lexer */ -#endif - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -#ifndef YYLLOC_DEFAULT -#define YYLLOC_DEFAULT(loc, rhs, n) \ -do \ -{ \ - if (n == 0) \ - { \ - (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ - (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ - (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ - } \ - else \ - { \ - (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ - (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ - (loc).last_line = YYRHSLOC(rhs, n).last_line; \ - (loc).last_column = YYRHSLOC(rhs, n).last_column; \ - } \ -} while (0) -#endif /* YYLLOC_DEFAULT */ -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#if YYBTYACC - -#ifndef YYLVQUEUEGROWTH -#define YYLVQUEUEGROWTH 32 -#endif -#endif /* YYBTYACC */ - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#ifndef YYINITSTACKSIZE -#define YYINITSTACKSIZE 200 -#endif - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *p_base; - YYLTYPE *p_mark; -#endif -} YYSTACKDATA; -#if YYBTYACC - -struct YYParseState_s -{ - struct YYParseState_s *save; /* Previously saved parser state */ - YYSTACKDATA yystack; /* saved parser stack */ - int state; /* saved parser state */ - int errflag; /* saved error recovery status */ - int lexeme; /* saved index of the conflict lexeme in the lexical queue */ - YYINT ctry; /* saved index in yyctable[] for this conflict */ -}; -typedef struct YYParseState_s YYParseState; -#endif /* YYBTYACC */ -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#if YYBTYACC - -/* Current parser state */ -static YYParseState *yyps = 0; - -/* yypath != NULL: do the full parse, starting at *yypath parser state. */ -static YYParseState *yypath = 0; - -/* Base of the lexical value queue */ -static YYSTYPE *yylvals = 0; - -/* Current position at lexical value queue */ -static YYSTYPE *yylvp = 0; - -/* End position of lexical value queue */ -static YYSTYPE *yylve = 0; - -/* The last allocated position at the lexical value queue */ -static YYSTYPE *yylvlim = 0; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -/* Base of the lexical position queue */ -static YYLTYPE *yylpsns = 0; - -/* Current position at lexical position queue */ -static YYLTYPE *yylpp = 0; - -/* End position of lexical position queue */ -static YYLTYPE *yylpe = 0; - -/* The last allocated position at the lexical position queue */ -static YYLTYPE *yylplim = 0; -#endif - -/* Current position at lexical token queue */ -static YYINT *yylexp = 0; - -static YYINT *yylexemes = 0; -#endif /* YYBTYACC */ -#line 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 656 "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; - YYINT *newss; - YYSTYPE *newvs; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *newps; -#endif - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); - if (newps == 0) - return YYENOMEM; - - data->p_base = newps; - data->p_mark = newps + i; -#endif - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); -#endif - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - free(data->p_base); -#endif - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif /* YYPURE || defined(YY_NO_LEAKS) */ -#if YYBTYACC - -static YYParseState * -yyNewState(unsigned size) -{ - YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); - if (p == NULL) return NULL; - - p->yystack.stacksize = size; - if (size == 0) - { - p->yystack.s_base = NULL; - p->yystack.l_base = NULL; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = NULL; -#endif - return p; - } - p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); - if (p->yystack.s_base == NULL) return NULL; - p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); - if (p->yystack.l_base == NULL) return NULL; - memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); - if (p->yystack.p_base == NULL) return NULL; - memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); -#endif - - return p; -} - -static void -yyFreeState(YYParseState *p) -{ - yyfreestack(&p->yystack); - free(p); -} -#endif /* YYBTYACC */ - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -#if YYBTYACC -#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) -#define YYVALID_NESTED do { if (yyps->save && \ - yyps->save->save == 0) goto yyvalid; } while(0) -#endif /* YYBTYACC */ - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate, yyresult; -#if YYBTYACC - int yynewerrflag; - YYParseState *yyerrctx = NULL; -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ -#endif -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } - if (yydebug) - fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); -#endif -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); -#endif - -#if YYBTYACC - yyps = yyNewState(0); if (yyps == 0) goto yyenomem; - yyps->save = 0; -#endif /* YYBTYACC */ - yym = 0; - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base; -#endif - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { -#if YYBTYACC - do { - if (yylvp < yylve) - { - /* we're currently re-reading tokens */ - yylval = *yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = *yylpp++; -#endif - yychar = *yylexp++; - break; - } - if (yyps->save) - { - /* in trial mode; save scanner results for future parse attempts */ - if (yylvp == yylvlim) - { /* Enlarge lexical value queue */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", - YYDEBUGSTR, yydepth, yystate, yychar, yys); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); -#endif - fputc('\n', stderr); - } -#endif - } -#if YYBTYACC - - /* Do we have a conflict? */ - if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - YYINT ctry; - - if (yypath) - { - YYParseState *save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", - YYDEBUGSTR, yydepth, yystate); -#endif - /* Switch to the next conflict context */ - save = yypath; - yypath = save->save; - save->save = NULL; - ctry = save->ctry; - if (save->state != yystate) YYABORT; - yyFreeState(save); - - } - else - { - - /* Unresolved conflict - start/continue trial parse */ - YYParseState *save; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); - if (yyps->save) - fputs("ALREADY in conflict, continuing trial parse.\n", stderr); - else - fputs("Starting trial parse.\n", stderr); - } -#endif - save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (save == NULL) goto yyenomem; - save->save = yyps->save; - save->state = yystate; - save->errflag = yyerrflag; - save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = yytable[yyn]; - if (yyctable[ctry] == -1) - { -#if YYDEBUG - if (yydebug && yychar >= YYEOF) - fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); -#endif - ctry++; - } - save->ctry = ctry; - if (yyps->save == NULL) - { - /* If this is a first conflict in the stack, start saving lexemes */ - if (!yylexemes) - { - yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); - if (yylexemes == NULL) goto yyenomem; - yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); - if (yylvals == NULL) goto yyenomem; - yylvlim = yylvals + YYLVQUEUEGROWTH; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); - if (yylpsns == NULL) goto yyenomem; - yylplim = yylpsns + YYLVQUEUEGROWTH; -#endif - } - if (yylvp == yylve) - { - yylvp = yylve = yylvals; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns; -#endif - yylexp = yylexemes; - if (yychar >= YYEOF) - { - *yylve++ = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpe++ = yylloc; -#endif - *yylexp = (YYINT) yychar; - yychar = YYEMPTY; - } - } - } - if (yychar >= YYEOF) - { - yylvp--; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp--; -#endif - yylexp--; - yychar = YYEMPTY; - } - save->lexeme = (int) (yylvp - yylvals); - yyps->save = save; - } - if (yytable[yyn] == ctry) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); -#endif - if (yychar < 0) - { - yylvp++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp++; -#endif - yylexp++; - } - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - goto yyoverflow; - yystate = yyctable[ctry]; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - else - { - yyn = yyctable[ctry]; - goto yyreduce; - } - } /* End of code dealing with conflicts */ -#endif /* YYBTYACC */ - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", - YYDEBUGSTR, yydepth, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yylloc; -#endif - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; -#if YYBTYACC - - yynewerrflag = 1; - goto yyerrhandler; - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ - -yyerrlab: - /* explicit YYERROR from an action -- pop the rhs of the rule reduced - * before looking for error recovery */ - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark -= yym; -#endif - - yynewerrflag = 0; -yyerrhandler: - while (yyps->save) - { - int ctry; - YYParseState *save = yyps->save; -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yyps->save->state, - (int)(yylvp - yylvals - yyps->save->lexeme)); -#endif - /* Memorize most forward-looking error state in case it's really an error. */ - if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) - { - /* Free old saved error context state */ - if (yyerrctx) yyFreeState(yyerrctx); - /* Create and fill out new saved error context state */ - yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); - if (yyerrctx == NULL) goto yyenomem; - yyerrctx->save = yyps->save; - yyerrctx->state = yystate; - yyerrctx->errflag = yyerrflag; - yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yyerrctx->lexeme = (int) (yylvp - yylvals); - } - yylvp = yylvals + save->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + save->lexeme; -#endif - yylexp = yylexemes + save->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - ctry = ++save->ctry; - yystate = save->state; - /* We tried shift, try reduce now */ - if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; - yyps->save = save->save; - save->save = NULL; - yyFreeState(save); - - /* Nothing left on the stack -- error */ - if (!yyps->save) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", - YYPREFIX, yydepth); -#endif - /* Restore state as it was in the most forward-advanced error */ - yylvp = yylvals + yyerrctx->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yyerrctx->lexeme; -#endif - yylexp = yylexemes + yyerrctx->lexeme; - yychar = yylexp[-1]; - yylval = yylvp[-1]; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylloc = yylpp[-1]; -#endif - yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yyerrctx->state; - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yynewerrflag = 1; - } - if (yynewerrflag == 0) goto yyinrecovery; -#endif /* YYBTYACC */ - - YYERROR_CALL("syntax error"); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ -#endif - -#if !YYBTYACC - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: -#endif - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* lookahead position is error end position */ - yyerror_loc_range[2] = yylloc; - YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ - *++yystack.p_mark = yyloc; -#endif - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", - YYDEBUGSTR, yydepth, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - /* the current TOS position is the error start position */ - yyerror_loc_range[1] = *yystack.p_mark; -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); -#else - YYDESTRUCT_CALL("error: discarding state", - yystos[*yystack.s_mark], yystack.l_mark); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - --yystack.s_mark; - --yystack.l_mark; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - --yystack.p_mark; -#endif - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", - YYDEBUGSTR, yydepth, yystate, yychar, yys); - } -#endif -#if defined(YYDESTRUCT_CALL) -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ -#endif /* defined(YYDESTRUCT_CALL) */ - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: - yym = yylen[yyn]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", - YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - if (yym > 0) - { - int i; - fputc('<', stderr); - for (i = yym; i > 0; i--) - { - if (i != yym) fputs(", ", stderr); - fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], - yystack.l_mark[1-i]), stderr); - } - fputc('>', stderr); - } -#endif - fputc('\n', stderr); - } -#endif - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - - /* Perform position reduction */ - memset(&yyloc, 0, sizeof(yyloc)); -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); - /* just in case YYERROR is invoked within the action, save - the start of the rhs as the error start position */ - yyerror_loc_range[1] = yystack.p_mark[1-yym]; - } -#endif - - switch (yyn) - { -case 3: -#line 59 "varsyntax_calc1.y" - { - (void) printf("%15.8f\n", yystack.l_mark[-1].dval); - } -#line 1331 "varsyntax_calc1.tab.c" -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); - } -#line 1338 "varsyntax_calc1.tab.c" -break; -case 5: -#line 67 "varsyntax_calc1.y" - { - dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; - } -#line 1345 "varsyntax_calc1.tab.c" -break; -case 6: -#line 71 "varsyntax_calc1.y" - { - vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; - } -#line 1352 "varsyntax_calc1.tab.c" -break; -case 7: -#line 75 "varsyntax_calc1.y" - { - yyerrok; - } -#line 1359 "varsyntax_calc1.tab.c" -break; -case 9: -#line 82 "varsyntax_calc1.y" - { - yyval.dval = dreg[yystack.l_mark[0].ival]; /* $$ & $1 are sufficient here*/ - } -#line 1366 "varsyntax_calc1.tab.c" -break; -case 10: -#line 86 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; - } -#line 1373 "varsyntax_calc1.tab.c" -break; -case 11: -#line 90 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; - } -#line 1380 "varsyntax_calc1.tab.c" -break; -case 12: -#line 94 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; - } -#line 1387 "varsyntax_calc1.tab.c" -break; -case 13: -#line 98 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; - } -#line 1394 "varsyntax_calc1.tab.c" -break; -case 14: -#line 102 "varsyntax_calc1.y" - { - yyval.dval = -yystack.l_mark[0].dval; - } -#line 1401 "varsyntax_calc1.tab.c" -break; -case 15: -#line 106 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-1].dval; - } -#line 1408 "varsyntax_calc1.tab.c" -break; -case 16: -#line 112 "varsyntax_calc1.y" - { - yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; - } -#line 1415 "varsyntax_calc1.tab.c" -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; - } - } -#line 1428 "varsyntax_calc1.tab.c" -break; -case 18: -#line 126 "varsyntax_calc1.y" - { - yyval.vval = vreg[yystack.l_mark[0].ival]; - } -#line 1435 "varsyntax_calc1.tab.c" -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; - } -#line 1443 "varsyntax_calc1.tab.c" -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; - } -#line 1451 "varsyntax_calc1.tab.c" -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; - } -#line 1459 "varsyntax_calc1.tab.c" -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; - } -#line 1467 "varsyntax_calc1.tab.c" -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 ); - } -#line 1474 "varsyntax_calc1.tab.c" -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 ); - } -#line 1481 "varsyntax_calc1.tab.c" -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 ); - } -#line 1489 "varsyntax_calc1.tab.c" -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 ); - } -#line 1497 "varsyntax_calc1.tab.c" -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; - } -#line 1505 "varsyntax_calc1.tab.c" -break; -case 28: -#line 173 "varsyntax_calc1.y" - { - yyval.vval = yystack.l_mark[-1].vval; - } -#line 1512 "varsyntax_calc1.tab.c" -break; -#line 1514 "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 */ - size_t p = (size_t) (yylvp - yylvals); - size_t s = (size_t) (yylvlim - yylvals); - - s += YYLVQUEUEGROWTH; - if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) - goto yyenomem; - if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) - goto yyenomem; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) - goto yyenomem; -#endif - yylvp = yylve = yylvals + p; - yylvlim = yylvals + s; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpe = yylpsns + p; - yylplim = yylpsns + s; -#endif - yylexp = yylexemes + p; - } - *yylexp = (YYINT) YYLEX; - *yylvp++ = yylval; - yylve++; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *yylpp++ = yylloc; - yylpe++; -#endif - yychar = *yylexp++; - break; - } - /* normal operation, no conflict encountered */ -#endif /* YYBTYACC */ - yychar = YYLEX; -#if YYBTYACC - } while (0); -#endif /* YYBTYACC */ - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", - YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - { - fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); -#ifdef YYSTYPE_TOSTRING -#if YYBTYACC - if (!yytrial) -#endif /* YYBTYACC */ - fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); -#endif - fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); - } -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - *++yystack.p_mark = yyloc; -#endif - goto yyloop; -#if YYBTYACC - - /* Reduction declares that this path is valid. Set yypath and do a full parse */ -yyvalid: - if (yypath) YYABORT; - while (yyps->save) - { - YYParseState *save = yyps->save; - yyps->save = save->save; - save->save = yypath; - yypath = save; - } -#if YYDEBUG - if (yydebug) - fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", - YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); -#endif - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - yylvp = yylvals + yypath->lexeme; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yylpp = yylpsns + yypath->lexeme; -#endif - yylexp = yylexemes + yypath->lexeme; - yychar = YYEMPTY; - yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); - yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); -#endif - yystate = yypath->state; - goto yyloop; -#endif /* YYBTYACC */ - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); -#if YYBTYACC - goto yyabort_nomem; -yyenomem: - YYERROR_CALL("memory exhausted"); -yyabort_nomem: -#endif /* YYBTYACC */ - yyresult = 2; - goto yyreturn; - -yyabort: - yyresult = 1; - goto yyreturn; - -yyaccept: -#if YYBTYACC - if (yyps->save) goto yyvalid; -#endif /* YYBTYACC */ - yyresult = 0; - -yyreturn: -#if defined(YYDESTRUCT_CALL) - if (yychar != YYEOF && yychar != YYEMPTY) -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); -#else - YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - - { - YYSTYPE *pv; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE *pp; - - for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); -#else - for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) - YYDESTRUCT_CALL("cleanup: discarding state", - yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); -#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ - } -#endif /* defined(YYDESTRUCT_CALL) */ - -#if YYBTYACC - if (yyerrctx) - { - yyFreeState(yyerrctx); - yyerrctx = NULL; - } - while (yyps) - { - YYParseState *save = yyps; - yyps = save->save; - save->save = NULL; - yyFreeState(save); - } - while (yypath) - { - YYParseState *save = yypath; - yypath = save->save; - save->save = NULL; - yyFreeState(save); - } -#endif /* YYBTYACC */ - yyfreestack(&yystack); - return (yyresult); -} diff --git a/test/btyacc/varsyntax_calc1.tab.h b/test/btyacc/varsyntax_calc1.tab.h deleted file mode 100644 index 5c28ca8ef13..00000000000 --- a/test/btyacc/varsyntax_calc1.tab.h +++ /dev/null @@ -1,23 +0,0 @@ -#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 YYSTYPE -{ - 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/test/btyacc_calc1.y b/test/btyacc_calc1.y deleted file mode 100644 index 0c6311c881b..00000000000 --- a/test/btyacc_calc1.y +++ /dev/null @@ -1,324 +0,0 @@ -%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/test/btyacc_demo.y b/test/btyacc_demo.y deleted file mode 100644 index 892434c8b15..00000000000 --- a/test/btyacc_demo.y +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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/test/btyacc_destroy1.y b/test/btyacc_destroy1.y deleted file mode 100644 index 413066ddb17..00000000000 --- a/test/btyacc_destroy1.y +++ /dev/null @@ -1,91 +0,0 @@ -%parse-param { struct parser_param *param , int flag } - -%{ -#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; - -struct parser_param { - int *rtrn; - symbol ss; -}; - -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 -%type locnamelist -%type class -%type type -%type namelist - -%destructor { if (!param->rtrn) close($$); } - -%destructor { - namelist *p = $$; - while (p != NULL) - { namelist *pp = p; - p = p->next; - free(pp->s); free(pp); - } - } declaration - -%union -{ - class cval; - type tval; - namelist * nlist; - name id; -} - -%start declaration - -%% -declaration: class type namelist'(' class ',' type ')' - { $$ = $3; } - | type locnamelist '(' class ')' - { $$ = $2; } - ; - -class : GLOBAL { $$ = cGLOBAL; } - | LOCAL { $$ = cLOCAL; } - ; - -type : REAL { $$ = tREAL; } - | INTEGER { $$ = tINTEGER; } - ; - -namelist: namelist NAME - { $$->s = mksymbol($0, $0, $2); - $$->next = $1; - } - | NAME - { $$->s = mksymbol(0, 0, $1); - $$->next = NULL; - } - ; - -locnamelist: namelist '(' LOCAL ',' type ')' - { $$ = $1; } - ; -%% - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); diff --git a/test/btyacc_destroy2.y b/test/btyacc_destroy2.y deleted file mode 100644 index 883b9f5e955..00000000000 --- a/test/btyacc_destroy2.y +++ /dev/null @@ -1,91 +0,0 @@ -%parse-param { struct parser_param *param } { int flag } - -%{ -#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; - -struct parser_param { - int *rtrn; - symbol ss; -}; - -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 -%type locnamelist -%type class -%type type -%type namelist - -%destructor { if (!param->rtrn) close($$); } - -%destructor { - namelist *p = $$; - while (p != NULL) - { namelist *pp = p; - p = p->next; - free(pp->s); free(pp); - } - } declaration - -%union -{ - class cval; - type tval; - namelist * nlist; - name id; -} - -%start declaration - -%% -declaration: class type namelist'(' class ',' type ')' - { $$ = $3; } - | type locnamelist '(' class ')' - { $$ = $2; } - ; - -class : GLOBAL { $$ = cGLOBAL; } - | LOCAL { $$ = cLOCAL; } - ; - -type : REAL { $$ = tREAL; } - | INTEGER { $$ = tINTEGER; } - ; - -namelist: namelist NAME - { $$->s = mksymbol($0, $0, $2); - $$->next = $1; - } - | NAME - { $$->s = mksymbol(0, 0, $1); - $$->next = NULL; - } - ; - -locnamelist: namelist '(' LOCAL ',' type ')' - { $$ = $1; } - ; -%% - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); diff --git a/test/btyacc_destroy3.y b/test/btyacc_destroy3.y deleted file mode 100644 index c111273baca..00000000000 --- a/test/btyacc_destroy3.y +++ /dev/null @@ -1,94 +0,0 @@ -%parse-param { - struct parser_param *param, - int flag - } - -%{ -#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; - -struct parser_param { - int *rtrn; - symbol ss; -}; - -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 -%type locnamelist -%type class -%type type -%type namelist - -%destructor { if (!param->rtrn) close($$); } - -%destructor { - namelist *p = $$; - while (p != NULL) - { namelist *pp = p; - p = p->next; - free(pp->s); free(pp); - } - } declaration - -%union -{ - class cval; - type tval; - namelist * nlist; - name id; -} - -%start declaration - -%% -declaration: class type namelist'(' class ',' type ')' - { $$ = $3; } - | type locnamelist '(' class ')' - { $$ = $2; } - ; - -class : GLOBAL { $$ = cGLOBAL; } - | LOCAL { $$ = cLOCAL; } - ; - -type : REAL { $$ = tREAL; } - | INTEGER { $$ = tINTEGER; } - ; - -namelist: namelist NAME - { $$->s = mksymbol($0, $0, $2); - $$->next = $1; - } - | NAME - { $$->s = mksymbol(0, 0, $1); - $$->next = NULL; - } - ; - -locnamelist: namelist '(' LOCAL ',' type ')' - { $$ = $1; } - ; -%% - -extern int YYLEX_DECL(); -extern void YYERROR_DECL(); diff --git a/test/calc.y b/test/calc.y deleted file mode 100644 index c2e5a898c93..00000000000 --- a/test/calc.y +++ /dev/null @@ -1,106 +0,0 @@ -%{ -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token DIGIT LETTER - -%left '|' -%left '&' -%left '+' '-' -%left '*' '/' '%' -%left UMINUS /* supplies precedence for unary minus */ - -%% /* beginning of rules section */ - -list : /* empty */ - | list stat '\n' - | list error '\n' - { yyerrok ; } - ; - -stat : expr - { printf("%d\n",$1);} - | LETTER '=' expr - { regs[$1] = $3; } - ; - -expr : '(' expr ')' - { $$ = $2; } - | expr '+' expr - { $$ = $1 + $3; } - | expr '-' expr - { $$ = $1 - $3; } - | expr '*' expr - { $$ = $1 * $3; } - | expr '/' expr - { $$ = $1 / $3; } - | expr '%' expr - { $$ = $1 % $3; } - | expr '&' expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | '-' expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/calc1.y b/test/calc1.y deleted file mode 100644 index 1f42e1fce82..00000000000 --- a/test/calc1.y +++ /dev/null @@ -1,305 +0,0 @@ -%{ - -/* 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; - 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 '*' '/' -%left UMINUS /* precedence for unary minus */ - -%% /* beginning of rules section */ - -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]; - } - | 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/test/calc2.y b/test/calc2.y deleted file mode 100644 index d9193d0872b..00000000000 --- a/test/calc2.y +++ /dev/null @@ -1,124 +0,0 @@ -%parse-param { int regs[26] } -%parse-param { int *base } - -%lex-param { int *base } - -%{ -# 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 - -%} - -%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/test/calc3.y b/test/calc3.y deleted file mode 100644 index 2c9148e8010..00000000000 --- a/test/calc3.y +++ /dev/null @@ -1,127 +0,0 @@ -%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 - -%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/test/calc_code_all.y b/test/calc_code_all.y deleted file mode 100644 index 5924877f158..00000000000 --- a/test/calc_code_all.y +++ /dev/null @@ -1,113 +0,0 @@ -%code { /* CODE-DEFAULT2 */ } -%code { /* CODE-DEFAULT */ } -%code requires { /* CODE-REQUIRES */ } -%code provides { /* CODE-PROVIDES */ } -%code top { /* CODE-TOP */ } -%code provides { /* CODE-PROVIDES2 */ } - -%{ -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token DIGIT LETTER - -%left '|' -%left '&' -%left '+' '-' -%left '*' '/' '%' -%left UMINUS /* supplies precedence for unary minus */ - -%% /* beginning of rules section */ - -list : /* empty */ - | list stat '\n' - | list error '\n' - { yyerrok ; } - ; - -stat : expr - { printf("%d\n",$1);} - | LETTER '=' expr - { regs[$1] = $3; } - ; - -expr : '(' expr ')' - { $$ = $2; } - | expr '+' expr - { $$ = $1 + $3; } - | expr '-' expr - { $$ = $1 - $3; } - | expr '*' expr - { $$ = $1 * $3; } - | expr '/' expr - { $$ = $1 / $3; } - | expr '%' expr - { $$ = $1 % $3; } - | expr '&' expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | '-' expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/calc_code_default.y b/test/calc_code_default.y deleted file mode 100644 index a0829affbe3..00000000000 --- a/test/calc_code_default.y +++ /dev/null @@ -1,109 +0,0 @@ -%code { /* CODE-DEFAULT */ } -%code { /* CODE-DEFAULT2 */ } - -%{ -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token DIGIT LETTER - -%left '|' -%left '&' -%left '+' '-' -%left '*' '/' '%' -%left UMINUS /* supplies precedence for unary minus */ - -%% /* beginning of rules section */ - -list : /* empty */ - | list stat '\n' - | list error '\n' - { yyerrok ; } - ; - -stat : expr - { printf("%d\n",$1);} - | LETTER '=' expr - { regs[$1] = $3; } - ; - -expr : '(' expr ')' - { $$ = $2; } - | expr '+' expr - { $$ = $1 + $3; } - | expr '-' expr - { $$ = $1 - $3; } - | expr '*' expr - { $$ = $1 * $3; } - | expr '/' expr - { $$ = $1 / $3; } - | expr '%' expr - { $$ = $1 % $3; } - | expr '&' expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | '-' expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/calc_code_imports.y b/test/calc_code_imports.y deleted file mode 100644 index ded30926f7b..00000000000 --- a/test/calc_code_imports.y +++ /dev/null @@ -1,109 +0,0 @@ -%code imports { /* CODE-IMPORTS */ } -%code imports { /* CODE-IMPORTS2 */ } - -%{ -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token DIGIT LETTER - -%left '|' -%left '&' -%left '+' '-' -%left '*' '/' '%' -%left UMINUS /* supplies precedence for unary minus */ - -%% /* beginning of rules section */ - -list : /* empty */ - | list stat '\n' - | list error '\n' - { yyerrok ; } - ; - -stat : expr - { printf("%d\n",$1);} - | LETTER '=' expr - { regs[$1] = $3; } - ; - -expr : '(' expr ')' - { $$ = $2; } - | expr '+' expr - { $$ = $1 + $3; } - | expr '-' expr - { $$ = $1 - $3; } - | expr '*' expr - { $$ = $1 * $3; } - | expr '/' expr - { $$ = $1 / $3; } - | expr '%' expr - { $$ = $1 % $3; } - | expr '&' expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | '-' expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/calc_code_provides.y b/test/calc_code_provides.y deleted file mode 100644 index 53776928dcd..00000000000 --- a/test/calc_code_provides.y +++ /dev/null @@ -1,109 +0,0 @@ -%code provides { /* CODE-PROVIDES */ } -%code provides { /* CODE-PROVIDES2 */ } - -%{ -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token DIGIT LETTER - -%left '|' -%left '&' -%left '+' '-' -%left '*' '/' '%' -%left UMINUS /* supplies precedence for unary minus */ - -%% /* beginning of rules section */ - -list : /* empty */ - | list stat '\n' - | list error '\n' - { yyerrok ; } - ; - -stat : expr - { printf("%d\n",$1);} - | LETTER '=' expr - { regs[$1] = $3; } - ; - -expr : '(' expr ')' - { $$ = $2; } - | expr '+' expr - { $$ = $1 + $3; } - | expr '-' expr - { $$ = $1 - $3; } - | expr '*' expr - { $$ = $1 * $3; } - | expr '/' expr - { $$ = $1 / $3; } - | expr '%' expr - { $$ = $1 % $3; } - | expr '&' expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | '-' expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/calc_code_requires.y b/test/calc_code_requires.y deleted file mode 100644 index 5254bcbd6de..00000000000 --- a/test/calc_code_requires.y +++ /dev/null @@ -1,109 +0,0 @@ -%code requires { /* CODE-REQUIRES */ } -%code requires { /* CODE-REQUIRES2 */ } - -%{ -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token DIGIT LETTER - -%left '|' -%left '&' -%left '+' '-' -%left '*' '/' '%' -%left UMINUS /* supplies precedence for unary minus */ - -%% /* beginning of rules section */ - -list : /* empty */ - | list stat '\n' - | list error '\n' - { yyerrok ; } - ; - -stat : expr - { printf("%d\n",$1);} - | LETTER '=' expr - { regs[$1] = $3; } - ; - -expr : '(' expr ')' - { $$ = $2; } - | expr '+' expr - { $$ = $1 + $3; } - | expr '-' expr - { $$ = $1 - $3; } - | expr '*' expr - { $$ = $1 * $3; } - | expr '/' expr - { $$ = $1 / $3; } - | expr '%' expr - { $$ = $1 % $3; } - | expr '&' expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | '-' expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/calc_code_top.y b/test/calc_code_top.y deleted file mode 100644 index 8520791e4de..00000000000 --- a/test/calc_code_top.y +++ /dev/null @@ -1,109 +0,0 @@ -%code top { /* CODE-TOP */ } -%code top { /* CODE-TOP2 */ } - -%{ -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token DIGIT LETTER - -%left '|' -%left '&' -%left '+' '-' -%left '*' '/' '%' -%left UMINUS /* supplies precedence for unary minus */ - -%% /* beginning of rules section */ - -list : /* empty */ - | list stat '\n' - | list error '\n' - { yyerrok ; } - ; - -stat : expr - { printf("%d\n",$1);} - | LETTER '=' expr - { regs[$1] = $3; } - ; - -expr : '(' expr ')' - { $$ = $2; } - | expr '+' expr - { $$ = $1 + $3; } - | expr '-' expr - { $$ = $1 - $3; } - | expr '*' expr - { $$ = $1 * $3; } - | expr '/' expr - { $$ = $1 / $3; } - | expr '%' expr - { $$ = $1 % $3; } - | expr '&' expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | '-' expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/code_calc.y b/test/code_calc.y deleted file mode 100644 index 6947b74e175..00000000000 --- a/test/code_calc.y +++ /dev/null @@ -1,114 +0,0 @@ -%token-table - -%{ -# include -# include - -int regs[26]; -int base; - -#ifdef YYBISON -int yylex(void); -static void yyerror(const char *s); -#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) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/code_debug.y b/test/code_debug.y deleted file mode 100644 index bb771567606..00000000000 --- a/test/code_debug.y +++ /dev/null @@ -1,36 +0,0 @@ -%{ - -#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/test/code_error.y b/test/code_error.y deleted file mode 100644 index bb771567606..00000000000 --- a/test/code_error.y +++ /dev/null @@ -1,36 +0,0 @@ -%{ - -#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/test/empty.y b/test/empty.y deleted file mode 100644 index 2e60a743cf0..00000000000 --- a/test/empty.y +++ /dev/null @@ -1,24 +0,0 @@ -%{ -#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/test/err_inherit1.y b/test/err_inherit1.y deleted file mode 100644 index 6c16e17cd8b..00000000000 --- a/test/err_inherit1.y +++ /dev/null @@ -1,64 +0,0 @@ -%{ -#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/test/err_inherit2.y b/test/err_inherit2.y deleted file mode 100644 index a39e2d0f1bf..00000000000 --- a/test/err_inherit2.y +++ /dev/null @@ -1,80 +0,0 @@ -%{ -#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/test/err_inherit3.y b/test/err_inherit3.y deleted file mode 100644 index f52a5f7b6e3..00000000000 --- a/test/err_inherit3.y +++ /dev/null @@ -1,80 +0,0 @@ -%{ -#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/test/err_inherit4.y b/test/err_inherit4.y deleted file mode 100644 index 8e9aeb9fe6e..00000000000 --- a/test/err_inherit4.y +++ /dev/null @@ -1,82 +0,0 @@ -%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; @$ = @3; } - | type locnamelist($1) - { $$ = $2; @$ = @-1; } - ; - -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/test/err_inherit5.y b/test/err_inherit5.y deleted file mode 100644 index 56c5c7e4c07..00000000000 --- a/test/err_inherit5.y +++ /dev/null @@ -1,80 +0,0 @@ -%{ -#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/test/err_syntax1.y b/test/err_syntax1.y deleted file mode 100644 index 27355207a24..00000000000 --- a/test/err_syntax1.y +++ /dev/null @@ -1,28 +0,0 @@ - % { -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/test/err_syntax10.y b/test/err_syntax10.y deleted file mode 100644 index 581f8458df5..00000000000 --- a/test/err_syntax10.y +++ /dev/null @@ -1,32 +0,0 @@ -%{ -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/test/err_syntax11.y b/test/err_syntax11.y deleted file mode 100644 index 81bdf6914cf..00000000000 --- a/test/err_syntax11.y +++ /dev/null @@ -1,32 +0,0 @@ -%{ -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/test/err_syntax12.y b/test/err_syntax12.y deleted file mode 100644 index ae1a48c1762..00000000000 --- a/test/err_syntax12.y +++ /dev/null @@ -1,32 +0,0 @@ -%{ -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/test/err_syntax13.y b/test/err_syntax13.y deleted file mode 100644 index f28ed435eef..00000000000 --- a/test/err_syntax13.y +++ /dev/null @@ -1,32 +0,0 @@ -%{ -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/test/err_syntax14.y b/test/err_syntax14.y deleted file mode 100644 index 43e4fc07890..00000000000 --- a/test/err_syntax14.y +++ /dev/null @@ -1,32 +0,0 @@ -%{ -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/test/err_syntax15.y b/test/err_syntax15.y deleted file mode 100644 index 88814c9143d..00000000000 --- a/test/err_syntax15.y +++ /dev/null @@ -1,32 +0,0 @@ -%% -%{ -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/test/err_syntax16.y b/test/err_syntax16.y deleted file mode 100644 index 0479e821776..00000000000 --- a/test/err_syntax16.y +++ /dev/null @@ -1,40 +0,0 @@ -%{ -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/test/err_syntax17.y b/test/err_syntax17.y deleted file mode 100644 index a5551c2f7c7..00000000000 --- a/test/err_syntax17.y +++ /dev/null @@ -1,30 +0,0 @@ -%{ -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/test/err_syntax18.y b/test/err_syntax18.y deleted file mode 100644 index 1407af802ae..00000000000 --- a/test/err_syntax18.y +++ /dev/null @@ -1,33 +0,0 @@ -%{ -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/test/err_syntax19.y b/test/err_syntax19.y deleted file mode 100644 index e2ee5497a8e..00000000000 --- a/test/err_syntax19.y +++ /dev/null @@ -1,33 +0,0 @@ -%{ -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/test/err_syntax2.y b/test/err_syntax2.y deleted file mode 100644 index 247511ebd8e..00000000000 --- a/test/err_syntax2.y +++ /dev/null @@ -1,28 +0,0 @@ -%{ /* -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/test/err_syntax20.y b/test/err_syntax20.y deleted file mode 100644 index 880e0181704..00000000000 --- a/test/err_syntax20.y +++ /dev/null @@ -1,36 +0,0 @@ -%{ -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/test/err_syntax21.y b/test/err_syntax21.y deleted file mode 100644 index ba6ec7080f0..00000000000 --- a/test/err_syntax21.y +++ /dev/null @@ -1,36 +0,0 @@ -%{ -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/test/err_syntax22.y b/test/err_syntax22.y deleted file mode 100644 index e92decbf5e5..00000000000 --- a/test/err_syntax22.y +++ /dev/null @@ -1,44 +0,0 @@ -%{ -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/test/err_syntax23.y b/test/err_syntax23.y deleted file mode 100644 index 4fe51c5c553..00000000000 --- a/test/err_syntax23.y +++ /dev/null @@ -1,46 +0,0 @@ -%{ -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/test/err_syntax24.y b/test/err_syntax24.y deleted file mode 100644 index 3cc4f87a767..00000000000 --- a/test/err_syntax24.y +++ /dev/null @@ -1,46 +0,0 @@ -%{ -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/test/err_syntax25.y b/test/err_syntax25.y deleted file mode 100644 index 9b5dfd13eb8..00000000000 --- a/test/err_syntax25.y +++ /dev/null @@ -1,51 +0,0 @@ -%{ -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/test/err_syntax26.y b/test/err_syntax26.y deleted file mode 100644 index 748382ba2c0..00000000000 --- a/test/err_syntax26.y +++ /dev/null @@ -1,6 +0,0 @@ -%{ -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/test/err_syntax3.y b/test/err_syntax3.y deleted file mode 100644 index c10b227f2bf..00000000000 --- a/test/err_syntax3.y +++ /dev/null @@ -1,31 +0,0 @@ -%{ -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/test/err_syntax4.y b/test/err_syntax4.y deleted file mode 100644 index 2c6f22ff25f..00000000000 --- a/test/err_syntax4.y +++ /dev/null @@ -1,28 +0,0 @@ -%{ -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/test/err_syntax5.y b/test/err_syntax5.y deleted file mode 100644 index ca9ce1a40e7..00000000000 --- a/test/err_syntax5.y +++ /dev/null @@ -1,33 +0,0 @@ -%{ -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/test/err_syntax6.y b/test/err_syntax6.y deleted file mode 100644 index 5d87945cb1f..00000000000 --- a/test/err_syntax6.y +++ /dev/null @@ -1,31 +0,0 @@ -%{ -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/test/err_syntax7.y b/test/err_syntax7.y deleted file mode 100644 index 783d563f33d..00000000000 --- a/test/err_syntax7.y +++ /dev/null @@ -1,31 +0,0 @@ -%{ -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/test/err_syntax7a.y b/test/err_syntax7a.y deleted file mode 100644 index ae105d0d0c9..00000000000 --- a/test/err_syntax7a.y +++ /dev/null @@ -1,31 +0,0 @@ -%{ -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/test/err_syntax7b.y b/test/err_syntax7b.y deleted file mode 100644 index a3e5e216ffe..00000000000 --- a/test/err_syntax7b.y +++ /dev/null @@ -1,31 +0,0 @@ -%{ -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/test/err_syntax8.y b/test/err_syntax8.y deleted file mode 100644 index 5ac0974dba4..00000000000 --- a/test/err_syntax8.y +++ /dev/null @@ -1,31 +0,0 @@ -%{ -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/test/err_syntax8a.y b/test/err_syntax8a.y deleted file mode 100644 index 9a3a76cf42c..00000000000 --- a/test/err_syntax8a.y +++ /dev/null @@ -1,31 +0,0 @@ -%{ -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/test/err_syntax9.y b/test/err_syntax9.y deleted file mode 100644 index f3ec6fab319..00000000000 --- a/test/err_syntax9.y +++ /dev/null @@ -1,32 +0,0 @@ -%{ -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/test/error.y b/test/error.y deleted file mode 100644 index 673c68d68e9..00000000000 --- a/test/error.y +++ /dev/null @@ -1,28 +0,0 @@ -%{ -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/test/expr.oxout.y b/test/expr.oxout.y deleted file mode 100644 index 80f16bd9b3a..00000000000 --- a/test/expr.oxout.y +++ /dev/null @@ -1,1446 +0,0 @@ -/* output from Ox version G1.04 */ -#line 1 "expr.Y" -#line 4 "expr.oxout.y" -%{ -#include -#include -%} -#line 1 "expr.Y" -/* Y-file for translation of infix expressions to prefix and postfix */ -%token ID CONST -%start yyyAugNonterm -%left '+' '-' -%left '*' '/' -%nonassoc '*' - -%{ -#include "expr.oxout.h" -#include - -extern int yylex(void); -extern void yyerror(const char *); -%} - -#line 25 "expr.oxout.y" - -%{ -#include -#define yyyR USHRT_MAX -%} -%type yyyAugNonterm -%union { -struct yyyOxAttrbs { -struct yyyStackItem *yyyOxStackItem; -} yyyOxAttrbs; -} - -%{ -#include -#include - -static int yyyYok = 1; - -extern yyyFT yyyRCIL[]; - -void yyyExecuteRRsection(yyyGNT *rootNode); -void yyyYoxInit(void); -void yyyDecorate(void); -struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ -void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); -void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); -void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); -void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); -void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); -void yyyabort(void); - -%} - - -#line 20 "expr.Y" -%% - -#line 63 "expr.oxout.y" -yyyAugNonterm - : {yyyYoxInit();} - s - { - yyyDecorate(); yyyExecuteRRsection($2.yyyOxStackItem->node); - } - ; -#line 21 "expr.Y" -s : expr -#line 73 "expr.oxout.y" -{if(yyyYok){ -yyyGenIntNode(1,1,0,&$$,&$1); -yyyAdjustINRC(1,1,0,0,&$$,&$1);}} - -#line 27 "expr.Y" -expr : expr '*' expr -#line 80 "expr.oxout.y" -{if(yyyYok){ -yyyGenIntNode(2,3,0,&$$,&$1,&$2,&$3); -yyyAdjustINRC(2,3,0,0,&$$,&$1,&$2,&$3);}} - -#line 31 "expr.Y" - | expr '+' expr -#line 87 "expr.oxout.y" -{if(yyyYok){ -yyyGenIntNode(3,3,0,&$$,&$1,&$2,&$3); -yyyAdjustINRC(3,3,0,0,&$$,&$1,&$2,&$3);}} - -#line 35 "expr.Y" - | expr '/' expr -#line 94 "expr.oxout.y" -{if(yyyYok){ -yyyGenIntNode(4,3,0,&$$,&$1,&$2,&$3); -yyyAdjustINRC(4,3,0,0,&$$,&$1,&$2,&$3);}} - -#line 39 "expr.Y" - | expr '-' expr -#line 101 "expr.oxout.y" -{if(yyyYok){ -yyyGenIntNode(5,3,0,&$$,&$1,&$2,&$3); -yyyAdjustINRC(5,3,0,0,&$$,&$1,&$2,&$3);}} - -#line 43 "expr.Y" - | '(' expr ')' -#line 108 "expr.oxout.y" -{if(yyyYok){ -yyyGenIntNode(6,3,0,&$$,&$1,&$2,&$3); -yyyAdjustINRC(6,3,0,0,&$$,&$1,&$2,&$3);}} -#line 44 "expr.Y" - | ID -#line 114 "expr.oxout.y" -{if(yyyYok){ -yyyGenIntNode(7,1,0,&$$,&$1); -yyyAdjustINRC(7,1,0,0,&$$,&$1);}} - -#line 48 "expr.Y" - | CONST -#line 121 "expr.oxout.y" -{if(yyyYok){ -yyyGenIntNode(8,1,0,&$$,&$1); -yyyAdjustINRC(8,1,0,0,&$$,&$1);}} - -#line 52 "expr.Y" - ; -%% - -int yyparse(void); - -int main() - {yyparse(); - } - - - -#line 138 "expr.oxout.y" -long yyySSALspaceSize = 20000; -long yyyRSmaxSize = 1000; -long yyyTravStackMaxSize = 2000; - -struct yyySolvedSAlistCell {yyyWAT attrbNum; - long next; - }; - -#define yyyLambdaSSAL 0 -long yyySSALCfreeList = yyyLambdaSSAL; -long yyyNewSSALC = 1; - -struct yyySolvedSAlistCell *yyySSALspace; - -long yyyNbytesStackStg; - - - -yyyFT yyyRCIL[1]; - -short yyyIIIEL[] = {0, -0,2,6,10,14,18,22,24, -}; - -long yyyIIEL[] = { -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,1, -}; - -long yyyIEL[] = { -0,0,0, -}; - -yyyFT yyyEntL[1]; - -void yyyfatal(char *msg) -{fputs(msg,stderr);exit(-1);} - - - -#define yyySSALof 'S' -#define yyyRSof 'q' -#define yyyTSof 't' - - - -void yyyHandleOverflow(char which) - {char *msg1 = "?", *msg2; - long oldSize = 0, newSize; - switch(which) - { - case yyySSALof : - msg1 = "SSAL overflow: "; - oldSize = yyySSALspaceSize; - break; - case yyyRSof : - msg1 = "ready set overflow: "; - oldSize = yyyRSmaxSize; - break; - case yyyTSof : - msg1 = "traversal stack overflow: "; - oldSize = yyyTravStackMaxSize; - break; - default :; - } - newSize = (3*oldSize)/2; - if (newSize < 100) newSize = 100; - fputs(msg1,stderr); - fprintf(stderr,"size was %ld.\n",oldSize); - msg2 = " Have to modify evaluator: -Y%c%ld.\n"; - fprintf(stderr,msg2,which,newSize); - exit(-1); - } - - - -void yyySignalEnts(yyyGNT *node,long startP,long stopP) - {yyyGNT *dumNode; - - while (startP < stopP) - { - if (!yyyEntL[startP]) dumNode = node; - else dumNode = (node->cL)[yyyEntL[startP]-1]; - if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] - ) - ) - ) - { - if (++yyyRSTop == yyyAfterRS) - {yyyHandleOverflow(yyyRSof); - break; - } - yyyRSTop->node = dumNode; - yyyRSTop->whichSym = yyyEntL[startP]; - yyyRSTop->wa = yyyEntL[startP+1]; - } - startP += 2; - } - } - - - - - - -void yyySolveAndSignal() { -long yyyiDum,*yyypL; -int yyyws,yyywa; -yyyGNT *yyyRSTopN,*yyyRefN; -yyyParent yyyRSTopNp; - - -yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; -yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; -yyywa = yyyRSTop->wa; -yyyRSTop--; -switch(yyyRefN->prodNum) { -case 1: /***yacc rule 1***/ - switch (yyyws) { - } -break; -case 2: /***yacc rule 2***/ - switch (yyyws) { - } -break; -case 3: /***yacc rule 3***/ - switch (yyyws) { - } -break; -case 4: /***yacc rule 4***/ - switch (yyyws) { - } -break; -case 5: /***yacc rule 5***/ - switch (yyyws) { - } -break; -case 6: /***yacc rule 6***/ - switch (yyyws) { - } -break; -case 7: /***yacc rule 7***/ - switch (yyyws) { - case 1: /**/ - switch (yyywa) { - } - break; - } -break; -case 8: /***yacc rule 8***/ - switch (yyyws) { - case 1: /**/ - switch (yyywa) { - } - break; - } -break; -} /* switch */ - -if (yyyws) /* the just-solved instance was inherited. */ - {if (yyyRSTopN->prodNum) - {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; - yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], - yyyIEL[yyyiDum+1] - ); - } - } - else /* the just-solved instance was synthesized. */ - {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ - {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + - yyyRSTopN->whichSym - ] + - yyywa; - yyySignalEnts(yyyRSTopNp.noderef, - yyyIEL[yyyiDum], - yyyIEL[yyyiDum+1] - ); - } - else /* node is still on the stack--it has no parent yet. */ - {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); - if (yyySSALCfreeList == yyyLambdaSSAL) - {yyySSALspace[yyyNewSSALC].next = *yyypL; - if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) - yyyHandleOverflow(yyySSALof); - } - else - {yyyiDum = yyySSALCfreeList; - yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; - yyySSALspace[yyyiDum].next = *yyypL; - *yyypL = yyyiDum; - } - yyySSALspace[*yyypL].attrbNum = yyywa; - } - } - -} /* yyySolveAndSignal */ - - - - - - -#define condStg unsigned int conds; -#define yyyClearConds {yyyTST->conds = 0;} -#define yyySetCond(n) {yyyTST->conds += (1<<(n));} -#define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) - - - -struct yyyTravStackItem {yyyGNT *node; - char isReady; - condStg - }; - - - -void yyyDoTraversals(yyyGNT *rootNode) -{struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; - yyyGNT *yyyTSTn,**yyyCLptr2; - int yyyi,yyyRL,yyyPass; - int i; - - if (!yyyYok) return; - if ((yyyTravStack = - ((struct yyyTravStackItem *) - calloc((size_t)yyyTravStackMaxSize, - (size_t)sizeof(struct yyyTravStackItem) - ) - ) - ) - == - (struct yyyTravStackItem *)NULL - ) - {fputs("malloc error in traversal stack allocation\n",stderr); - exit(-1); - } - -yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; -yyyTravStack++; - - -for (yyyi=0; yyyi<2; yyyi++) { -yyyTST = yyyTravStack; -yyyTST->node = rootNode; -yyyTST->isReady = 0; -yyyClearConds - -while(yyyTST >= yyyTravStack) - {yyyTSTn = yyyTST->node; - if (yyyTST->isReady) - {yyyPass = 1; - goto yyyTravSwitch; -yyyTpop: - yyyTST--; - } - else - {yyyPass = 0; - goto yyyTravSwitch; -yyyTpush: - yyyTST->isReady = 1; - if (yyyTSTn->prodNum) - {if (yyyRL) - {yyyCLptr2 = yyyTSTn->cL; - i = yyyTSTn->cLlen; - while (i--) - {if (++yyyTST == yyyAfterTravStack) - yyyHandleOverflow(yyyTSof); - else - {yyyTST->node = *yyyCLptr2; - yyyTST->isReady = 0; - yyyClearConds - } - yyyCLptr2++; - } - } /* right to left */ - else /* left to right */ - {i = yyyTSTn->cLlen; - yyyCLptr2 = yyyTSTn->cL + i; - while (i--) - {yyyCLptr2--; - if (++yyyTST == yyyAfterTravStack) - yyyHandleOverflow(yyyTSof); - else - {yyyTST->node = *yyyCLptr2; - yyyTST->isReady = 0; - yyyClearConds - } - } - } /* left to right */ - } - } /* else */ - continue; -yyyTravSwitch: - switch(yyyTSTn->prodNum) { -case 1: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - -if (! -#line 24 "expr.Y" - (1) -#line 444 "expr.oxout.y" -) yyySetCond(1) -yyySetCond(2) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 24 "expr.Y" - -#line 453 "expr.oxout.y" -} -if (yyyCond(1) != yyyPass) { -#line 24 "expr.Y" - printf("\n"); - -#line 459 "expr.oxout.y" -} -if (yyyCond(2) != yyyPass) { -#line 25 "expr.Y" - printf("prefix: "); - -#line 465 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; -if ( -#line 23 "expr.Y" - (1) -#line 477 "expr.oxout.y" -) yyySetCond(2) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 22 "expr.Y" - printf("\n"); - -#line 486 "expr.oxout.y" -} -if (yyyCond(1) != yyyPass) { -#line 23 "expr.Y" - -#line 491 "expr.oxout.y" -} -if (yyyCond(2) != yyyPass) { -#line 23 "expr.Y" - printf("postfix: "); - -#line 497 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 2: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 29 "expr.Y" - printf(" * "); - -#line 518 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 28 "expr.Y" - printf(" * "); - -#line 533 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 3: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 32 "expr.Y" - printf(" + "); - -#line 554 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 33 "expr.Y" - printf(" + "); - -#line 569 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 4: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 37 "expr.Y" - printf(" / "); - -#line 590 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 36 "expr.Y" - printf(" / "); - -#line 605 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 5: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 41 "expr.Y" - printf(" - "); - -#line 626 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 40 "expr.Y" - printf(" - "); - -#line 641 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 6: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - - break; - } - break; - } - -break; -case 7: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 46 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 685 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 45 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 700 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 8: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 50 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 721 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 49 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 736 "expr.oxout.y" -} - break; - } - break; - } - -break; - } /* switch */ - if (yyyPass) goto yyyTpop; else goto yyyTpush; - } /* while */ - } /* for */ -} /* yyyDoTraversals */ - -void yyyExecuteRRsection(yyyGNT *rootNode) { - int yyyi; - long cycleSum = 0; - long nNZrc = 0; - - if (!yyyYok) return; - yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); - if (nNZrc) - { - fputs("\n\n\n**********\n",stderr); - fputs("cycle detected in completed parse tree",stderr); - fputs(" after decoration.\n",stderr); -#if CYCLE_VERBOSE - fprintf(stderr, - "number of unsolved attribute instances == %ld.\n", - nNZrc - ); - fprintf(stderr, - "total number of remaining dependencies == %ld.\n", - cycleSum - ); - fputs("average number of remaining dependencies\n",stderr); - fprintf(stderr," per unsolved instance == %f.\n", - ((float)(cycleSum)/(float)(nNZrc)) - ); -#endif - fprintf(stderr, - "searching parse tree for %ld unsolved instances:\n", - nNZrc - ); - yyyUnsolvedInstSearchTravAux(rootNode); - } - yyyDoTraversals(rootNode); -} /* yyyExecuteRRsection */ - - - -yyyWAT yyyLRCIL[2] = {0,0, -}; - - - -void yyyYoxInit(void) - { - static int yyyInitDone = 0; - if (yyyInitDone) return; - - if ((yyyRS = (yyyRSitem *) - calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(yyyRSitem)) - ) - == - ((yyyRSitem *) NULL) - ) - yyyfatal("malloc error in ox ready set space allocation\n"); - yyyRS++; - yyyAfterRS = yyyRS + yyyRSmaxSize; - - - if ((yyySSALspace = (struct yyySolvedSAlistCell *) - calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) - ) - == - ((struct yyySolvedSAlistCell *) NULL) - ) - yyyfatal("malloc error in stack solved list space allocation\n"); - yyyInitDone = 1; - - yyyRSTop = yyyRS - 1; - } /* yyyYoxInit */ - - - -void yyyDecorate(void) - { - while (yyyRSTop >= yyyRS) - yyySolveAndSignal(); - } - - - -void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) - {yyyWST i; - yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; - yyyGNT *gnpDum; - va_list ap; - - *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); - if (*yyyOxStackItem == (yyySIT *) NULL) - yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); - (*yyyOxStackItem)->node = - (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); - if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) - yyyfatal("malloc error in ox node space allocation\n"); - (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; - (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; - (*yyyOxStackItem)->node->parentIsStack = 1; - (*yyyOxStackItem)->node->cLlen = yyyRHSlength; - (*yyyOxStackItem)->node->cL = - (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); - if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) - yyyfatal("malloc error in ox child list space allocation\n"); - (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; - (*yyyOxStackItem)->node->refCountList = - (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); - if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) - yyyfatal("malloc error in ox reference count list space allocation\n"); - (*yyyOxStackItem)->node->prodNum = (int) yyyProdNum; - va_start(ap, yyval_OxAttrbs); - for (i=1;i<=yyyRHSlength;i++) - {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; - gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; - gnpDum->whichSym = i; - gnpDum->parent.noderef = (*yyyOxStackItem)->node; - gnpDum->parentIsStack = 0; - } - va_end(ap); - } - - - -#define yyyDECORfREQ 50 - - - -void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) - {yyyWST i; - yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; - long SSALptr,SSALptrHead,*cPtrPtr; - long *pL; - yyyGNT *gnpDum; - long iTemp; - long nextP; - static unsigned short intNodeCount = yyyDECORfREQ; - va_list ap; - - nextP = startP; - while (nextP < stopP) - {if (yyyRCIL[nextP] == yyyR) - {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; - } - else - {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; - } - nextP += 3; - } - pL = yyyIIEL + yyyIIIEL[yyyProdNum]; - va_start(ap, yyval_OxAttrbs); - for (i=1;i<=yyyRHSlength;i++) - {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; - pL++; - SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); - if (SSALptr != yyyLambdaSSAL) - {*cPtrPtr = yyyLambdaSSAL; - do - { - iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); - yyySignalEnts(yyyOxStackItem->node, - yyyIEL[iTemp], - yyyIEL[iTemp+1] - ); - SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); - } - while (SSALptr != yyyLambdaSSAL); - *cPtrPtr = yyySSALCfreeList; - yyySSALCfreeList = SSALptrHead; - } - } - va_end(ap); - nextP = startP + 2; - while (nextP < stopP) - {if (!yyyRCIL[nextP]) - {if (yyyRCIL[nextP-2] == yyyR) - {pL = &(yyyOxStackItem->solvedSAlist); - if (yyySSALCfreeList == yyyLambdaSSAL) - {yyySSALspace[yyyNewSSALC].next = *pL; - if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) - yyyHandleOverflow(yyySSALof); - } - else - {iTemp = yyySSALCfreeList; - yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; - yyySSALspace[iTemp].next = *pL; - *pL = iTemp; - } - yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; - } - else - {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) - { - iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; - yyySignalEnts(gnpDum, - yyyIEL[iTemp], - yyyIEL[iTemp+1] - ); - } - } - } - nextP += 3; - } - if (!--intNodeCount) - {intNodeCount = yyyDECORfREQ; - yyyDecorate(); - } - } - - - -void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *mylval) - {yyyRCT *rcPdum; - yyySIT **yyyOxStackItem = &mylval->yyyOxAttrbs.yyyOxStackItem; - (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); - if ((*yyyOxStackItem) == (yyySIT *) NULL) - yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); - (*yyyOxStackItem)->node = - (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) - ; - if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) - yyyfatal("malloc error in ox node space allocation\n"); - (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; - (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; - (*yyyOxStackItem)->node->parentIsStack = 1; - (*yyyOxStackItem)->node->cLlen = 0; - (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; - (*yyyOxStackItem)->node->refCountListLen = nAttrbs; - rcPdum = (*yyyOxStackItem)->node->refCountList = - (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); - if (rcPdum == (yyyRCT *) NULL) - yyyfatal("malloc error in ox reference count list space allocation\n"); - while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; - (*yyyOxStackItem)->node->prodNum = 0; - (*yyyOxStackItem)->node->whichSym = 0; - } - - - -void yyyabort(void) - {yyyYok = 0; - } - - - - - -#define yyyLastProdNum 8 - - -#define yyyNsorts 1 - - -int yyyProdsInd[] = { - 0, - 0, 2, 6, 10, 14, 18, 22, 24, - 26, -}; - - -int yyyProds[][2] = { -{ 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, -{ 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, -{ 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, -{ 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, -{ 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, -{ 567, 1}, -}; - - -int yyySortsInd[] = { - 0, - 0, - 1, -}; - - -int yyySorts[] = { - 413, -}; - - - -char *yyyStringTab[] = { -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"s",0,0,0, -0,0,"y",0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"LRpre",0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"'('",0,0,0, -0,0,0,0,"')'", -0,0,0,0,0, -0,0,"'*'","lexeme",0, -0,0,0,0,0, -"'+'",0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"'-'",0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,"'/'",0,0, -0,0,0,0,0, -0,0,"expr",0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"printf",0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,"CONST","LRpost",0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,"ID", -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0, -}; - - - -#define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) - -#define yyyGSoccurStr(prodNum,symPos) \ - (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) - -#define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) - -#define yyySortOf(prodNum,symPos) \ - (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) - -#define yyyAttrbStr(prodNum,symPos,attrbNum) \ - (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ - (attrbNum) \ - ] \ - ] \ - ) - - - -void yyyShowProd(int i) - {int j,nSyms; - - nSyms = yyySizeofProd(i); - for (j=0; j\n",stderr); - else - putc('\n',stderr); - } - } - } - - - -void yyyCheckNodeInstancesSolved(yyyGNT *np) - {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; - int nUnsolvedInsts = 0; - - if (np->prodNum != 0) - {inTerminalNode = 0; - prodNum = np->prodNum; - symPos = 0; - } - else - {inTerminalNode = 1; - prodNum = np->parent.noderef->prodNum; - symPos = np->whichSym; - } - mysort = yyySortOf(prodNum,symPos); - sortSize = yyySizeofSort(mysort); - for (i=0; irefCountList)[i] != 0) nUnsolvedInsts += 1; - if (nUnsolvedInsts) - {fprintf(stderr, - "\nFound node that has %d unsolved attribute instance(s).\n", - nUnsolvedInsts - ); - fprintf(stderr,"Node is labeled \"%s\".\n", - yyyGSoccurStr(prodNum,symPos)); - if (inTerminalNode) - {fputs("Node is terminal. Its parent production is:\n ",stderr); - yyyShowProd(prodNum); - } - else - {fputs("Node is nonterminal. ",stderr); - if (!(np->parentIsStack)) - {fprintf(stderr, - "Node is %dth child in its parent production:\n ", - np->whichSym - ); - yyyShowProd(np->parent.noderef->prodNum); - } - fputs("Node is on left hand side of this production:\n ",stderr); - yyyShowProd(np->prodNum); - } - fputs("The following instances are unsolved:\n",stderr); - for (i=0; irefCountList)[i] != 0) - fprintf(stderr," %-16s still has %1d dependencies.\n", - yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); - } - } - - - -void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) - {yyyGNT **yyyCLpdum; - yyyRCT *rcp; - int i; - - /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ - rcp = pNode->refCountList; - i = pNode->refCountListLen; - while (i--) - if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} - yyyCLpdum = pNode->cL; - i = pNode->cLlen; - while (i--) - { - yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); - yyyCLpdum++; - } - } - - - -void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) - {yyyGNT **yyyCLpdum; - int i; - - yyyCheckNodeInstancesSolved(pNode); - yyyCLpdum = pNode->cL; - i = pNode->cLlen; - while (i--) - { - yyyUnsolvedInstSearchTravAux(*yyyCLpdum); - yyyCLpdum++; - } - } - - - -void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) - {yyyGNT **yyyCLpdum; - int i; - - yyyCLpdum = pNode->cL; - i = pNode->cLlen; - while (i--) - { - yyyUnsolvedInstSearchTravAux(*yyyCLpdum); - yyyCLpdum++; - } - } - - - diff --git a/test/grammar.y b/test/grammar.y deleted file mode 100644 index c4c8fd58093..00000000000 --- a/test/grammar.y +++ /dev/null @@ -1,1184 +0,0 @@ -/* $Id: grammar.y,v 1.7 2020/03/30 23:55:49 tom Exp $ - * - * yacc grammar for C function prototype generator - * This was derived from the grammar in Appendix A of - * "The C Programming Language" by Kernighan and Ritchie. - */ -%expect 1 -%{ -#ifdef YYBISON -#include -#define YYSTYPE_IS_DECLARED -#define yyerror yaccError -#endif - -#if defined(YYBISON) || !defined(YYBYACC) -static void yyerror(const char *s); -#endif -%} - -%token '(' '*' '&' - /* identifiers that are not reserved words */ - T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME - - /* storage class */ - T_AUTO T_EXTERN T_REGISTER T_STATIC T_TYPEDEF - /* This keyword included for compatibility with C++. */ - T_INLINE - /* This keyword included for compatibility with GCC */ - T_EXTENSION - - /* type specifiers */ - T_CHAR T_DOUBLE T_FLOAT T_INT T_VOID - T_LONG T_SHORT T_SIGNED T_UNSIGNED - T_ENUM T_STRUCT T_UNION - /* C9X new types */ - T_Bool T_Complex T_Imaginary - - /* type qualifiers */ - T_TYPE_QUALIFIER - - /* paired square brackets and everything between them: [ ... ] */ - T_BRACKETS - -%token - /* left brace */ - T_LBRACE - /* all input to the matching right brace */ - T_MATCHRBRACE - - /* three periods */ - T_ELLIPSIS - - /* constant expression or paired braces following an equal sign */ - T_INITIALIZER - - /* string literal */ - T_STRING_LITERAL - - /* asm */ - T_ASM - /* ( "string literal" ) following asm keyword */ - T_ASMARG - - /* va_dcl from */ - T_VA_DCL - -%type decl_specifiers decl_specifier -%type storage_class type_specifier type_qualifier -%type struct_or_union_specifier enum_specifier -%type init_declarator_list -%type init_declarator declarator direct_declarator -%type abs_declarator direct_abs_declarator -%type parameter_type_list parameter_list -%type parameter_declaration -%type opt_identifier_list identifier_list -%type struct_or_union pointer opt_type_qualifiers type_qualifier_list - any_id identifier_or_ref -%type enumeration - -%{ -#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 -#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3) - -/* 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; -} -%} -%% - -program - : /* empty */ - | translation_unit - ; - -translation_unit - : external_declaration - | translation_unit external_declaration - ; - -external_declaration - : declaration - | function_definition - | ';' - | linkage_specification - | T_ASM T_ASMARG ';' - | error T_MATCHRBRACE - { - yyerrok; - } - | error ';' - { - yyerrok; - } - ; - -braces - : T_LBRACE T_MATCHRBRACE - ; - -linkage_specification - : T_EXTERN T_STRING_LITERAL braces - { - /* Provide an empty action here so bison will not complain about - * incompatible types in the default action it normally would - * have generated. - */ - } - | T_EXTERN T_STRING_LITERAL declaration - { - /* empty */ - } - ; - -declaration - : decl_specifiers ';' - { -#if OPT_LINTLIBRARY - if (types_out && want_typedef()) { - gen_declarations(&$1, (DeclaratorList *)0); - flush_varargs(); - } -#endif - free_decl_spec(&$1); - end_typedef(); - } - | decl_specifiers init_declarator_list ';' - { - if (func_params != NULL) { - set_param_types(func_params, &$1, &$2); - } else { - gen_declarations(&$1, &$2); -#if OPT_LINTLIBRARY - flush_varargs(); -#endif - free_decl_list(&$2); - } - free_decl_spec(&$1); - end_typedef(); - } - | any_typedef decl_specifiers - { - cur_decl_spec_flags = $2.flags; - free_decl_spec(&$2); - } - opt_declarator_list ';' - { - end_typedef(); - } - ; - -any_typedef - : T_EXTENSION T_TYPEDEF - { - begin_typedef(); - } - | T_TYPEDEF - { - begin_typedef(); - } - ; - -opt_declarator_list - : /* empty */ - | declarator_list - ; - -declarator_list - : declarator - { - 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($1->text, $1->name) != 0) - flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT); - new_symbol(typedef_names, $1->name, NULL, flags); - free_declarator($1); - } - | declarator_list ',' declarator - { - int flags = cur_decl_spec_flags; - - if (strcmp($3->text, $3->name) != 0) - flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT); - new_symbol(typedef_names, $3->name, NULL, flags); - free_declarator($3); - } - ; - -function_definition - : decl_specifiers declarator - { - check_untagged(&$1); - if ($2->func_def == FUNC_NONE) { - yyerror("syntax error"); - YYERROR; - } - func_params = &($2->head->params); - func_params->begin_comment = cur_file->begin_comment; - func_params->end_comment = cur_file->end_comment; - } - opt_declaration_list T_LBRACE - { - /* 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() - && $2->head->func_def == func_style) { - $2->head->func_def = FUNC_BOTH; - } - - func_params = NULL; - - if (cur_file->convert) - gen_func_definition(&$1, $2); - gen_prototype(&$1, $2); -#if OPT_LINTLIBRARY - flush_varargs(); -#endif - free_decl_spec(&$1); - free_declarator($2); - } - T_MATCHRBRACE - | declarator - { - if ($1->func_def == FUNC_NONE) { - yyerror("syntax error"); - YYERROR; - } - func_params = &($1->head->params); - func_params->begin_comment = cur_file->begin_comment; - func_params->end_comment = cur_file->end_comment; - } - opt_declaration_list T_LBRACE T_MATCHRBRACE - { - DeclSpec decl_spec; - - func_params = NULL; - - new_decl_spec(&decl_spec, dft_decl_spec(), $1->begin, DS_NONE); - if (cur_file->convert) - gen_func_definition(&decl_spec, $1); - gen_prototype(&decl_spec, $1); -#if OPT_LINTLIBRARY - flush_varargs(); -#endif - free_decl_spec(&decl_spec); - free_declarator($1); - } - ; - -opt_declaration_list - : /* empty */ - | T_VA_DCL - | declaration_list - ; - -declaration_list - : declaration - | declaration_list declaration - ; - -decl_specifiers - : decl_specifier - | decl_specifiers decl_specifier - { - join_decl_specs(&$$, &$1, &$2); - free($1.text); - free($2.text); - } - ; - -decl_specifier - : storage_class - | type_specifier - | type_qualifier - ; - -storage_class - : T_AUTO - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_EXTERN - { - new_decl_spec(&$$, $1.text, $1.begin, DS_EXTERN); - } - | T_REGISTER - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_STATIC - { - new_decl_spec(&$$, $1.text, $1.begin, DS_STATIC); - } - | T_INLINE - { - new_decl_spec(&$$, $1.text, $1.begin, DS_INLINE); - } - | T_EXTENSION - { - new_decl_spec(&$$, $1.text, $1.begin, DS_JUNK); - } - ; - -type_specifier - : T_CHAR - { - new_decl_spec(&$$, $1.text, $1.begin, DS_CHAR); - } - | T_DOUBLE - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_FLOAT - { - new_decl_spec(&$$, $1.text, $1.begin, DS_FLOAT); - } - | T_INT - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_LONG - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_SHORT - { - new_decl_spec(&$$, $1.text, $1.begin, DS_SHORT); - } - | T_SIGNED - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_UNSIGNED - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_VOID - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_Bool - { - new_decl_spec(&$$, $1.text, $1.begin, DS_CHAR); - } - | T_Complex - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_Imaginary - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_TYPEDEF_NAME - { - Symbol *s; - s = find_symbol(typedef_names, $1.text); - if (s != NULL) - new_decl_spec(&$$, $1.text, $1.begin, s->flags); - } - | struct_or_union_specifier - | enum_specifier - ; - -type_qualifier - : T_TYPE_QUALIFIER - { - new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); - } - | T_DEFINE_NAME - { - /* This rule allows the nonterminal to scan #define - * names as if they were type modifiers. - */ - Symbol *s; - s = find_symbol(define_names, $1.text); - if (s != NULL) - new_decl_spec(&$$, $1.text, $1.begin, s->flags); - } - ; - -struct_or_union_specifier - : struct_or_union any_id braces - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, $1.text, TEXT_LEN, $2.text); - new_decl_spec(&$$, s, $1.begin, DS_NONE); - } - | struct_or_union braces - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, $1.text); - new_decl_spec(&$$, s, $1.begin, DS_NONE); - } - | struct_or_union any_id - { - (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, $1.text, TEXT_LEN, $2.text); - new_decl_spec(&$$, buf, $1.begin, DS_NONE); - } - ; - -struct_or_union - : T_STRUCT - { - imply_typedef($$.text); - } - | T_UNION - { - imply_typedef($$.text); - } - ; - -init_declarator_list - : init_declarator - { - new_decl_list(&$$, $1); - } - | init_declarator_list ',' init_declarator - { - add_decl_list(&$$, &$1, $3); - } - ; - -init_declarator - : declarator - { - if ($1->func_def != FUNC_NONE && func_params == NULL && - func_style == FUNC_TRADITIONAL && cur_file->convert) { - gen_func_declarator($1); - fputs(cur_text(), cur_file->tmp_file); - } - cur_declarator = $$; - } - | declarator '=' - { - if ($1->func_def != FUNC_NONE && func_params == NULL && - func_style == FUNC_TRADITIONAL && cur_file->convert) { - gen_func_declarator($1); - fputs(" =", cur_file->tmp_file); - } - } - T_INITIALIZER - ; - -enum_specifier - : enumeration any_id braces - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, $2.text); - new_decl_spec(&$$, s, $1.begin, DS_NONE); - } - | enumeration braces - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, $1.text); - new_decl_spec(&$$, s, $1.begin, DS_NONE); - } - | enumeration any_id - { - (void)sprintf(buf, "enum %.*s", TEXT_LEN, $2.text); - new_decl_spec(&$$, buf, $1.begin, DS_NONE); - } - ; - -enumeration - : T_ENUM - { - imply_typedef("enum"); - $$ = $1; - } - ; - -any_id - : T_IDENTIFIER - | T_TYPEDEF_NAME - ; - -declarator - : pointer direct_declarator - { - $$ = $2; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $1.text, TEXT_LEN, $$->text); - free($$->text); - $$->text = xstrdup(buf); - $$->begin = $1.begin; - $$->pointer = TRUE; - } - | direct_declarator - ; - -direct_declarator - : identifier_or_ref - { - $$ = new_declarator($1.text, $1.text, $1.begin); - } - | '(' declarator ')' - { - $$ = $2; - (void)sprintf(buf, "(%.*s)", TEXT_LEN, $$->text); - free($$->text); - $$->text = xstrdup(buf); - $$->begin = $1.begin; - } - | direct_declarator T_BRACKETS - { - $$ = $1; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $$->text, TEXT_LEN, $2.text); - free($$->text); - $$->text = xstrdup(buf); - } - | direct_declarator '(' parameter_type_list ')' - { - $$ = new_declarator("%s()", $1->name, $1->begin); - $$->params = $3; - $$->func_stack = $1; - $$->head = ($1->func_stack == NULL) ? $$ : $1->head; - $$->func_def = FUNC_ANSI; - } - | direct_declarator '(' opt_identifier_list ')' - { - $$ = new_declarator("%s()", $1->name, $1->begin); - $$->params = $3; - $$->func_stack = $1; - $$->head = ($1->func_stack == NULL) ? $$ : $1->head; - $$->func_def = FUNC_TRADITIONAL; - } - ; - -pointer - : '*' opt_type_qualifiers - { - (void)sprintf($$.text, "*%.*s", TEXT_LEN, $2.text); - $$.begin = $1.begin; - } - | '*' opt_type_qualifiers pointer - { - (void)sprintf($$.text, "*%.*s%.*s", TEXT_LEN, $2.text, TEXT_LEN, $3.text); - $$.begin = $1.begin; - } - ; - -opt_type_qualifiers - : /* empty */ - { - strcpy($$.text, ""); - $$.begin = 0L; - } - | type_qualifier_list - ; - -type_qualifier_list - : type_qualifier - { - (void)sprintf($$.text, "%s ", $1.text); - $$.begin = $1.begin; - free($1.text); - } - | type_qualifier_list type_qualifier - { - (void)sprintf($$.text, "%.*s%.*s ", TEXT_LEN, $1.text, TEXT_LEN, $2.text); - $$.begin = $1.begin; - free($2.text); - } - ; - -parameter_type_list - : parameter_list - | parameter_list ',' T_ELLIPSIS - { - add_ident_list(&$$, &$1, "..."); - } - ; - -parameter_list - : parameter_declaration - { - new_param_list(&$$, $1); - } - | parameter_list ',' parameter_declaration - { - add_param_list(&$$, &$1, $3); - } - ; - -parameter_declaration - : decl_specifiers declarator - { - check_untagged(&$1); - $$ = new_parameter(&$1, $2); - } - | decl_specifiers abs_declarator - { - check_untagged(&$1); - $$ = new_parameter(&$1, $2); - } - | decl_specifiers - { - check_untagged(&$1); - $$ = new_parameter(&$1, (Declarator *)0); - } - ; - -opt_identifier_list - : /* empty */ - { - new_ident_list(&$$); - } - | identifier_list - ; - -identifier_list - : any_id - { - new_ident_list(&$$); - add_ident_list(&$$, &$$, $1.text); - } - | identifier_list ',' any_id - { - add_ident_list(&$$, &$1, $3.text); - } - ; - -identifier_or_ref - : any_id - { - $$ = $1; - } - | '&' any_id - { -#if OPT_LINTLIBRARY - if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */ - $$ = $2; - } else -#endif - (void)sprintf($$.text, "&%.*s", TEXT_LEN, $2.text); - $$.begin = $1.begin; - } - ; - -abs_declarator - : pointer - { - $$ = new_declarator($1.text, "", $1.begin); - } - | pointer direct_abs_declarator - { - $$ = $2; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $1.text, TEXT_LEN, $$->text); - free($$->text); - $$->text = xstrdup(buf); - $$->begin = $1.begin; - } - | direct_abs_declarator - ; - -direct_abs_declarator - : '(' abs_declarator ')' - { - $$ = $2; - (void)sprintf(buf, "(%.*s)", TEXT_LEN, $$->text); - free($$->text); - $$->text = xstrdup(buf); - $$->begin = $1.begin; - } - | direct_abs_declarator T_BRACKETS - { - $$ = $1; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $$->text, TEXT_LEN, $2.text); - free($$->text); - $$->text = xstrdup(buf); - } - | T_BRACKETS - { - $$ = new_declarator($1.text, "", $1.begin); - } - | direct_abs_declarator '(' parameter_type_list ')' - { - $$ = new_declarator("%s()", "", $1->begin); - $$->params = $3; - $$->func_stack = $1; - $$->head = ($1->func_stack == NULL) ? $$ : $1->head; - $$->func_def = FUNC_ANSI; - } - | direct_abs_declarator '(' ')' - { - $$ = new_declarator("%s()", "", $1->begin); - $$->func_stack = $1; - $$->head = ($1->func_stack == NULL) ? $$ : $1->head; - $$->func_def = FUNC_ANSI; - } - | '(' parameter_type_list ')' - { - Declarator *d; - - d = new_declarator("", "", $1.begin); - $$ = new_declarator("%s()", "", $1.begin); - $$->params = $2; - $$->func_stack = d; - $$->head = $$; - $$->func_def = FUNC_ANSI; - } - | '(' ')' - { - Declarator *d; - - d = new_declarator("", "", $1.begin); - $$ = new_declarator("%s()", "", $1.begin); - $$->func_stack = d; - $$->head = $$; - $$->func_def = FUNC_ANSI; - } - ; - -%% - -/* 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 occurrences 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 diff --git a/test/inherit0.y b/test/inherit0.y deleted file mode 100644 index 3a90e45c867..00000000000 --- a/test/inherit0.y +++ /dev/null @@ -1,48 +0,0 @@ -%{ -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/test/inherit1.y b/test/inherit1.y deleted file mode 100644 index 9c7e876f056..00000000000 --- a/test/inherit1.y +++ /dev/null @@ -1,76 +0,0 @@ -%{ -#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/test/inherit2.y b/test/inherit2.y deleted file mode 100644 index e297d08cd85..00000000000 --- a/test/inherit2.y +++ /dev/null @@ -1,80 +0,0 @@ -%{ -#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/test/ok_syntax1.y b/test/ok_syntax1.y deleted file mode 100644 index a22f231ef60..00000000000 --- a/test/ok_syntax1.y +++ /dev/null @@ -1,155 +0,0 @@ -%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/test/pure_calc.y b/test/pure_calc.y deleted file mode 100644 index 3cd04332dcd..00000000000 --- a/test/pure_calc.y +++ /dev/null @@ -1,116 +0,0 @@ -%{ -# 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 - -%} - -%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 -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 ); -} diff --git a/test/pure_error.y b/test/pure_error.y deleted file mode 100644 index fe7a3c3094f..00000000000 --- a/test/pure_error.y +++ /dev/null @@ -1,41 +0,0 @@ -%{ - -#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 - -%} - -%% -S: error -%% - -#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); -} diff --git a/test/quote_calc.y b/test/quote_calc.y deleted file mode 100644 index 9304dd8a700..00000000000 --- a/test/quote_calc.y +++ /dev/null @@ -1,112 +0,0 @@ -%{ -# include -# include - -int regs[26]; -int base; - -int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token OP_ADD "ADD" -%token OP_SUB "SUB" -%token OP_MUL "MUL" -%token OP_DIV "DIV" -%token OP_MOD "MOD" -%token OP_AND "AND" - -%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 OP_ADD expr - { $$ = $1 + $3; } - | expr OP_SUB expr - { $$ = $1 - $3; } - | expr OP_MUL expr - { $$ = $1 * $3; } - | expr OP_DIV expr - { $$ = $1 / $3; } - | expr OP_MOD expr - { $$ = $1 % $3; } - | expr OP_AND expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | OP_SUB expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) { - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/quote_calc2.y b/test/quote_calc2.y deleted file mode 100644 index ab72a285fcb..00000000000 --- a/test/quote_calc2.y +++ /dev/null @@ -1,112 +0,0 @@ -%{ -# include -# include - -int regs[26]; -int base; - -int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token OP_ADD "ADD" -%token OP_SUB "SUB" -%token OP_MUL "MUL" -%token OP_DIV "DIV" -%token OP_MOD "MOD" -%token OP_AND "AND" - -%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 "ADD" expr - { $$ = $1 + $3; } - | expr "SUB" expr - { $$ = $1 - $3; } - | expr "MUL" expr - { $$ = $1 * $3; } - | expr "DIV" expr - { $$ = $1 / $3; } - | expr "MOD" expr - { $$ = $1 % $3; } - | expr "AND" expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | "SUB" expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) { - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/quote_calc3.y b/test/quote_calc3.y deleted file mode 100644 index 5feeb4a03ed..00000000000 --- a/test/quote_calc3.y +++ /dev/null @@ -1,112 +0,0 @@ -%{ -# include -# include - -int regs[26]; -int base; - -int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token OP_ADD "ADD-operator" -%token OP_SUB "SUB-operator" -%token OP_MUL "MUL-operator" -%token OP_DIV "DIV-operator" -%token OP_MOD "MOD-operator" -%token OP_AND "AND-operator" - -%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 OP_ADD expr - { $$ = $1 + $3; } - | expr OP_SUB expr - { $$ = $1 - $3; } - | expr OP_MUL expr - { $$ = $1 * $3; } - | expr OP_DIV expr - { $$ = $1 / $3; } - | expr OP_MOD expr - { $$ = $1 % $3; } - | expr OP_AND expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | OP_SUB expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) { - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/quote_calc4.y b/test/quote_calc4.y deleted file mode 100644 index 34b790e67f1..00000000000 --- a/test/quote_calc4.y +++ /dev/null @@ -1,112 +0,0 @@ -%{ -# include -# include - -int regs[26]; -int base; - -int yylex(void); -static void yyerror(const char *s); - -%} - -%start list - -%token OP_ADD "ADD-operator" -%token OP_SUB "SUB-operator" -%token OP_MUL "MUL-operator" -%token OP_DIV "DIV-operator" -%token OP_MOD "MOD-operator" -%token OP_AND "AND-operator" - -%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 "ADD-operator" expr - { $$ = $1 + $3; } - | expr "SUB-operator" expr - { $$ = $1 - $3; } - | expr "MUL-operator" expr - { $$ = $1 * $3; } - | expr "DIV-operator" expr - { $$ = $1 / $3; } - | expr "MOD-operator" expr - { $$ = $1 % $3; } - | expr "AND-operator" expr - { $$ = $1 & $3; } - | expr '|' expr - { $$ = $1 | $3; } - | "SUB-operator" expr %prec UMINUS - { $$ = - $2; } - | LETTER - { $$ = regs[$1]; } - | number - ; - -number: DIGIT - { $$ = $1; base = ($1==0) ? 8 : 10; } - | number DIGIT - { $$ = base * $1 + $2; } - ; - -%% /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) { - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} diff --git a/test/run_lint.sh b/test/run_lint.sh deleted file mode 100755 index c6cedc23a01..00000000000 --- a/test/run_lint.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# $Id: run_lint.sh,v 1.5 2022/11/06 20:56:42 tom Exp $ -# vi:ts=4 sw=4: - -# run lint on each of the ".c" files in the test directory - -if test $# = 1 -then - PROG_DIR=`pwd` - TEST_DIR=$1 -else - PROG_DIR=.. - TEST_DIR=. -fi - -: "${FGREP:=grep -F}" -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 ${REF_DIR}/*.c -do - make -f $PROG_DIR/makefile lint C_FILES="$i" srcdir="$PROG_DIR" -done diff --git a/test/run_make.sh b/test/run_make.sh deleted file mode 100755 index a09e6034b31..00000000000 --- a/test/run_make.sh +++ /dev/null @@ -1,196 +0,0 @@ -#!/bin/sh -# $Id: run_make.sh,v 1.21 2022/11/06 20:57:33 tom Exp $ -# vi:ts=4 sw=4: - -# do a test-compile on each of the ".c" files in the test-directory - -BISON=`bison --version 2>/dev/null | head -n 1 | sed -e 's/^[^0-9.]*//' -e 's/[^0-9.]*$//'` - -if test $# = 1 -then - PROG_DIR=`pwd` - TEST_DIR=$1 -else - PROG_DIR=.. - TEST_DIR=. -fi -THIS_DIR=`pwd` - -: "${FGREP:=grep -F}" -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 - RETEST=`unset CDPATH; cd $TEST_DIR; pwd` - cd "$REF_DIR" - test -f "$I_FILE" && rm "$I_FILE" - make -f "$PROG_DIR/makefile" EXTRA_CFLAGS=-I$RETEST srcdir="$PROG_DIR" "$O_FILE" "$@" - test -f "$O_FILE" && rm "$O_FILE" - cd "$THIS_DIR" -} - -echo "** `date`" -echo "** program is in $PROG_DIR" -echo "** test-files in $REF_DIR" - -for input in ${REF_DIR}/*.c -do - case $input in #(vi - ${REF_DIR}/err_*|\ - ${REF_DIR}/test-err_*) - continue - ;; - esac - - test -f "$input" || continue - - run_make "$input" - - DEFS= - case $input in #(vi - ${REF_DIR}/pure_*) - # DEFS="-DYYLEX_PARAM=flag -DYYLEX_PARAM_TYPE=int" - ;; - esac - - if test "x$DEFS" != "x" - then - run_make "$input" DEFINES="$DEFS" - fi -done - -if test -n "$BISON" -then - echo "** compare with bison $BISON" - for input in ${TEST_DIR}/*.y - do - test -f "$input" || continue - case $input in - ${TEST_DIR}/err_*|\ - ${TEST_DIR}/test-err_*) - continue - ;; - ${TEST_DIR}/ok_syntax*|\ - ${TEST_DIR}/varsyntax*) - # Bison does not support all byacc legacy syntax - continue - ;; - ${TEST_DIR}/btyacc_*) - # Bison does not support the btyacc []-action & inherited attribute extensions. - continue - ;; - esac - - # Bison does not support pure-parser from command-line. - # Also, its support for %expect is generally broken. - # Work around these issues using a temporary file. - - echo "... testing $input" - rm -f run_make.[coy] - - case $input in - ${TEST_DIR}/pure_*) - if test -z "`$FGREP -i -l '%pure-parser' "$input"`" - then - echo "%pure-parser" >>run_make.y - fi - ;; - esac - - sed -e '/^%expect/s,%expect.*,,' "$input" >>run_make.y - - case $BISON in - [3-9].[0-9]*.[0-9]*) - bison -Wno-other -Wno-conflicts-sr -Wconflicts-rr -y -Wno-yacc run_make.y - ;; - *) - bison -y run_make.y - ;; - esac - if test -f "y.tab.c" - then - sed -e '/^#line/s,"run_make.y","'"$input"'",' y.tab.c >run_make.c - - 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" - fi - fi - rm -f run_make.[coy] - done -fi - -YACC= -for name in /usr/ccs/bin/yacc -do - if test -f $name - then - YACC=$name - fi -done - -if test -n "$YACC" -then - echo "** compare with $YACC" - for input in ${TEST_DIR}/*.y - do - test -f "$input" || continue - - echo "... testing $input" - rm -f run_make.[coy] - - case $input in - pure_*) - echo "... skipping $input" - continue; - ;; - *) - if $FGREP -i '%pure-parser' "$input" >/dev/null || - $FGREP -i '%parse-param' "$input" >/dev/null || - $FGREP -i '%lex-param' "$input" >/dev/null || - $FGREP -i '%token-table' "$input" >/dev/null || - $FGREP 'YYLEX_PARAM' "$input" >/dev/null - then - echo "... skipping $input" - continue; - fi - ;; - esac - - sed -e '/^%expect/s,%expect.*,,' "$input" >>run_make.y - - $YACC run_make.y - 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 - - 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 -fi diff --git a/test/run_test.sh b/test/run_test.sh deleted file mode 100755 index def26e3c6b7..00000000000 --- a/test/run_test.sh +++ /dev/null @@ -1,311 +0,0 @@ -#!/bin/sh -# $Id: run_test.sh,v 1.37 2022/11/06 21:55:25 tom Exp $ -# vi:ts=4 sw=4: - -errors=0 - -# 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" - errors=1 - else - sed -e "s,$NEW,$REF," \ - -e "s%$YACC_escaped%YACC%" \ - -e "s%^yacc\>%YACC%" \ - -e "s%YACC:.*option.*$%YACC: error message%" \ - -e "s%yacc:.*option.*$%YACC: error message%" \ - -e "s%^Usage: yacc\>%Usage: YACC%" \ - -e '/YYPATCH/s/[0-9][0-9]*/"yyyymmdd"/' \ - -e '/#define YYPATCH/s/PATCH/CHECK/' \ - -e 's,#line \([1-9][0-9]*\) "'"$REF_DIR"'/,#line \1 ",' \ - -e 's,#line \([1-9][0-9]*\) "'"$TEST_DIR"'/,#line \1 ",' \ - -e 's/^typedef \(short\|long\) YYINT;$/typedef int YYINT;/' \ - -e 's,\(YACC:.* line [0-9][0-9]* of "\)'"$TEST_DIR/"',\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 -c "$REF" "$CMP" - errors=1 - fi - fi -} - -test_flags() { - echo "** testing flags $*" - root=$1 - ROOT=test-$root - shift 1 - $YACC "$@" >"$ROOT.output" 2>"$ROOT.error" - for type in .output .error - do - NEW=$ROOT$type - REF=$REF_DIR/$root$type - test_diffs - done -} - -test_stdin() { - echo "** testing stdin $*" - root=$1 - ROOT=test-$root - shift 1 - opts="$1" - shift 1 - code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"` - if test "x$opts" = "x-" - then - $YACC -o "$ROOT.$code" $opts <$1 >"$ROOT.output" 2>"$ROOT.error" - else - $YACC -o "$ROOT.$code" $opts $1 >"$ROOT.output" 2>"$ROOT.error" - fi - for type in .output .error .$code - do - NEW=$ROOT$type - REF=$REF_DIR/$root$type - test_diffs - done -} - -test_defines() { - echo "** testing defines $*" - root=$1 - ROOT=test-$root - shift 1 - opts= - while test $# != 1 - do - opts="$opts $1" - shift 1 - done - head=`echo "$1"|sed -e 's/y$/h/' -e "s,${TEST_DIR}/,,"` - code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"` - $YACC $opts -H "$ROOT.$head" $1 >"$ROOT.output" 2>"$ROOT.error" - for name in prefix.tab.c y.tab.c - do - if test -f $name - then - mv "$name" "$ROOT.$code" - break - fi - done - for name in .output .error .$head .$code - do - NEW=$ROOT$name - REF=$REF_DIR/$root$name - test_diffs - done -} - -if test $# = 1 -then - PROG_DIR=`pwd` - 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=. -fi - -YACC=$PROG_DIR/yacc -YACC_escaped=`echo "$PROG_DIR/yacc" | sed -e 's/\./\\\./g'` - -tmpfile=temp$$ - -: "${FGREP:=grep -F}" -ifBTYACC=`$FGREP -l 'define YYBTYACC' $PROG_DIR/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.* - -# Test special cases -test_stdin stdin1 - ${TEST_DIR}/calc.y -test_stdin stdin2 -- ${TEST_DIR}/calc.y - -test_defines defines1 ${TEST_DIR}/calc.y -test_defines defines2 -d ${TEST_DIR}/calc.y -test_defines defines3 -b prefix ${TEST_DIR}/calc.y - -for input in "${TEST_DIR}"/*.y -do - case $input in - test-*) - echo "?? ignored $input" - ;; - *) - root=`basename "$input" .y` - ROOT="test-$root" - prefix=`echo "${root}_" | sed -e 's/[.]/_/g'` - - OPTS= - OPT2= - 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" - prefix=`echo "$prefix" | sed -e 's/^code_//'` - ;; - ${TEST_DIR}/pure_*) - OPTS="$OPTS -P" - prefix=`echo "$prefix" | sed -e 's/^pure_//'` - ;; - ${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 - 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=${REF_DIR}/${root}${opt2}${type} - - # handle renaming due to "-o" option - if test -n "$OOPT" - then - 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 - NEW="${ROOT}${opt2}${type}" - fi - test_diffs - done - done - ;; - esac -done - -exit $errors diff --git a/test/varsyntax_calc1.y b/test/varsyntax_calc1.y deleted file mode 100644 index c9917e0b49f..00000000000 --- a/test/varsyntax_calc1.y +++ /dev/null @@ -1,307 +0,0 @@ -%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/test/yacc/big_b.error b/test/yacc/big_b.error deleted file mode 100644 index 6c3442bef99..00000000000 --- a/test/yacc/big_b.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: w - -B flag unsupported, reconfigure with --enable-btyacc -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/yacc/big_b.output b/test/yacc/big_b.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/big_l.error b/test/yacc/big_l.error deleted file mode 100644 index 8ca42217c68..00000000000 --- a/test/yacc/big_l.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: w - -L flag unsupported, reconfigure with --enable-btyacc -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/yacc/big_l.output b/test/yacc/big_l.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc.error b/test/yacc/calc.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc.output b/test/yacc/calc.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/calc.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/calc.tab.c b/test/yacc/calc.tab.c deleted file mode 100644 index 22f387c2f09..00000000000 --- a/test/yacc/calc.tab.c +++ /dev/null @@ -1,686 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto calc_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_rule -#endif /* yyrule */ -#define YYPREFIX "calc_" - -#define YYPURE 0 - -#line 2 "calc.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 111 "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 int 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_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, -}; -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-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const calc_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 356 "calc.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 558 "calc.tab.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 563 "calc.tab.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 568 "calc.tab.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 573 "calc.tab.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 578 "calc.tab.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 583 "calc.tab.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 588 "calc.tab.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 593 "calc.tab.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 598 "calc.tab.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 603 "calc.tab.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 608 "calc.tab.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 613 "calc.tab.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 618 "calc.tab.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 623 "calc.tab.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 628 "calc.tab.c" -break; -#line 630 "calc.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc.tab.h b/test/yacc/calc.tab.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/calc.tab.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/calc1.error b/test/yacc/calc1.error deleted file mode 100644 index 9c1f7152c30..00000000000 --- a/test/yacc/calc1.error +++ /dev/null @@ -1,2 +0,0 @@ -YACC: 2 rules never reduced -YACC: 18 shift/reduce conflicts, 26 reduce/reduce conflicts. diff --git a/test/yacc/calc1.output b/test/yacc/calc1.output deleted file mode 100644 index 2b628d47ddb..00000000000 --- a/test/yacc/calc1.output +++ /dev/null @@ -1,877 +0,0 @@ - 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/test/yacc/calc1.tab.c b/test/yacc/calc1.tab.c deleted file mode 100644 index 3f704400d84..00000000000 --- a/test/yacc/calc1.tab.c +++ /dev/null @@ -1,936 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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]; - -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 31 "calc1.y" -typedef union YYSTYPE -{ - int ival; - double dval; - INTERVAL vval; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -#line 141 "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 int 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_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, -}; -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-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 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 493 "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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 57 "calc1.y" - { - (void) printf("%15.8f\n", yystack.l_mark[-1].dval); - } -#line 697 "calc1.tab.c" -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); - } -#line 704 "calc1.tab.c" -break; -case 5: -#line 65 "calc1.y" - { - dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; - } -#line 711 "calc1.tab.c" -break; -case 6: -#line 69 "calc1.y" - { - vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; - } -#line 718 "calc1.tab.c" -break; -case 7: -#line 73 "calc1.y" - { - yyerrok; - } -#line 725 "calc1.tab.c" -break; -case 9: -#line 80 "calc1.y" - { - yyval.dval = dreg[yystack.l_mark[0].ival]; - } -#line 732 "calc1.tab.c" -break; -case 10: -#line 84 "calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; - } -#line 739 "calc1.tab.c" -break; -case 11: -#line 88 "calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; - } -#line 746 "calc1.tab.c" -break; -case 12: -#line 92 "calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; - } -#line 753 "calc1.tab.c" -break; -case 13: -#line 96 "calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; - } -#line 760 "calc1.tab.c" -break; -case 14: -#line 100 "calc1.y" - { - yyval.dval = -yystack.l_mark[0].dval; - } -#line 767 "calc1.tab.c" -break; -case 15: -#line 104 "calc1.y" - { - yyval.dval = yystack.l_mark[-1].dval; - } -#line 774 "calc1.tab.c" -break; -case 16: -#line 110 "calc1.y" - { - yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; - } -#line 781 "calc1.tab.c" -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; - } - } -#line 794 "calc1.tab.c" -break; -case 18: -#line 124 "calc1.y" - { - yyval.vval = vreg[yystack.l_mark[0].ival]; - } -#line 801 "calc1.tab.c" -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; - } -#line 809 "calc1.tab.c" -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; - } -#line 817 "calc1.tab.c" -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; - } -#line 825 "calc1.tab.c" -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; - } -#line 833 "calc1.tab.c" -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 ); - } -#line 840 "calc1.tab.c" -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 ); - } -#line 847 "calc1.tab.c" -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 ); - } -#line 855 "calc1.tab.c" -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 ); - } -#line 863 "calc1.tab.c" -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; - } -#line 871 "calc1.tab.c" -break; -case 28: -#line 171 "calc1.y" - { - yyval.vval = yystack.l_mark[-1].vval; - } -#line 878 "calc1.tab.c" -break; -#line 880 "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) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc1.tab.h b/test/yacc/calc1.tab.h deleted file mode 100644 index dd493d013c2..00000000000 --- a/test/yacc/calc1.tab.h +++ /dev/null @@ -1,18 +0,0 @@ -#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 YYSTYPE -{ - int ival; - double dval; - INTERVAL vval; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE calc1_lval; diff --git a/test/yacc/calc2.error b/test/yacc/calc2.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc2.output b/test/yacc/calc2.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/calc2.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/calc2.tab.c b/test/yacc/calc2.tab.c deleted file mode 100644 index 62202c424b1..00000000000 --- a/test/yacc/calc2.tab.c +++ /dev/null @@ -1,699 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 113 "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 int 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_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, -}; -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-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 369 "calc2.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "calc2.y" - { yyerrok ; } -#line 571 "calc2.tab.c" -break; -case 4: -#line 39 "calc2.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 576 "calc2.tab.c" -break; -case 5: -#line 41 "calc2.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 581 "calc2.tab.c" -break; -case 6: -#line 45 "calc2.y" - { yyval = yystack.l_mark[-1]; } -#line 586 "calc2.tab.c" -break; -case 7: -#line 47 "calc2.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 591 "calc2.tab.c" -break; -case 8: -#line 49 "calc2.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 596 "calc2.tab.c" -break; -case 9: -#line 51 "calc2.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 601 "calc2.tab.c" -break; -case 10: -#line 53 "calc2.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 606 "calc2.tab.c" -break; -case 11: -#line 55 "calc2.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 611 "calc2.tab.c" -break; -case 12: -#line 57 "calc2.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 616 "calc2.tab.c" -break; -case 13: -#line 59 "calc2.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 621 "calc2.tab.c" -break; -case 14: -#line 61 "calc2.y" - { yyval = - yystack.l_mark[0]; } -#line 626 "calc2.tab.c" -break; -case 15: -#line 63 "calc2.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 631 "calc2.tab.c" -break; -case 17: -#line 68 "calc2.y" - { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 636 "calc2.tab.c" -break; -case 18: -#line 70 "calc2.y" - { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 641 "calc2.tab.c" -break; -#line 643 "calc2.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc2.tab.h b/test/yacc/calc2.tab.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/calc2.tab.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/calc3.error b/test/yacc/calc3.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc3.output b/test/yacc/calc3.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/calc3.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/calc3.tab.c b/test/yacc/calc3.tab.c deleted file mode 100644 index eb487785e56..00000000000 --- a/test/yacc/calc3.tab.c +++ /dev/null @@ -1,707 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 114 "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 int 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_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, -}; -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-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const 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 - -#if YYDEBUG -int yydebug; -#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 - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -#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 366 "calc3.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; - int yynerrs; - - /* 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 - - memset(&yyval, 0, sizeof(yyval)); - memset(&yylval, 0, sizeof(yylval)); - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 38 "calc3.y" - { yyerrok ; } -#line 579 "calc3.tab.c" -break; -case 4: -#line 42 "calc3.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 584 "calc3.tab.c" -break; -case 5: -#line 44 "calc3.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 589 "calc3.tab.c" -break; -case 6: -#line 48 "calc3.y" - { yyval = yystack.l_mark[-1]; } -#line 594 "calc3.tab.c" -break; -case 7: -#line 50 "calc3.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 599 "calc3.tab.c" -break; -case 8: -#line 52 "calc3.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 604 "calc3.tab.c" -break; -case 9: -#line 54 "calc3.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 609 "calc3.tab.c" -break; -case 10: -#line 56 "calc3.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 614 "calc3.tab.c" -break; -case 11: -#line 58 "calc3.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 619 "calc3.tab.c" -break; -case 12: -#line 60 "calc3.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 624 "calc3.tab.c" -break; -case 13: -#line 62 "calc3.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 629 "calc3.tab.c" -break; -case 14: -#line 64 "calc3.y" - { yyval = - yystack.l_mark[0]; } -#line 634 "calc3.tab.c" -break; -case 15: -#line 66 "calc3.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 639 "calc3.tab.c" -break; -case 17: -#line 71 "calc3.y" - { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 644 "calc3.tab.c" -break; -case 18: -#line 73 "calc3.y" - { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 649 "calc3.tab.c" -break; -#line 651 "calc3.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc3.tab.h b/test/yacc/calc3.tab.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/calc3.tab.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/calc_code_all.error b/test/yacc/calc_code_all.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc_code_all.output b/test/yacc/calc_code_all.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/calc_code_all.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/calc_code_all.tab.c b/test/yacc/calc_code_all.tab.c deleted file mode 100644 index 423189b7025..00000000000 --- a/test/yacc/calc_code_all.tab.c +++ /dev/null @@ -1,714 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 - -/* %code "top" block start */ -#line 5 "calc_code_all.y" -/* CODE-TOP */ -/* %code "top" block end */ -#line 22 "calc_code_all.tab.c" - -#ifndef yyparse -#define yyparse calc_code_all_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_all_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_all_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_all_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_all_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_all_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_all_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_all_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_all_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_all_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_all_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_all_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto calc_code_all_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_all_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_all_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_all_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_all_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_all_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_all_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_all_rule -#endif /* yyrule */ -#define YYPREFIX "calc_code_all_" - -#define YYPURE 0 - -#line 9 "calc_code_all.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 117 "calc_code_all.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_all_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_all_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_all_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT calc_code_all_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_all_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_all_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT calc_code_all_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_all_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_all_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_all_name[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const calc_code_all_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* %code "requires" block start */ -#line 3 "calc_code_all.y" -/* CODE-REQUIRES */ -/* %code "requires" block end */ -#line 299 "calc_code_all.tab.c" - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; - -/* %code "provides" block start */ -#line 4 "calc_code_all.y" -/* CODE-PROVIDES */ -#line 6 "calc_code_all.y" -/* CODE-PROVIDES2 */ -/* %code "provides" block end */ -#line 333 "calc_code_all.tab.c" - -/* %code "" block start */ -#line 1 "calc_code_all.y" -/* CODE-DEFAULT2 */ -#line 2 "calc_code_all.y" -/* CODE-DEFAULT */ -/* %code "" block end */ -#line 341 "calc_code_all.tab.c" -#line 73 "calc_code_all.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 384 "calc_code_all.tab.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "calc_code_all.y" - { yyerrok ; } -#line 586 "calc_code_all.tab.c" -break; -case 4: -#line 39 "calc_code_all.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 591 "calc_code_all.tab.c" -break; -case 5: -#line 41 "calc_code_all.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 596 "calc_code_all.tab.c" -break; -case 6: -#line 45 "calc_code_all.y" - { yyval = yystack.l_mark[-1]; } -#line 601 "calc_code_all.tab.c" -break; -case 7: -#line 47 "calc_code_all.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 606 "calc_code_all.tab.c" -break; -case 8: -#line 49 "calc_code_all.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 611 "calc_code_all.tab.c" -break; -case 9: -#line 51 "calc_code_all.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 616 "calc_code_all.tab.c" -break; -case 10: -#line 53 "calc_code_all.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 621 "calc_code_all.tab.c" -break; -case 11: -#line 55 "calc_code_all.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 626 "calc_code_all.tab.c" -break; -case 12: -#line 57 "calc_code_all.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 631 "calc_code_all.tab.c" -break; -case 13: -#line 59 "calc_code_all.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 636 "calc_code_all.tab.c" -break; -case 14: -#line 61 "calc_code_all.y" - { yyval = - yystack.l_mark[0]; } -#line 641 "calc_code_all.tab.c" -break; -case 15: -#line 63 "calc_code_all.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 646 "calc_code_all.tab.c" -break; -case 17: -#line 68 "calc_code_all.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 651 "calc_code_all.tab.c" -break; -case 18: -#line 70 "calc_code_all.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 656 "calc_code_all.tab.c" -break; -#line 658 "calc_code_all.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc_code_all.tab.h b/test/yacc/calc_code_all.tab.h deleted file mode 100644 index 7edd87c3e6c..00000000000 --- a/test/yacc/calc_code_all.tab.h +++ /dev/null @@ -1,13 +0,0 @@ -/* %code "requires" block start */ -#line 3 "calc_code_all.y" -/* CODE-REQUIRES */ -/* %code "requires" block end */ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -/* %code "provides" block start */ -#line 4 "calc_code_all.y" -/* CODE-PROVIDES */ -#line 6 "calc_code_all.y" -/* CODE-PROVIDES2 */ -/* %code "provides" block end */ diff --git a/test/yacc/calc_code_default.error b/test/yacc/calc_code_default.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc_code_default.output b/test/yacc/calc_code_default.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/calc_code_default.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/calc_code_default.tab.c b/test/yacc/calc_code_default.tab.c deleted file mode 100644 index cf4e7e65261..00000000000 --- a/test/yacc/calc_code_default.tab.c +++ /dev/null @@ -1,694 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 - -#ifndef yyparse -#define yyparse calc_code_default_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_default_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_default_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_default_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_default_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_default_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_default_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_default_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_default_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_default_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_default_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_default_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto calc_code_default_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_default_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_default_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_default_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_default_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_default_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_default_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_default_rule -#endif /* yyrule */ -#define YYPREFIX "calc_code_default_" - -#define YYPURE 0 - -#line 5 "calc_code_default.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 111 "calc_code_default.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_default_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_default_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_default_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT calc_code_default_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_default_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_default_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT calc_code_default_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_default_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_default_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_default_name[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const calc_code_default_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; - -/* %code "" block start */ -#line 1 "calc_code_default.y" -/* CODE-DEFAULT */ -#line 2 "calc_code_default.y" -/* CODE-DEFAULT2 */ -/* %code "" block end */ -#line 321 "calc_code_default.tab.c" -#line 69 "calc_code_default.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 364 "calc_code_default.tab.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 31 "calc_code_default.y" - { yyerrok ; } -#line 566 "calc_code_default.tab.c" -break; -case 4: -#line 35 "calc_code_default.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 571 "calc_code_default.tab.c" -break; -case 5: -#line 37 "calc_code_default.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 576 "calc_code_default.tab.c" -break; -case 6: -#line 41 "calc_code_default.y" - { yyval = yystack.l_mark[-1]; } -#line 581 "calc_code_default.tab.c" -break; -case 7: -#line 43 "calc_code_default.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 586 "calc_code_default.tab.c" -break; -case 8: -#line 45 "calc_code_default.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 591 "calc_code_default.tab.c" -break; -case 9: -#line 47 "calc_code_default.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 596 "calc_code_default.tab.c" -break; -case 10: -#line 49 "calc_code_default.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 601 "calc_code_default.tab.c" -break; -case 11: -#line 51 "calc_code_default.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 606 "calc_code_default.tab.c" -break; -case 12: -#line 53 "calc_code_default.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 611 "calc_code_default.tab.c" -break; -case 13: -#line 55 "calc_code_default.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 616 "calc_code_default.tab.c" -break; -case 14: -#line 57 "calc_code_default.y" - { yyval = - yystack.l_mark[0]; } -#line 621 "calc_code_default.tab.c" -break; -case 15: -#line 59 "calc_code_default.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 626 "calc_code_default.tab.c" -break; -case 17: -#line 64 "calc_code_default.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 631 "calc_code_default.tab.c" -break; -case 18: -#line 66 "calc_code_default.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 636 "calc_code_default.tab.c" -break; -#line 638 "calc_code_default.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc_code_default.tab.h b/test/yacc/calc_code_default.tab.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/calc_code_default.tab.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/calc_code_imports.error b/test/yacc/calc_code_imports.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc_code_imports.output b/test/yacc/calc_code_imports.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/calc_code_imports.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/calc_code_imports.tab.c b/test/yacc/calc_code_imports.tab.c deleted file mode 100644 index ddd89c35969..00000000000 --- a/test/yacc/calc_code_imports.tab.c +++ /dev/null @@ -1,686 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 - -#ifndef yyparse -#define yyparse calc_code_imports_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_imports_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_imports_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_imports_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_imports_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_imports_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_imports_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_imports_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_imports_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_imports_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_imports_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_imports_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto calc_code_imports_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_imports_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_imports_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_imports_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_imports_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_imports_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_imports_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_imports_rule -#endif /* yyrule */ -#define YYPREFIX "calc_code_imports_" - -#define YYPURE 0 - -#line 5 "calc_code_imports.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 111 "calc_code_imports.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_imports_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_imports_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_imports_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT calc_code_imports_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_imports_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_imports_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT calc_code_imports_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_imports_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_imports_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_imports_name[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const calc_code_imports_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 69 "calc_code_imports.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 356 "calc_code_imports.tab.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 31 "calc_code_imports.y" - { yyerrok ; } -#line 558 "calc_code_imports.tab.c" -break; -case 4: -#line 35 "calc_code_imports.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 563 "calc_code_imports.tab.c" -break; -case 5: -#line 37 "calc_code_imports.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 568 "calc_code_imports.tab.c" -break; -case 6: -#line 41 "calc_code_imports.y" - { yyval = yystack.l_mark[-1]; } -#line 573 "calc_code_imports.tab.c" -break; -case 7: -#line 43 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 578 "calc_code_imports.tab.c" -break; -case 8: -#line 45 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 583 "calc_code_imports.tab.c" -break; -case 9: -#line 47 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 588 "calc_code_imports.tab.c" -break; -case 10: -#line 49 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 593 "calc_code_imports.tab.c" -break; -case 11: -#line 51 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 598 "calc_code_imports.tab.c" -break; -case 12: -#line 53 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 603 "calc_code_imports.tab.c" -break; -case 13: -#line 55 "calc_code_imports.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 608 "calc_code_imports.tab.c" -break; -case 14: -#line 57 "calc_code_imports.y" - { yyval = - yystack.l_mark[0]; } -#line 613 "calc_code_imports.tab.c" -break; -case 15: -#line 59 "calc_code_imports.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 618 "calc_code_imports.tab.c" -break; -case 17: -#line 64 "calc_code_imports.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 623 "calc_code_imports.tab.c" -break; -case 18: -#line 66 "calc_code_imports.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 628 "calc_code_imports.tab.c" -break; -#line 630 "calc_code_imports.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc_code_imports.tab.h b/test/yacc/calc_code_imports.tab.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/calc_code_imports.tab.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/calc_code_provides.error b/test/yacc/calc_code_provides.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc_code_provides.output b/test/yacc/calc_code_provides.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/calc_code_provides.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/calc_code_provides.tab.c b/test/yacc/calc_code_provides.tab.c deleted file mode 100644 index 46f68e4b039..00000000000 --- a/test/yacc/calc_code_provides.tab.c +++ /dev/null @@ -1,694 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 - -#ifndef yyparse -#define yyparse calc_code_provides_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_provides_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_provides_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_provides_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_provides_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_provides_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_provides_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_provides_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_provides_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_provides_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_provides_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_provides_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto calc_code_provides_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_provides_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_provides_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_provides_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_provides_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_provides_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_provides_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_provides_rule -#endif /* yyrule */ -#define YYPREFIX "calc_code_provides_" - -#define YYPURE 0 - -#line 5 "calc_code_provides.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 111 "calc_code_provides.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_provides_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_provides_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_provides_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT calc_code_provides_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_provides_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_provides_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT calc_code_provides_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_provides_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_provides_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_provides_name[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const calc_code_provides_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; - -/* %code "provides" block start */ -#line 1 "calc_code_provides.y" -/* CODE-PROVIDES */ -#line 2 "calc_code_provides.y" -/* CODE-PROVIDES2 */ -/* %code "provides" block end */ -#line 321 "calc_code_provides.tab.c" -#line 69 "calc_code_provides.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 364 "calc_code_provides.tab.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 31 "calc_code_provides.y" - { yyerrok ; } -#line 566 "calc_code_provides.tab.c" -break; -case 4: -#line 35 "calc_code_provides.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 571 "calc_code_provides.tab.c" -break; -case 5: -#line 37 "calc_code_provides.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 576 "calc_code_provides.tab.c" -break; -case 6: -#line 41 "calc_code_provides.y" - { yyval = yystack.l_mark[-1]; } -#line 581 "calc_code_provides.tab.c" -break; -case 7: -#line 43 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 586 "calc_code_provides.tab.c" -break; -case 8: -#line 45 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 591 "calc_code_provides.tab.c" -break; -case 9: -#line 47 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 596 "calc_code_provides.tab.c" -break; -case 10: -#line 49 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 601 "calc_code_provides.tab.c" -break; -case 11: -#line 51 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 606 "calc_code_provides.tab.c" -break; -case 12: -#line 53 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 611 "calc_code_provides.tab.c" -break; -case 13: -#line 55 "calc_code_provides.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 616 "calc_code_provides.tab.c" -break; -case 14: -#line 57 "calc_code_provides.y" - { yyval = - yystack.l_mark[0]; } -#line 621 "calc_code_provides.tab.c" -break; -case 15: -#line 59 "calc_code_provides.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 626 "calc_code_provides.tab.c" -break; -case 17: -#line 64 "calc_code_provides.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 631 "calc_code_provides.tab.c" -break; -case 18: -#line 66 "calc_code_provides.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 636 "calc_code_provides.tab.c" -break; -#line 638 "calc_code_provides.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc_code_provides.tab.h b/test/yacc/calc_code_provides.tab.h deleted file mode 100644 index a7004790d1f..00000000000 --- a/test/yacc/calc_code_provides.tab.h +++ /dev/null @@ -1,9 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -/* %code "provides" block start */ -#line 1 "calc_code_provides.y" -/* CODE-PROVIDES */ -#line 2 "calc_code_provides.y" -/* CODE-PROVIDES2 */ -/* %code "provides" block end */ diff --git a/test/yacc/calc_code_requires.error b/test/yacc/calc_code_requires.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc_code_requires.output b/test/yacc/calc_code_requires.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/calc_code_requires.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/calc_code_requires.tab.c b/test/yacc/calc_code_requires.tab.c deleted file mode 100644 index e409d37e40c..00000000000 --- a/test/yacc/calc_code_requires.tab.c +++ /dev/null @@ -1,694 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 - -#ifndef yyparse -#define yyparse calc_code_requires_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_requires_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_requires_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_requires_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_requires_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_requires_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_requires_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_requires_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_requires_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_requires_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_requires_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_requires_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto calc_code_requires_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_requires_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_requires_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_requires_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_requires_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_requires_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_requires_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_requires_rule -#endif /* yyrule */ -#define YYPREFIX "calc_code_requires_" - -#define YYPURE 0 - -#line 5 "calc_code_requires.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 111 "calc_code_requires.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_requires_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_requires_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_requires_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT calc_code_requires_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_requires_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_requires_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT calc_code_requires_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_requires_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_requires_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_requires_name[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const calc_code_requires_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* %code "requires" block start */ -#line 1 "calc_code_requires.y" -/* CODE-REQUIRES */ -#line 2 "calc_code_requires.y" -/* CODE-REQUIRES2 */ -/* %code "requires" block end */ -#line 295 "calc_code_requires.tab.c" - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 69 "calc_code_requires.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 364 "calc_code_requires.tab.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 31 "calc_code_requires.y" - { yyerrok ; } -#line 566 "calc_code_requires.tab.c" -break; -case 4: -#line 35 "calc_code_requires.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 571 "calc_code_requires.tab.c" -break; -case 5: -#line 37 "calc_code_requires.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 576 "calc_code_requires.tab.c" -break; -case 6: -#line 41 "calc_code_requires.y" - { yyval = yystack.l_mark[-1]; } -#line 581 "calc_code_requires.tab.c" -break; -case 7: -#line 43 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 586 "calc_code_requires.tab.c" -break; -case 8: -#line 45 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 591 "calc_code_requires.tab.c" -break; -case 9: -#line 47 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 596 "calc_code_requires.tab.c" -break; -case 10: -#line 49 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 601 "calc_code_requires.tab.c" -break; -case 11: -#line 51 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 606 "calc_code_requires.tab.c" -break; -case 12: -#line 53 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 611 "calc_code_requires.tab.c" -break; -case 13: -#line 55 "calc_code_requires.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 616 "calc_code_requires.tab.c" -break; -case 14: -#line 57 "calc_code_requires.y" - { yyval = - yystack.l_mark[0]; } -#line 621 "calc_code_requires.tab.c" -break; -case 15: -#line 59 "calc_code_requires.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 626 "calc_code_requires.tab.c" -break; -case 17: -#line 64 "calc_code_requires.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 631 "calc_code_requires.tab.c" -break; -case 18: -#line 66 "calc_code_requires.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 636 "calc_code_requires.tab.c" -break; -#line 638 "calc_code_requires.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc_code_requires.tab.h b/test/yacc/calc_code_requires.tab.h deleted file mode 100644 index b734c8358f5..00000000000 --- a/test/yacc/calc_code_requires.tab.h +++ /dev/null @@ -1,9 +0,0 @@ -/* %code "requires" block start */ -#line 1 "calc_code_requires.y" -/* CODE-REQUIRES */ -#line 2 "calc_code_requires.y" -/* CODE-REQUIRES2 */ -/* %code "requires" block end */ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/calc_code_top.error b/test/yacc/calc_code_top.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/calc_code_top.output b/test/yacc/calc_code_top.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/calc_code_top.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/calc_code_top.tab.c b/test/yacc/calc_code_top.tab.c deleted file mode 100644 index 1f47973f1ac..00000000000 --- a/test/yacc/calc_code_top.tab.c +++ /dev/null @@ -1,694 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 - -/* %code "top" block start */ -#line 1 "calc_code_top.y" -/* CODE-TOP */ -#line 2 "calc_code_top.y" -/* CODE-TOP2 */ -/* %code "top" block end */ -#line 24 "calc_code_top.tab.c" - -#ifndef yyparse -#define yyparse calc_code_top_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_code_top_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_code_top_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_code_top_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_code_top_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_code_top_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_code_top_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_code_top_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_code_top_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_code_top_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_code_top_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_code_top_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto calc_code_top_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_code_top_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_code_top_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_code_top_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_code_top_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_code_top_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_code_top_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_code_top_rule -#endif /* yyrule */ -#define YYPREFIX "calc_code_top_" - -#define YYPURE 0 - -#line 5 "calc_code_top.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 119 "calc_code_top.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT calc_code_top_lhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT calc_code_top_len[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT calc_code_top_defred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT calc_code_top_dgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT calc_code_top_sindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT calc_code_top_rindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT calc_code_top_gindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT calc_code_top_table[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT calc_code_top_check[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const calc_code_top_name[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const calc_code_top_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 69 "calc_code_top.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 364 "calc_code_top.tab.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 31 "calc_code_top.y" - { yyerrok ; } -#line 566 "calc_code_top.tab.c" -break; -case 4: -#line 35 "calc_code_top.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 571 "calc_code_top.tab.c" -break; -case 5: -#line 37 "calc_code_top.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 576 "calc_code_top.tab.c" -break; -case 6: -#line 41 "calc_code_top.y" - { yyval = yystack.l_mark[-1]; } -#line 581 "calc_code_top.tab.c" -break; -case 7: -#line 43 "calc_code_top.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 586 "calc_code_top.tab.c" -break; -case 8: -#line 45 "calc_code_top.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 591 "calc_code_top.tab.c" -break; -case 9: -#line 47 "calc_code_top.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 596 "calc_code_top.tab.c" -break; -case 10: -#line 49 "calc_code_top.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 601 "calc_code_top.tab.c" -break; -case 11: -#line 51 "calc_code_top.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 606 "calc_code_top.tab.c" -break; -case 12: -#line 53 "calc_code_top.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 611 "calc_code_top.tab.c" -break; -case 13: -#line 55 "calc_code_top.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 616 "calc_code_top.tab.c" -break; -case 14: -#line 57 "calc_code_top.y" - { yyval = - yystack.l_mark[0]; } -#line 621 "calc_code_top.tab.c" -break; -case 15: -#line 59 "calc_code_top.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 626 "calc_code_top.tab.c" -break; -case 17: -#line 64 "calc_code_top.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 631 "calc_code_top.tab.c" -break; -case 18: -#line 66 "calc_code_top.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 636 "calc_code_top.tab.c" -break; -#line 638 "calc_code_top.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/calc_code_top.tab.h b/test/yacc/calc_code_top.tab.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/calc_code_top.tab.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/code_calc.code.c b/test/yacc/code_calc.code.c deleted file mode 100644 index 608ff7fb4ad..00000000000 --- a/test/yacc/code_calc.code.c +++ /dev/null @@ -1,595 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto calc_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_rule -#endif /* yyrule */ -#define YYPREFIX "calc_" - -#define YYPURE 0 - -#line 4 "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 -#undef yytname -#define yytname yyname -#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 int 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 || defined(yytname) -extern char *yyname[]; -#endif -#if YYDEBUG -extern char *yyrule[]; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 70 "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 265 "code_calc.code.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 32 "code_calc.y" - { yyerrok ; } -#line 467 "code_calc.code.c" -break; -case 4: -#line 36 "code_calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 472 "code_calc.code.c" -break; -case 5: -#line 38 "code_calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 477 "code_calc.code.c" -break; -case 6: -#line 42 "code_calc.y" - { yyval = yystack.l_mark[-1]; } -#line 482 "code_calc.code.c" -break; -case 7: -#line 44 "code_calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 487 "code_calc.code.c" -break; -case 8: -#line 46 "code_calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 492 "code_calc.code.c" -break; -case 9: -#line 48 "code_calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 497 "code_calc.code.c" -break; -case 10: -#line 50 "code_calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 502 "code_calc.code.c" -break; -case 11: -#line 52 "code_calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 507 "code_calc.code.c" -break; -case 12: -#line 54 "code_calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 512 "code_calc.code.c" -break; -case 13: -#line 56 "code_calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 517 "code_calc.code.c" -break; -case 14: -#line 58 "code_calc.y" - { yyval = - yystack.l_mark[0]; } -#line 522 "code_calc.code.c" -break; -case 15: -#line 60 "code_calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 527 "code_calc.code.c" -break; -case 17: -#line 65 "code_calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 532 "code_calc.code.c" -break; -case 18: -#line 67 "code_calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 537 "code_calc.code.c" -break; -#line 539 "code_calc.code.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/code_calc.error b/test/yacc/code_calc.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/code_calc.output b/test/yacc/code_calc.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/code_calc.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/code_calc.tab.c b/test/yacc/code_calc.tab.c deleted file mode 100644 index 9242641a931..00000000000 --- a/test/yacc/code_calc.tab.c +++ /dev/null @@ -1,119 +0,0 @@ -typedef int 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_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, -}; -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 -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, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -#if YYDEBUG -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/test/yacc/code_calc.tab.h b/test/yacc/code_calc.tab.h deleted file mode 100644 index b0bcb16dc45..00000000000 --- a/test/yacc/code_calc.tab.h +++ /dev/null @@ -1,5 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#undef yytname -#define yytname yyname diff --git a/test/yacc/code_error.code.c b/test/yacc/code_error.code.c deleted file mode 100644 index ef2e78c00b5..00000000000 --- a/test/yacc/code_error.code.c +++ /dev/null @@ -1,489 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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_" - -#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(); -typedef int 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 || defined(yytname) -extern char *yyname[]; -#endif -#if YYDEBUG -extern char *yyrule[]; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 235 "code_error.code.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/code_error.error b/test/yacc/code_error.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/code_error.output b/test/yacc/code_error.output deleted file mode 100644 index 0c4db6225e2..00000000000 --- a/test/yacc/code_error.output +++ /dev/null @@ -1,27 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -2 terminals, 2 nonterminals -2 grammar rules, 3 states diff --git a/test/yacc/code_error.tab.c b/test/yacc/code_error.tab.c deleted file mode 100644 index d394ad80849..00000000000 --- a/test/yacc/code_error.tab.c +++ /dev/null @@ -1,44 +0,0 @@ -typedef int 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/test/yacc/code_error.tab.h b/test/yacc/code_error.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/defines1.calc.c b/test/yacc/defines1.calc.c deleted file mode 100644 index e5ebf355c00..00000000000 --- a/test/yacc/defines1.calc.c +++ /dev/null @@ -1,610 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "calc.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 31 "y.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 66 "calc.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 280 "y.tab.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 482 "y.tab.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 487 "y.tab.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 492 "y.tab.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 497 "y.tab.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 502 "y.tab.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 507 "y.tab.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 512 "y.tab.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 517 "y.tab.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 522 "y.tab.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 527 "y.tab.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 532 "y.tab.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 537 "y.tab.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 542 "y.tab.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 547 "y.tab.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 552 "y.tab.c" -break; -#line 554 "y.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/defines1.calc.h b/test/yacc/defines1.calc.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/defines1.calc.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/defines1.error b/test/yacc/defines1.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/defines1.output b/test/yacc/defines1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/defines2.calc.c b/test/yacc/defines2.calc.c deleted file mode 100644 index e5ebf355c00..00000000000 --- a/test/yacc/defines2.calc.c +++ /dev/null @@ -1,610 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "calc.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 31 "y.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 66 "calc.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 280 "y.tab.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 482 "y.tab.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 487 "y.tab.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 492 "y.tab.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 497 "y.tab.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 502 "y.tab.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 507 "y.tab.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 512 "y.tab.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 517 "y.tab.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 522 "y.tab.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 527 "y.tab.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 532 "y.tab.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 537 "y.tab.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 542 "y.tab.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 547 "y.tab.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 552 "y.tab.c" -break; -#line 554 "y.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/defines2.calc.h b/test/yacc/defines2.calc.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/defines2.calc.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/defines2.error b/test/yacc/defines2.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/defines2.output b/test/yacc/defines2.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/defines3.calc.c b/test/yacc/defines3.calc.c deleted file mode 100644 index 90bca1d7b36..00000000000 --- a/test/yacc/defines3.calc.c +++ /dev/null @@ -1,610 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "calc.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 31 "prefix.tab.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 66 "calc.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 280 "prefix.tab.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 482 "prefix.tab.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 487 "prefix.tab.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 492 "prefix.tab.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 497 "prefix.tab.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 502 "prefix.tab.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 507 "prefix.tab.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 512 "prefix.tab.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 517 "prefix.tab.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 522 "prefix.tab.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 527 "prefix.tab.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 532 "prefix.tab.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 537 "prefix.tab.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 542 "prefix.tab.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 547 "prefix.tab.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 552 "prefix.tab.c" -break; -#line 554 "prefix.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/defines3.calc.h b/test/yacc/defines3.calc.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/defines3.calc.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/defines3.error b/test/yacc/defines3.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/defines3.output b/test/yacc/defines3.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/empty.error b/test/yacc/empty.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/empty.output b/test/yacc/empty.output deleted file mode 100644 index b7cf396ef98..00000000000 --- a/test/yacc/empty.output +++ /dev/null @@ -1,21 +0,0 @@ - 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/test/yacc/empty.tab.c b/test/yacc/empty.tab.c deleted file mode 100644 index f2387a4218e..00000000000 --- a/test/yacc/empty.tab.c +++ /dev/null @@ -1,500 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 13 "empty.y" - -#include - -static int -YYLEX_DECL() { - return -1; -} - -static void -YYERROR_DECL() { - printf("%s\n",s); -} -#line 246 "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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/empty.tab.h b/test/yacc/empty.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax1.error b/test/yacc/err_syntax1.error deleted file mode 100644 index 5df5c22ef17..00000000000 --- a/test/yacc/err_syntax1.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 1 of "./err_syntax1.y", syntax error - ?% { - ^ diff --git a/test/yacc/err_syntax1.output b/test/yacc/err_syntax1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax1.tab.c b/test/yacc/err_syntax1.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax1.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax1.tab.h b/test/yacc/err_syntax1.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax10.error b/test/yacc/err_syntax10.error deleted file mode 100644 index 61a72c0408a..00000000000 --- a/test/yacc/err_syntax10.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: w - line 7 of "./err_syntax10.y", the type of '(' has been redeclared -YACC: w - line 7 of "./err_syntax10.y", the type of '*' has been redeclared -YACC: w - line 7 of "./err_syntax10.y", the type of '&' has been redeclared diff --git a/test/yacc/err_syntax10.output b/test/yacc/err_syntax10.output deleted file mode 100644 index 1b4542bde5c..00000000000 --- a/test/yacc/err_syntax10.output +++ /dev/null @@ -1,27 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -5 terminals, 2 nonterminals -2 grammar rules, 3 states diff --git a/test/yacc/err_syntax10.tab.c b/test/yacc/err_syntax10.tab.c deleted file mode 100644 index 2cf718c93de..00000000000 --- a/test/yacc/err_syntax10.tab.c +++ /dev/null @@ -1,499 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 245 "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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/err_syntax10.tab.h b/test/yacc/err_syntax10.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax11.error b/test/yacc/err_syntax11.error deleted file mode 100644 index b2dd79c5050..00000000000 --- a/test/yacc/err_syntax11.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - line 7 of "./err_syntax11.y", the precedence of '|' has been redeclared diff --git a/test/yacc/err_syntax11.output b/test/yacc/err_syntax11.output deleted file mode 100644 index a71ff2a4001..00000000000 --- a/test/yacc/err_syntax11.output +++ /dev/null @@ -1,27 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -3 terminals, 2 nonterminals -2 grammar rules, 3 states diff --git a/test/yacc/err_syntax11.tab.c b/test/yacc/err_syntax11.tab.c deleted file mode 100644 index ef6c680724f..00000000000 --- a/test/yacc/err_syntax11.tab.c +++ /dev/null @@ -1,505 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 251 "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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/err_syntax11.tab.h b/test/yacc/err_syntax11.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax12.error b/test/yacc/err_syntax12.error deleted file mode 100644 index 358960bdb9e..00000000000 --- a/test/yacc/err_syntax12.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - line 7 of "./err_syntax12.y", the value of text has been redeclared diff --git a/test/yacc/err_syntax12.output b/test/yacc/err_syntax12.output deleted file mode 100644 index a71ff2a4001..00000000000 --- a/test/yacc/err_syntax12.output +++ /dev/null @@ -1,27 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -3 terminals, 2 nonterminals -2 grammar rules, 3 states diff --git a/test/yacc/err_syntax12.tab.c b/test/yacc/err_syntax12.tab.c deleted file mode 100644 index 8060aaa26a1..00000000000 --- a/test/yacc/err_syntax12.tab.c +++ /dev/null @@ -1,511 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 257 "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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/err_syntax12.tab.h b/test/yacc/err_syntax12.tab.h deleted file mode 100644 index c273c08742a..00000000000 --- a/test/yacc/err_syntax12.tab.h +++ /dev/null @@ -1 +0,0 @@ -#define text 456 diff --git a/test/yacc/err_syntax13.error b/test/yacc/err_syntax13.error deleted file mode 100644 index 9ffa8b40c27..00000000000 --- a/test/yacc/err_syntax13.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 7 of "./err_syntax13.y", the start symbol text is a token diff --git a/test/yacc/err_syntax13.output b/test/yacc/err_syntax13.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax13.tab.c b/test/yacc/err_syntax13.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax13.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax13.tab.h b/test/yacc/err_syntax13.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax14.error b/test/yacc/err_syntax14.error deleted file mode 100644 index 73e9f7c8319..00000000000 --- a/test/yacc/err_syntax14.error +++ /dev/null @@ -1,2 +0,0 @@ -YACC: w - line 7 of "./err_syntax14.y", the start symbol has been redeclared -YACC: e - the start symbol text2 is undefined diff --git a/test/yacc/err_syntax14.output b/test/yacc/err_syntax14.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax14.tab.c b/test/yacc/err_syntax14.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax14.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax14.tab.h b/test/yacc/err_syntax14.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax15.error b/test/yacc/err_syntax15.error deleted file mode 100644 index 36dc03fef8b..00000000000 --- a/test/yacc/err_syntax15.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 9 of "./err_syntax15.y", no grammar has been specified diff --git a/test/yacc/err_syntax15.output b/test/yacc/err_syntax15.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax15.tab.c b/test/yacc/err_syntax15.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax15.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax15.tab.h b/test/yacc/err_syntax15.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax16.error b/test/yacc/err_syntax16.error deleted file mode 100644 index 6ff15897045..00000000000 --- a/test/yacc/err_syntax16.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 14 of "./err_syntax16.y", a token appears on the lhs of a production diff --git a/test/yacc/err_syntax16.output b/test/yacc/err_syntax16.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax16.tab.c b/test/yacc/err_syntax16.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax16.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax16.tab.h b/test/yacc/err_syntax16.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax17.error b/test/yacc/err_syntax17.error deleted file mode 100644 index 8a8b64b0712..00000000000 --- a/test/yacc/err_syntax17.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 8 of "./err_syntax17.y", unterminated action -S: { error - ^ diff --git a/test/yacc/err_syntax17.output b/test/yacc/err_syntax17.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax17.tab.c b/test/yacc/err_syntax17.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax17.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax17.tab.h b/test/yacc/err_syntax17.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax18.error b/test/yacc/err_syntax18.error deleted file mode 100644 index c52fd71a1ec..00000000000 --- a/test/yacc/err_syntax18.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - line 9 of "./err_syntax18.y", $4 references beyond the end of the current rule diff --git a/test/yacc/err_syntax18.output b/test/yacc/err_syntax18.output deleted file mode 100644 index 09ed7d4c70a..00000000000 --- a/test/yacc/err_syntax18.output +++ /dev/null @@ -1,43 +0,0 @@ - 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/test/yacc/err_syntax18.tab.c b/test/yacc/err_syntax18.tab.c deleted file mode 100644 index 1c08b55b5b7..00000000000 --- a/test/yacc/err_syntax18.tab.c +++ /dev/null @@ -1,513 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 253 "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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 1: -#line 9 "err_syntax18.y" - { yyval = yystack.l_mark[1]; } -#line 455 "err_syntax18.tab.c" -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) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/err_syntax18.tab.h b/test/yacc/err_syntax18.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax19.error b/test/yacc/err_syntax19.error deleted file mode 100644 index 2499b7fc4f1..00000000000 --- a/test/yacc/err_syntax19.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 9 of "./err_syntax19.y", illegal $-name - { $$ = $; } - ^ diff --git a/test/yacc/err_syntax19.output b/test/yacc/err_syntax19.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax19.tab.c b/test/yacc/err_syntax19.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax19.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax19.tab.h b/test/yacc/err_syntax19.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax2.error b/test/yacc/err_syntax2.error deleted file mode 100644 index 29fe56c28b4..00000000000 --- a/test/yacc/err_syntax2.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 1 of "./err_syntax2.y", unmatched /* -%{ /* - ^ diff --git a/test/yacc/err_syntax2.output b/test/yacc/err_syntax2.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax2.tab.c b/test/yacc/err_syntax2.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax2.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax2.tab.h b/test/yacc/err_syntax2.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax20.error b/test/yacc/err_syntax20.error deleted file mode 100644 index 76dac8152de..00000000000 --- a/test/yacc/err_syntax20.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - the symbol recur is undefined diff --git a/test/yacc/err_syntax20.output b/test/yacc/err_syntax20.output deleted file mode 100644 index cfe62800c64..00000000000 --- a/test/yacc/err_syntax20.output +++ /dev/null @@ -1,41 +0,0 @@ - 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/test/yacc/err_syntax20.tab.c b/test/yacc/err_syntax20.tab.c deleted file mode 100644 index d0b02858dcc..00000000000 --- a/test/yacc/err_syntax20.tab.c +++ /dev/null @@ -1,509 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 249 "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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 1: -#line 12 "err_syntax20.y" - { yystack.l_mark[-1].rechk = 3; } -#line 451 "err_syntax20.tab.c" -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) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/err_syntax20.tab.h b/test/yacc/err_syntax20.tab.h deleted file mode 100644 index 60dabd611dd..00000000000 --- a/test/yacc/err_syntax20.tab.h +++ /dev/null @@ -1 +0,0 @@ -#define recur 257 diff --git a/test/yacc/err_syntax21.error b/test/yacc/err_syntax21.error deleted file mode 100644 index 9b0dc17b662..00000000000 --- a/test/yacc/err_syntax21.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 12 of "./err_syntax21.y", $0 is untyped diff --git a/test/yacc/err_syntax21.output b/test/yacc/err_syntax21.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax21.tab.c b/test/yacc/err_syntax21.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax21.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax21.tab.h b/test/yacc/err_syntax21.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax22.error b/test/yacc/err_syntax22.error deleted file mode 100644 index 8622aa73f59..00000000000 --- a/test/yacc/err_syntax22.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 17 of "./err_syntax22.y", $2 (recur) is untyped diff --git a/test/yacc/err_syntax22.output b/test/yacc/err_syntax22.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax22.tab.c b/test/yacc/err_syntax22.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax22.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax22.tab.h b/test/yacc/err_syntax22.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax23.error b/test/yacc/err_syntax23.error deleted file mode 100644 index 3ccbbd1fee8..00000000000 --- a/test/yacc/err_syntax23.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 18 of "./err_syntax23.y", $$ is untyped diff --git a/test/yacc/err_syntax23.output b/test/yacc/err_syntax23.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax23.tab.c b/test/yacc/err_syntax23.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax23.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax23.tab.h b/test/yacc/err_syntax23.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax24.error b/test/yacc/err_syntax24.error deleted file mode 100644 index e8bbfeca35f..00000000000 --- a/test/yacc/err_syntax24.error +++ /dev/null @@ -1,2 +0,0 @@ -YACC: w - line 21 of "./err_syntax24.y", the default action for expr assigns an undefined value to $$ -YACC: e - line 22 of "./err_syntax24.y", $$ is untyped diff --git a/test/yacc/err_syntax24.output b/test/yacc/err_syntax24.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax24.tab.c b/test/yacc/err_syntax24.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax24.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax24.tab.h b/test/yacc/err_syntax24.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax25.error b/test/yacc/err_syntax25.error deleted file mode 100644 index 234a7b9fcd3..00000000000 --- a/test/yacc/err_syntax25.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 11 of "./err_syntax25.y", too many %union declarations -%union { -^ diff --git a/test/yacc/err_syntax25.output b/test/yacc/err_syntax25.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax25.tab.c b/test/yacc/err_syntax25.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax25.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax25.tab.h b/test/yacc/err_syntax25.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax26.error b/test/yacc/err_syntax26.error deleted file mode 100644 index c9a09ad1992..00000000000 --- a/test/yacc/err_syntax26.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 6 of "./err_syntax26.y", unexpected end-of-file diff --git a/test/yacc/err_syntax26.output b/test/yacc/err_syntax26.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax26.tab.c b/test/yacc/err_syntax26.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax26.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax26.tab.h b/test/yacc/err_syntax26.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax27.error b/test/yacc/err_syntax27.error deleted file mode 100644 index 2a277087c35..00000000000 --- a/test/yacc/err_syntax27.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 3 of "./err_syntax27.y", missing '}' diff --git a/test/yacc/err_syntax27.output b/test/yacc/err_syntax27.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax27.tab.c b/test/yacc/err_syntax27.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax27.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax27.tab.h b/test/yacc/err_syntax27.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax3.error b/test/yacc/err_syntax3.error deleted file mode 100644 index 7e4871b87ad..00000000000 --- a/test/yacc/err_syntax3.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax3.y", unterminated string -%token '(' '*' '& - ^ diff --git a/test/yacc/err_syntax3.output b/test/yacc/err_syntax3.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax3.tab.c b/test/yacc/err_syntax3.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax3.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax3.tab.h b/test/yacc/err_syntax3.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax4.error b/test/yacc/err_syntax4.error deleted file mode 100644 index 6a10d4040eb..00000000000 --- a/test/yacc/err_syntax4.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 1 of "./err_syntax4.y", unmatched %{ -%{ -^ diff --git a/test/yacc/err_syntax4.output b/test/yacc/err_syntax4.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax4.tab.c b/test/yacc/err_syntax4.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax4.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax4.tab.h b/test/yacc/err_syntax4.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax5.error b/test/yacc/err_syntax5.error deleted file mode 100644 index 37a8500b053..00000000000 --- a/test/yacc/err_syntax5.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax5.y", unterminated %union declaration -%union { -^ diff --git a/test/yacc/err_syntax5.output b/test/yacc/err_syntax5.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax5.tab.c b/test/yacc/err_syntax5.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax5.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax5.tab.h b/test/yacc/err_syntax5.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax6.error b/test/yacc/err_syntax6.error deleted file mode 100644 index bde624a7159..00000000000 --- a/test/yacc/err_syntax6.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax6.y", illegal tag -%token '\777' - ^ diff --git a/test/yacc/err_syntax7.output b/test/yacc/err_syntax7.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax7.tab.c b/test/yacc/err_syntax7.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax7.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax7.tab.h b/test/yacc/err_syntax7.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax7a.error b/test/yacc/err_syntax7a.error deleted file mode 100644 index 213711e11ff..00000000000 --- a/test/yacc/err_syntax7a.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax7a.y", illegal character -%token '\xfff' - ^ diff --git a/test/yacc/err_syntax7a.output b/test/yacc/err_syntax7a.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax7a.tab.c b/test/yacc/err_syntax7a.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax7a.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax7a.tab.h b/test/yacc/err_syntax7a.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax7b.error b/test/yacc/err_syntax7b.error deleted file mode 100644 index 19b617ccca1..00000000000 --- a/test/yacc/err_syntax7b.error +++ /dev/null @@ -1,3 +0,0 @@ -YACC: e - line 6 of "./err_syntax7b.y", illegal character -%token '\x.' - ^ diff --git a/test/yacc/err_syntax7b.output b/test/yacc/err_syntax7b.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax7b.tab.c b/test/yacc/err_syntax7b.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax7b.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax7b.tab.h b/test/yacc/err_syntax7b.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax8.error b/test/yacc/err_syntax8.error deleted file mode 100644 index c6a4cc943fa..00000000000 --- a/test/yacc/err_syntax8.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 6 of "./err_syntax8.y", illegal use of reserved symbol . diff --git a/test/yacc/err_syntax8.output b/test/yacc/err_syntax8.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax8.tab.c b/test/yacc/err_syntax8.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax8.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax8.tab.h b/test/yacc/err_syntax8.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax8a.error b/test/yacc/err_syntax8a.error deleted file mode 100644 index ed503e90451..00000000000 --- a/test/yacc/err_syntax8a.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 6 of "./err_syntax8a.y", illegal use of reserved symbol $$123 diff --git a/test/yacc/err_syntax8a.output b/test/yacc/err_syntax8a.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax8a.tab.c b/test/yacc/err_syntax8a.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax8a.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax8a.tab.h b/test/yacc/err_syntax8a.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax9.error b/test/yacc/err_syntax9.error deleted file mode 100644 index 1f74b7ea0a2..00000000000 --- a/test/yacc/err_syntax9.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 7 of "./err_syntax9.y", the start symbol text cannot be declared to be a token diff --git a/test/yacc/err_syntax9.output b/test/yacc/err_syntax9.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/err_syntax9.tab.c b/test/yacc/err_syntax9.tab.c deleted file mode 100644 index f0d4d2c7b6a..00000000000 --- a/test/yacc/err_syntax9.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/test/yacc/err_syntax9.tab.h b/test/yacc/err_syntax9.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/error.error b/test/yacc/error.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/error.output b/test/yacc/error.output deleted file mode 100644 index 0c4db6225e2..00000000000 --- a/test/yacc/error.output +++ /dev/null @@ -1,27 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -2 terminals, 2 nonterminals -2 grammar rules, 3 states diff --git a/test/yacc/error.tab.c b/test/yacc/error.tab.c deleted file mode 100644 index f21fa7dd854..00000000000 --- a/test/yacc/error.tab.c +++ /dev/null @@ -1,505 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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_" - -#define YYPURE 0 - -#line 2 "error.y" -int yylex(void); -static void yyerror(const char *); -#line 104 "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 int 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_dgoto[] = { 2, -}; -static const YYINT error_sindex[] = { -256, - 0, 0, -}; -static const YYINT error_rindex[] = { 0, - 0, 0, -}; -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-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 error_rule[] = { -"$accept : S", -"S : error", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 251 "error.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/error.tab.h b/test/yacc/error.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/expr.oxout.error b/test/yacc/expr.oxout.error deleted file mode 100644 index 58fdb1c267f..00000000000 --- a/test/yacc/expr.oxout.error +++ /dev/null @@ -1 +0,0 @@ -YACC: w - line 6 of "expr.Y", the precedence of '*' has been redeclared diff --git a/test/yacc/expr.oxout.output b/test/yacc/expr.oxout.output deleted file mode 100644 index bfd433c03c7..00000000000 --- a/test/yacc/expr.oxout.output +++ /dev/null @@ -1,209 +0,0 @@ - 0 $accept : yyyAugNonterm $end - - 1 $$1 : - - 2 yyyAugNonterm : $$1 s - - 3 s : expr - - 4 expr : expr '*' expr - 5 | expr '+' expr - 6 | expr '/' expr - 7 | expr '-' expr - 8 | '(' expr ')' - 9 | ID - 10 | CONST - -state 0 - $accept : . yyyAugNonterm $end (0) - $$1 : . (1) - - . reduce 1 - - yyyAugNonterm goto 1 - $$1 goto 2 - - -state 1 - $accept : yyyAugNonterm . $end (0) - - $end accept - - -state 2 - yyyAugNonterm : $$1 . s (2) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - s goto 6 - expr goto 7 - - -state 3 - expr : ID . (9) - - . reduce 9 - - -state 4 - expr : CONST . (10) - - . reduce 10 - - -state 5 - expr : '(' . expr ')' (8) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 8 - - -state 6 - yyyAugNonterm : $$1 s . (2) - - . reduce 2 - - -state 7 - s : expr . (3) - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - - '+' shift 9 - '-' shift 10 - '*' shift 11 - '/' shift 12 - $end reduce 3 - - -state 8 - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - expr : '(' expr . ')' (8) - - '+' shift 9 - '-' shift 10 - '*' shift 11 - '/' shift 12 - ')' shift 13 - . error - - -state 9 - expr : expr '+' . expr (5) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 14 - - -state 10 - expr : expr '-' . expr (7) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 15 - - -state 11 - expr : expr '*' . expr (4) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 16 - - -state 12 - expr : expr '/' . expr (6) - - ID shift 3 - CONST shift 4 - '(' shift 5 - . error - - expr goto 17 - - -state 13 - expr : '(' expr ')' . (8) - - . reduce 8 - - -state 14 - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr '+' expr . (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - - '*' shift 11 - '/' shift 12 - $end reduce 5 - '+' reduce 5 - '-' reduce 5 - ')' reduce 5 - - -state 15 - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - expr : expr '-' expr . (7) - - '*' shift 11 - '/' shift 12 - $end reduce 7 - '+' reduce 7 - '-' reduce 7 - ')' reduce 7 - - -state 16 - expr : expr . '*' expr (4) - expr : expr '*' expr . (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr . '-' expr (7) - - . reduce 4 - - -state 17 - expr : expr . '*' expr (4) - expr : expr . '+' expr (5) - expr : expr . '/' expr (6) - expr : expr '/' expr . (6) - expr : expr . '-' expr (7) - - '*' shift 11 - $end reduce 6 - '+' reduce 6 - '-' reduce 6 - '/' reduce 6 - ')' reduce 6 - - -10 terminals, 5 nonterminals -11 grammar rules, 18 states diff --git a/test/yacc/expr.oxout.tab.c b/test/yacc/expr.oxout.tab.c deleted file mode 100644 index af45682f868..00000000000 --- a/test/yacc/expr.oxout.tab.c +++ /dev/null @@ -1,1970 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 expr_oxout_parse -#endif /* yyparse */ - -#ifndef yylex -#define yylex expr_oxout_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror expr_oxout_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar expr_oxout_char -#endif /* yychar */ - -#ifndef yyval -#define yyval expr_oxout_val -#endif /* yyval */ - -#ifndef yylval -#define yylval expr_oxout_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug expr_oxout_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs expr_oxout_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag expr_oxout_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs expr_oxout_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen expr_oxout_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred expr_oxout_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto expr_oxout_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex expr_oxout_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex expr_oxout_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex expr_oxout_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable expr_oxout_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck expr_oxout_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname expr_oxout_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule expr_oxout_rule -#endif /* yyrule */ -#define YYPREFIX "expr_oxout_" - -#define YYPURE 0 - -#line 5 "expr.oxout.y" -#include -#include -#line 8 "expr.Y" - -#include "expr.oxout.h" -#include - -extern int yylex(void); -extern void yyerror(const char *); -#line 27 "expr.oxout.y" -#include -#define yyyR USHRT_MAX -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 31 "expr.oxout.y" -typedef union YYSTYPE { -struct yyyOxAttrbs { -struct yyyStackItem *yyyOxStackItem; -} yyyOxAttrbs; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -#line 38 "expr.oxout.y" -#include -#include - -static int yyyYok = 1; - -extern yyyFT yyyRCIL[]; - -void yyyExecuteRRsection(yyyGNT *rootNode); -void yyyYoxInit(void); -void yyyDecorate(void); -struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ -void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); -void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); -void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); -void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); -void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); -void yyyabort(void); - -#line 146 "expr.oxout.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 ID 257 -#define CONST 258 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT expr_oxout_lhs[] = { -1, - 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, -}; -static const YYINT expr_oxout_len[] = { 2, - 0, 2, 1, 3, 3, 3, 3, 3, 1, 1, -}; -static const YYINT expr_oxout_defred[] = { 1, - 0, 0, 9, 10, 0, 2, 0, 0, 0, 0, - 0, 0, 8, 0, 0, 4, 0, -}; -static const YYINT expr_oxout_dgoto[] = { 1, - 6, 2, 7, -}; -static const YYINT expr_oxout_sindex[] = { 0, - 0, -40, 0, 0, -40, 0, -18, -24, -40, -40, - -40, -40, 0, -37, -37, 0, -39, -}; -static const YYINT expr_oxout_rindex[] = { 0, - 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, - 0, 0, 0, 2, 8, 0, 1, -}; -static const YYINT expr_oxout_gindex[] = { 0, - 0, 0, 4, -}; -#define YYTABLESIZE 218 -static const YYINT expr_oxout_table[] = { 5, - 6, 5, 11, 0, 11, 3, 0, 7, 8, 12, - 0, 0, 14, 15, 16, 17, 13, 11, 9, 0, - 10, 0, 12, 11, 9, 0, 10, 0, 12, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 6, 5, 6, 5, 6, 5, 6, 7, 0, - 7, 0, 7, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3, 4, -}; -static const YYINT expr_oxout_check[] = { 40, - 0, 0, 42, -1, 42, 0, -1, 0, 5, 47, - -1, -1, 9, 10, 11, 12, 41, 42, 43, -1, - 45, -1, 47, 42, 43, -1, 45, -1, 47, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 41, 41, 43, 43, 45, 45, 47, 41, -1, - 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 258 -#define YYUNDFTOKEN 264 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const expr_oxout_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,"ID", -"CONST",0,0,0,0,0,"illegal-symbol", -}; -static const char *const expr_oxout_rule[] = { -"$accept : yyyAugNonterm", -"$$1 :", -"yyyAugNonterm : $$1 s", -"s : expr", -"expr : expr '*' expr", -"expr : expr '+' expr", -"expr : expr '/' expr", -"expr : expr '-' expr", -"expr : '(' expr ')'", -"expr : ID", -"expr : CONST", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 53 "expr.Y" - - -int yyparse(void); - -int main() - {yyparse(); - } - - - -#line 138 "expr.oxout.y" -long yyySSALspaceSize = 20000; -long yyyRSmaxSize = 1000; -long yyyTravStackMaxSize = 2000; - -struct yyySolvedSAlistCell {yyyWAT attrbNum; - long next; - }; - -#define yyyLambdaSSAL 0 -long yyySSALCfreeList = yyyLambdaSSAL; -long yyyNewSSALC = 1; - -struct yyySolvedSAlistCell *yyySSALspace; - -long yyyNbytesStackStg; - - - -yyyFT yyyRCIL[1]; - -short yyyIIIEL[] = {0, -0,2,6,10,14,18,22,24, -}; - -long yyyIIEL[] = { -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,1, -}; - -long yyyIEL[] = { -0,0,0, -}; - -yyyFT yyyEntL[1]; - -void yyyfatal(char *msg) -{fputs(msg,stderr);exit(-1);} - - - -#define yyySSALof 'S' -#define yyyRSof 'q' -#define yyyTSof 't' - - - -void yyyHandleOverflow(char which) - {char *msg1 = "?", *msg2; - long oldSize = 0, newSize; - switch(which) - { - case yyySSALof : - msg1 = "SSAL overflow: "; - oldSize = yyySSALspaceSize; - break; - case yyyRSof : - msg1 = "ready set overflow: "; - oldSize = yyyRSmaxSize; - break; - case yyyTSof : - msg1 = "traversal stack overflow: "; - oldSize = yyyTravStackMaxSize; - break; - default :; - } - newSize = (3*oldSize)/2; - if (newSize < 100) newSize = 100; - fputs(msg1,stderr); - fprintf(stderr,"size was %ld.\n",oldSize); - msg2 = " Have to modify evaluator: -Y%c%ld.\n"; - fprintf(stderr,msg2,which,newSize); - exit(-1); - } - - - -void yyySignalEnts(yyyGNT *node,long startP,long stopP) - {yyyGNT *dumNode; - - while (startP < stopP) - { - if (!yyyEntL[startP]) dumNode = node; - else dumNode = (node->cL)[yyyEntL[startP]-1]; - if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] - ) - ) - ) - { - if (++yyyRSTop == yyyAfterRS) - {yyyHandleOverflow(yyyRSof); - break; - } - yyyRSTop->node = dumNode; - yyyRSTop->whichSym = yyyEntL[startP]; - yyyRSTop->wa = yyyEntL[startP+1]; - } - startP += 2; - } - } - - - - - - -void yyySolveAndSignal() { -long yyyiDum,*yyypL; -int yyyws,yyywa; -yyyGNT *yyyRSTopN,*yyyRefN; -yyyParent yyyRSTopNp; - - -yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; -yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; -yyywa = yyyRSTop->wa; -yyyRSTop--; -switch(yyyRefN->prodNum) { -case 1: /***yacc rule 1***/ - switch (yyyws) { - } -break; -case 2: /***yacc rule 2***/ - switch (yyyws) { - } -break; -case 3: /***yacc rule 3***/ - switch (yyyws) { - } -break; -case 4: /***yacc rule 4***/ - switch (yyyws) { - } -break; -case 5: /***yacc rule 5***/ - switch (yyyws) { - } -break; -case 6: /***yacc rule 6***/ - switch (yyyws) { - } -break; -case 7: /***yacc rule 7***/ - switch (yyyws) { - case 1: /**/ - switch (yyywa) { - } - break; - } -break; -case 8: /***yacc rule 8***/ - switch (yyyws) { - case 1: /**/ - switch (yyywa) { - } - break; - } -break; -} /* switch */ - -if (yyyws) /* the just-solved instance was inherited. */ - {if (yyyRSTopN->prodNum) - {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; - yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], - yyyIEL[yyyiDum+1] - ); - } - } - else /* the just-solved instance was synthesized. */ - {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ - {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + - yyyRSTopN->whichSym - ] + - yyywa; - yyySignalEnts(yyyRSTopNp.noderef, - yyyIEL[yyyiDum], - yyyIEL[yyyiDum+1] - ); - } - else /* node is still on the stack--it has no parent yet. */ - {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); - if (yyySSALCfreeList == yyyLambdaSSAL) - {yyySSALspace[yyyNewSSALC].next = *yyypL; - if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) - yyyHandleOverflow(yyySSALof); - } - else - {yyyiDum = yyySSALCfreeList; - yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; - yyySSALspace[yyyiDum].next = *yyypL; - *yyypL = yyyiDum; - } - yyySSALspace[*yyypL].attrbNum = yyywa; - } - } - -} /* yyySolveAndSignal */ - - - - - - -#define condStg unsigned int conds; -#define yyyClearConds {yyyTST->conds = 0;} -#define yyySetCond(n) {yyyTST->conds += (1<<(n));} -#define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) - - - -struct yyyTravStackItem {yyyGNT *node; - char isReady; - condStg - }; - - - -void yyyDoTraversals(yyyGNT *rootNode) -{struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; - yyyGNT *yyyTSTn,**yyyCLptr2; - int yyyi,yyyRL,yyyPass; - int i; - - if (!yyyYok) return; - if ((yyyTravStack = - ((struct yyyTravStackItem *) - calloc((size_t)yyyTravStackMaxSize, - (size_t)sizeof(struct yyyTravStackItem) - ) - ) - ) - == - (struct yyyTravStackItem *)NULL - ) - {fputs("malloc error in traversal stack allocation\n",stderr); - exit(-1); - } - -yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; -yyyTravStack++; - - -for (yyyi=0; yyyi<2; yyyi++) { -yyyTST = yyyTravStack; -yyyTST->node = rootNode; -yyyTST->isReady = 0; -yyyClearConds - -while(yyyTST >= yyyTravStack) - {yyyTSTn = yyyTST->node; - if (yyyTST->isReady) - {yyyPass = 1; - goto yyyTravSwitch; -yyyTpop: - yyyTST--; - } - else - {yyyPass = 0; - goto yyyTravSwitch; -yyyTpush: - yyyTST->isReady = 1; - if (yyyTSTn->prodNum) - {if (yyyRL) - {yyyCLptr2 = yyyTSTn->cL; - i = yyyTSTn->cLlen; - while (i--) - {if (++yyyTST == yyyAfterTravStack) - yyyHandleOverflow(yyyTSof); - else - {yyyTST->node = *yyyCLptr2; - yyyTST->isReady = 0; - yyyClearConds - } - yyyCLptr2++; - } - } /* right to left */ - else /* left to right */ - {i = yyyTSTn->cLlen; - yyyCLptr2 = yyyTSTn->cL + i; - while (i--) - {yyyCLptr2--; - if (++yyyTST == yyyAfterTravStack) - yyyHandleOverflow(yyyTSof); - else - {yyyTST->node = *yyyCLptr2; - yyyTST->isReady = 0; - yyyClearConds - } - } - } /* left to right */ - } - } /* else */ - continue; -yyyTravSwitch: - switch(yyyTSTn->prodNum) { -case 1: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - -if (! -#line 24 "expr.Y" - (1) -#line 444 "expr.oxout.y" -) yyySetCond(1) -yyySetCond(2) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 24 "expr.Y" - -#line 453 "expr.oxout.y" -} -if (yyyCond(1) != yyyPass) { -#line 24 "expr.Y" - printf("\n"); - -#line 459 "expr.oxout.y" -} -if (yyyCond(2) != yyyPass) { -#line 25 "expr.Y" - printf("prefix: "); - -#line 465 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; -if ( -#line 23 "expr.Y" - (1) -#line 477 "expr.oxout.y" -) yyySetCond(2) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 22 "expr.Y" - printf("\n"); - -#line 486 "expr.oxout.y" -} -if (yyyCond(1) != yyyPass) { -#line 23 "expr.Y" - -#line 491 "expr.oxout.y" -} -if (yyyCond(2) != yyyPass) { -#line 23 "expr.Y" - printf("postfix: "); - -#line 497 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 2: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 29 "expr.Y" - printf(" * "); - -#line 518 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 28 "expr.Y" - printf(" * "); - -#line 533 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 3: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 32 "expr.Y" - printf(" + "); - -#line 554 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 33 "expr.Y" - printf(" + "); - -#line 569 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 4: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 37 "expr.Y" - printf(" / "); - -#line 590 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 36 "expr.Y" - printf(" / "); - -#line 605 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 5: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 41 "expr.Y" - printf(" - "); - -#line 626 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 40 "expr.Y" - printf(" - "); - -#line 641 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 6: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - - break; - } - break; - } - -break; -case 7: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 46 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 685 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 45 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 700 "expr.oxout.y" -} - break; - } - break; - } - -break; -case 8: - switch(yyyi) { - case 0: - switch(yyyPass) { - case 0: -yyyRL = 0;yyySetCond(0) - - case 1: - -if (yyyCond(0) != yyyPass) { -#line 50 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 721 "expr.oxout.y" -} - break; - } - break; - case 1: - switch(yyyPass) { - case 0: -yyyRL = 0; - case 1: - -if (yyyCond(0) != yyyPass) { -#line 49 "expr.Y" - printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); - -#line 736 "expr.oxout.y" -} - break; - } - break; - } - -break; - } /* switch */ - if (yyyPass) goto yyyTpop; else goto yyyTpush; - } /* while */ - } /* for */ -} /* yyyDoTraversals */ - -void yyyExecuteRRsection(yyyGNT *rootNode) { - int yyyi; - long cycleSum = 0; - long nNZrc = 0; - - if (!yyyYok) return; - yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); - if (nNZrc) - { - fputs("\n\n\n**********\n",stderr); - fputs("cycle detected in completed parse tree",stderr); - fputs(" after decoration.\n",stderr); -#if CYCLE_VERBOSE - fprintf(stderr, - "number of unsolved attribute instances == %ld.\n", - nNZrc - ); - fprintf(stderr, - "total number of remaining dependencies == %ld.\n", - cycleSum - ); - fputs("average number of remaining dependencies\n",stderr); - fprintf(stderr," per unsolved instance == %f.\n", - ((float)(cycleSum)/(float)(nNZrc)) - ); -#endif - fprintf(stderr, - "searching parse tree for %ld unsolved instances:\n", - nNZrc - ); - yyyUnsolvedInstSearchTravAux(rootNode); - } - yyyDoTraversals(rootNode); -} /* yyyExecuteRRsection */ - - - -yyyWAT yyyLRCIL[2] = {0,0, -}; - - - -void yyyYoxInit(void) - { - static int yyyInitDone = 0; - if (yyyInitDone) return; - - if ((yyyRS = (yyyRSitem *) - calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(yyyRSitem)) - ) - == - ((yyyRSitem *) NULL) - ) - yyyfatal("malloc error in ox ready set space allocation\n"); - yyyRS++; - yyyAfterRS = yyyRS + yyyRSmaxSize; - - - if ((yyySSALspace = (struct yyySolvedSAlistCell *) - calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) - ) - == - ((struct yyySolvedSAlistCell *) NULL) - ) - yyyfatal("malloc error in stack solved list space allocation\n"); - yyyInitDone = 1; - - yyyRSTop = yyyRS - 1; - } /* yyyYoxInit */ - - - -void yyyDecorate(void) - { - while (yyyRSTop >= yyyRS) - yyySolveAndSignal(); - } - - - -void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) - {yyyWST i; - yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; - yyyGNT *gnpDum; - va_list ap; - - *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); - if (*yyyOxStackItem == (yyySIT *) NULL) - yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); - (*yyyOxStackItem)->node = - (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); - if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) - yyyfatal("malloc error in ox node space allocation\n"); - (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; - (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; - (*yyyOxStackItem)->node->parentIsStack = 1; - (*yyyOxStackItem)->node->cLlen = yyyRHSlength; - (*yyyOxStackItem)->node->cL = - (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); - if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) - yyyfatal("malloc error in ox child list space allocation\n"); - (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; - (*yyyOxStackItem)->node->refCountList = - (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); - if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) - yyyfatal("malloc error in ox reference count list space allocation\n"); - (*yyyOxStackItem)->node->prodNum = (int) yyyProdNum; - va_start(ap, yyval_OxAttrbs); - for (i=1;i<=yyyRHSlength;i++) - {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; - gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; - gnpDum->whichSym = i; - gnpDum->parent.noderef = (*yyyOxStackItem)->node; - gnpDum->parentIsStack = 0; - } - va_end(ap); - } - - - -#define yyyDECORfREQ 50 - - - -void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) - {yyyWST i; - yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; - long SSALptr,SSALptrHead,*cPtrPtr; - long *pL; - yyyGNT *gnpDum; - long iTemp; - long nextP; - static unsigned short intNodeCount = yyyDECORfREQ; - va_list ap; - - nextP = startP; - while (nextP < stopP) - {if (yyyRCIL[nextP] == yyyR) - {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; - } - else - {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; - } - nextP += 3; - } - pL = yyyIIEL + yyyIIIEL[yyyProdNum]; - va_start(ap, yyval_OxAttrbs); - for (i=1;i<=yyyRHSlength;i++) - {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; - pL++; - SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); - if (SSALptr != yyyLambdaSSAL) - {*cPtrPtr = yyyLambdaSSAL; - do - { - iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); - yyySignalEnts(yyyOxStackItem->node, - yyyIEL[iTemp], - yyyIEL[iTemp+1] - ); - SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); - } - while (SSALptr != yyyLambdaSSAL); - *cPtrPtr = yyySSALCfreeList; - yyySSALCfreeList = SSALptrHead; - } - } - va_end(ap); - nextP = startP + 2; - while (nextP < stopP) - {if (!yyyRCIL[nextP]) - {if (yyyRCIL[nextP-2] == yyyR) - {pL = &(yyyOxStackItem->solvedSAlist); - if (yyySSALCfreeList == yyyLambdaSSAL) - {yyySSALspace[yyyNewSSALC].next = *pL; - if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) - yyyHandleOverflow(yyySSALof); - } - else - {iTemp = yyySSALCfreeList; - yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; - yyySSALspace[iTemp].next = *pL; - *pL = iTemp; - } - yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; - } - else - {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) - { - iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; - yyySignalEnts(gnpDum, - yyyIEL[iTemp], - yyyIEL[iTemp+1] - ); - } - } - } - nextP += 3; - } - if (!--intNodeCount) - {intNodeCount = yyyDECORfREQ; - yyyDecorate(); - } - } - - - -void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *mylval) - {yyyRCT *rcPdum; - yyySIT **yyyOxStackItem = &mylval->yyyOxAttrbs.yyyOxStackItem; - (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); - if ((*yyyOxStackItem) == (yyySIT *) NULL) - yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); - (*yyyOxStackItem)->node = - (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) - ; - if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) - yyyfatal("malloc error in ox node space allocation\n"); - (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; - (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; - (*yyyOxStackItem)->node->parentIsStack = 1; - (*yyyOxStackItem)->node->cLlen = 0; - (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; - (*yyyOxStackItem)->node->refCountListLen = nAttrbs; - rcPdum = (*yyyOxStackItem)->node->refCountList = - (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); - if (rcPdum == (yyyRCT *) NULL) - yyyfatal("malloc error in ox reference count list space allocation\n"); - while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; - (*yyyOxStackItem)->node->prodNum = 0; - (*yyyOxStackItem)->node->whichSym = 0; - } - - - -void yyyabort(void) - {yyyYok = 0; - } - - - - - -#define yyyLastProdNum 8 - - -#define yyyNsorts 1 - - -int yyyProdsInd[] = { - 0, - 0, 2, 6, 10, 14, 18, 22, 24, - 26, -}; - - -int yyyProds[][2] = { -{ 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, -{ 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, -{ 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, -{ 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, -{ 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, -{ 567, 1}, -}; - - -int yyySortsInd[] = { - 0, - 0, - 1, -}; - - -int yyySorts[] = { - 413, -}; - - - -char *yyyStringTab[] = { -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"s",0,0,0, -0,0,"y",0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"LRpre",0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"'('",0,0,0, -0,0,0,0,"')'", -0,0,0,0,0, -0,0,"'*'","lexeme",0, -0,0,0,0,0, -"'+'",0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"'-'",0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,"'/'",0,0, -0,0,0,0,0, -0,0,"expr",0,0, -0,0,0,0,0, -0,0,0,0,0, -0,"printf",0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,"CONST","LRpost",0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,"ID", -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0,0,0,0,0, -0, -}; - - - -#define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) - -#define yyyGSoccurStr(prodNum,symPos) \ - (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) - -#define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) - -#define yyySortOf(prodNum,symPos) \ - (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) - -#define yyyAttrbStr(prodNum,symPos,attrbNum) \ - (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ - (attrbNum) \ - ] \ - ] \ - ) - - - -void yyyShowProd(int i) - {int j,nSyms; - - nSyms = yyySizeofProd(i); - for (j=0; j\n",stderr); - else - putc('\n',stderr); - } - } - } - - - -void yyyCheckNodeInstancesSolved(yyyGNT *np) - {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; - int nUnsolvedInsts = 0; - - if (np->prodNum != 0) - {inTerminalNode = 0; - prodNum = np->prodNum; - symPos = 0; - } - else - {inTerminalNode = 1; - prodNum = np->parent.noderef->prodNum; - symPos = np->whichSym; - } - mysort = yyySortOf(prodNum,symPos); - sortSize = yyySizeofSort(mysort); - for (i=0; irefCountList)[i] != 0) nUnsolvedInsts += 1; - if (nUnsolvedInsts) - {fprintf(stderr, - "\nFound node that has %d unsolved attribute instance(s).\n", - nUnsolvedInsts - ); - fprintf(stderr,"Node is labeled \"%s\".\n", - yyyGSoccurStr(prodNum,symPos)); - if (inTerminalNode) - {fputs("Node is terminal. Its parent production is:\n ",stderr); - yyyShowProd(prodNum); - } - else - {fputs("Node is nonterminal. ",stderr); - if (!(np->parentIsStack)) - {fprintf(stderr, - "Node is %dth child in its parent production:\n ", - np->whichSym - ); - yyyShowProd(np->parent.noderef->prodNum); - } - fputs("Node is on left hand side of this production:\n ",stderr); - yyyShowProd(np->prodNum); - } - fputs("The following instances are unsolved:\n",stderr); - for (i=0; irefCountList)[i] != 0) - fprintf(stderr," %-16s still has %1d dependencies.\n", - yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); - } - } - - - -void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) - {yyyGNT **yyyCLpdum; - yyyRCT *rcp; - int i; - - /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ - rcp = pNode->refCountList; - i = pNode->refCountListLen; - while (i--) - if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} - yyyCLpdum = pNode->cL; - i = pNode->cLlen; - while (i--) - { - yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); - yyyCLpdum++; - } - } - - - -void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) - {yyyGNT **yyyCLpdum; - int i; - - yyyCheckNodeInstancesSolved(pNode); - yyyCLpdum = pNode->cL; - i = pNode->cLlen; - while (i--) - { - yyyUnsolvedInstSearchTravAux(*yyyCLpdum); - yyyCLpdum++; - } - } - - - -void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) - {yyyGNT **yyyCLpdum; - int i; - - yyyCLpdum = pNode->cL; - i = pNode->cLlen; - while (i--) - { - yyyUnsolvedInstSearchTravAux(*yyyCLpdum); - yyyCLpdum++; - } - } - - - -#line 1647 "expr.oxout.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 1: -#line 64 "expr.oxout.y" - {yyyYoxInit();} -#line 1849 "expr.oxout.tab.c" -break; -case 2: -#line 66 "expr.oxout.y" - { - yyyDecorate(); yyyExecuteRRsection(yystack.l_mark[0].yyyOxAttrbs.yyyOxStackItem->node); - } -#line 1856 "expr.oxout.tab.c" -break; -case 3: -#line 73 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(1,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(1,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 1863 "expr.oxout.tab.c" -break; -case 4: -#line 80 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(2,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(2,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 1870 "expr.oxout.tab.c" -break; -case 5: -#line 87 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(3,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(3,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 1877 "expr.oxout.tab.c" -break; -case 6: -#line 94 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(4,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(4,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 1884 "expr.oxout.tab.c" -break; -case 7: -#line 101 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(5,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(5,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 1891 "expr.oxout.tab.c" -break; -case 8: -#line 108 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(6,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(6,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 1898 "expr.oxout.tab.c" -break; -case 9: -#line 114 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(7,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(7,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 1905 "expr.oxout.tab.c" -break; -case 10: -#line 121 "expr.oxout.y" - {if(yyyYok){ -yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); -yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} -#line 1912 "expr.oxout.tab.c" -break; -#line 1914 "expr.oxout.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/expr.oxout.tab.h b/test/yacc/expr.oxout.tab.h deleted file mode 100644 index 03527bb036a..00000000000 --- a/test/yacc/expr.oxout.tab.h +++ /dev/null @@ -1,15 +0,0 @@ -#define ID 257 -#define CONST 258 -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE { -struct yyyOxAttrbs { -struct yyyStackItem *yyyOxStackItem; -} yyyOxAttrbs; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE expr_oxout_lval; diff --git a/test/yacc/grammar.dot b/test/yacc/grammar.dot deleted file mode 100644 index 1988e12ddd6..00000000000 --- a/test/yacc/grammar.dot +++ /dev/null @@ -1,906 +0,0 @@ -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/test/yacc/grammar.error b/test/yacc/grammar.error deleted file mode 100644 index d442f8abaeb..00000000000 --- a/test/yacc/grammar.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 1 shift/reduce conflict, 29 reduce/reduce conflicts. diff --git a/test/yacc/grammar.output b/test/yacc/grammar.output deleted file mode 100644 index 6351322345b..00000000000 --- a/test/yacc/grammar.output +++ /dev/null @@ -1,2214 +0,0 @@ - 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 diff --git a/test/yacc/grammar.tab.c b/test/yacc/grammar.tab.c deleted file mode 100644 index 90136eca0db..00000000000 --- a/test/yacc/grammar.tab.c +++ /dev/null @@ -1,2106 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 -#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3) - -/* 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 389 "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 int 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_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, -}; -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-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, -"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",0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,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 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 1015 "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 occurrences 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 1095 "grammar.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 10: -#line 378 "grammar.y" - { - yyerrok; - } -#line 1299 "grammar.tab.c" -break; -case 11: -#line 382 "grammar.y" - { - yyerrok; - } -#line 1306 "grammar.tab.c" -break; -case 13: -#line 393 "grammar.y" - { - /* Provide an empty action here so bison will not complain about - * incompatible types in the default action it normally would - * have generated. - */ - } -#line 1316 "grammar.tab.c" -break; -case 14: -#line 400 "grammar.y" - { - /* empty */ - } -#line 1323 "grammar.tab.c" -break; -case 15: -#line 407 "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(); - } -#line 1337 "grammar.tab.c" -break; -case 16: -#line 418 "grammar.y" - { - if (func_params != NULL) { - set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); - } 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(); - } -#line 1354 "grammar.tab.c" -break; -case 17: -#line 432 "grammar.y" - { - cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags; - free_decl_spec(&yystack.l_mark[0].decl_spec); - } -#line 1362 "grammar.tab.c" -break; -case 18: -#line 437 "grammar.y" - { - end_typedef(); - } -#line 1369 "grammar.tab.c" -break; -case 19: -#line 444 "grammar.y" - { - begin_typedef(); - } -#line 1376 "grammar.tab.c" -break; -case 20: -#line 448 "grammar.y" - { - begin_typedef(); - } -#line 1383 "grammar.tab.c" -break; -case 23: -#line 460 "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); - } -#line 1398 "grammar.tab.c" -break; -case 24: -#line 472 "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); - } -#line 1410 "grammar.tab.c" -break; -case 25: -#line 484 "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; - } -#line 1424 "grammar.tab.c" -break; -case 26: -#line 495 "grammar.y" - { - /* If we're converting to K&R and we've got a nominally K&R - * function which has a parameter which is ANSI (i.e., a prototyped - * 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); - } -#line 1451 "grammar.tab.c" -break; -case 28: -#line 520 "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; - } -#line 1464 "grammar.tab.c" -break; -case 29: -#line 530 "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); - } -#line 1483 "grammar.tab.c" -break; -case 36: -#line 561 "grammar.y" - { - join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec); - free(yystack.l_mark[-1].decl_spec.text); - free(yystack.l_mark[0].decl_spec.text); - } -#line 1492 "grammar.tab.c" -break; -case 40: -#line 576 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1499 "grammar.tab.c" -break; -case 41: -#line 580 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN); - } -#line 1506 "grammar.tab.c" -break; -case 42: -#line 584 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1513 "grammar.tab.c" -break; -case 43: -#line 588 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC); - } -#line 1520 "grammar.tab.c" -break; -case 44: -#line 592 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE); - } -#line 1527 "grammar.tab.c" -break; -case 45: -#line 596 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK); - } -#line 1534 "grammar.tab.c" -break; -case 46: -#line 603 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); - } -#line 1541 "grammar.tab.c" -break; -case 47: -#line 607 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1548 "grammar.tab.c" -break; -case 48: -#line 611 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT); - } -#line 1555 "grammar.tab.c" -break; -case 49: -#line 615 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1562 "grammar.tab.c" -break; -case 50: -#line 619 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1569 "grammar.tab.c" -break; -case 51: -#line 623 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT); - } -#line 1576 "grammar.tab.c" -break; -case 52: -#line 627 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1583 "grammar.tab.c" -break; -case 53: -#line 631 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1590 "grammar.tab.c" -break; -case 54: -#line 635 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1597 "grammar.tab.c" -break; -case 55: -#line 639 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); - } -#line 1604 "grammar.tab.c" -break; -case 56: -#line 643 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1611 "grammar.tab.c" -break; -case 57: -#line 647 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1618 "grammar.tab.c" -break; -case 58: -#line 651 "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); - } -#line 1628 "grammar.tab.c" -break; -case 61: -#line 663 "grammar.y" - { - new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); - } -#line 1635 "grammar.tab.c" -break; -case 62: -#line 667 "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); - } -#line 1648 "grammar.tab.c" -break; -case 63: -#line 680 "grammar.y" - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-2].text.text, TEXT_LEN, yystack.l_mark[-1].text.text); - new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); - } -#line 1658 "grammar.tab.c" -break; -case 64: -#line 687 "grammar.y" - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); - new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); - } -#line 1668 "grammar.tab.c" -break; -case 65: -#line 694 "grammar.y" - { - (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); - new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); - } -#line 1676 "grammar.tab.c" -break; -case 66: -#line 702 "grammar.y" - { - imply_typedef(yyval.text.text); - } -#line 1683 "grammar.tab.c" -break; -case 67: -#line 706 "grammar.y" - { - imply_typedef(yyval.text.text); - } -#line 1690 "grammar.tab.c" -break; -case 68: -#line 713 "grammar.y" - { - new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator); - } -#line 1697 "grammar.tab.c" -break; -case 69: -#line 717 "grammar.y" - { - add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator); - } -#line 1704 "grammar.tab.c" -break; -case 70: -#line 724 "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; - } -#line 1716 "grammar.tab.c" -break; -case 71: -#line 733 "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); - } - } -#line 1727 "grammar.tab.c" -break; -case 73: -#line 745 "grammar.y" - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, yystack.l_mark[-1].text.text); - new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); - } -#line 1737 "grammar.tab.c" -break; -case 74: -#line 752 "grammar.y" - { - char *s; - if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); - new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); - } -#line 1747 "grammar.tab.c" -break; -case 75: -#line 759 "grammar.y" - { - (void)sprintf(buf, "enum %.*s", TEXT_LEN, yystack.l_mark[0].text.text); - new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); - } -#line 1755 "grammar.tab.c" -break; -case 76: -#line 767 "grammar.y" - { - imply_typedef("enum"); - yyval.text = yystack.l_mark[0].text; - } -#line 1763 "grammar.tab.c" -break; -case 79: -#line 780 "grammar.y" - { - yyval.declarator = yystack.l_mark[0].declarator; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - yyval.declarator->begin = yystack.l_mark[-1].text.begin; - yyval.declarator->pointer = TRUE; - } -#line 1775 "grammar.tab.c" -break; -case 81: -#line 793 "grammar.y" - { - yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin); - } -#line 1782 "grammar.tab.c" -break; -case 82: -#line 797 "grammar.y" - { - yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - yyval.declarator->begin = yystack.l_mark[-2].text.begin; - } -#line 1793 "grammar.tab.c" -break; -case 83: -#line 805 "grammar.y" - { - yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - } -#line 1803 "grammar.tab.c" -break; -case 84: -#line 812 "grammar.y" - { - yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); - yyval.declarator->params = yystack.l_mark[-1].param_list; - 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; - } -#line 1814 "grammar.tab.c" -break; -case 85: -#line 820 "grammar.y" - { - yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); - yyval.declarator->params = yystack.l_mark[-1].param_list; - 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; - } -#line 1825 "grammar.tab.c" -break; -case 86: -#line 831 "grammar.y" - { - (void)sprintf(yyval.text.text, "*%.*s", TEXT_LEN, yystack.l_mark[0].text.text); - yyval.text.begin = yystack.l_mark[-1].text.begin; - } -#line 1833 "grammar.tab.c" -break; -case 87: -#line 836 "grammar.y" - { - (void)sprintf(yyval.text.text, "*%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); - yyval.text.begin = yystack.l_mark[-2].text.begin; - } -#line 1841 "grammar.tab.c" -break; -case 88: -#line 844 "grammar.y" - { - strcpy(yyval.text.text, ""); - yyval.text.begin = 0L; - } -#line 1849 "grammar.tab.c" -break; -case 90: -#line 853 "grammar.y" - { - (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text); - yyval.text.begin = yystack.l_mark[0].decl_spec.begin; - free(yystack.l_mark[0].decl_spec.text); - } -#line 1858 "grammar.tab.c" -break; -case 91: -#line 859 "grammar.y" - { - (void)sprintf(yyval.text.text, "%.*s%.*s ", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].decl_spec.text); - yyval.text.begin = yystack.l_mark[-1].text.begin; - free(yystack.l_mark[0].decl_spec.text); - } -#line 1867 "grammar.tab.c" -break; -case 93: -#line 869 "grammar.y" - { - add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "..."); - } -#line 1874 "grammar.tab.c" -break; -case 94: -#line 876 "grammar.y" - { - new_param_list(&yyval.param_list, yystack.l_mark[0].parameter); - } -#line 1881 "grammar.tab.c" -break; -case 95: -#line 880 "grammar.y" - { - add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter); - } -#line 1888 "grammar.tab.c" -break; -case 96: -#line 887 "grammar.y" - { - check_untagged(&yystack.l_mark[-1].decl_spec); - yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); - } -#line 1896 "grammar.tab.c" -break; -case 97: -#line 892 "grammar.y" - { - check_untagged(&yystack.l_mark[-1].decl_spec); - yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); - } -#line 1904 "grammar.tab.c" -break; -case 98: -#line 897 "grammar.y" - { - check_untagged(&yystack.l_mark[0].decl_spec); - yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0); - } -#line 1912 "grammar.tab.c" -break; -case 99: -#line 905 "grammar.y" - { - new_ident_list(&yyval.param_list); - } -#line 1919 "grammar.tab.c" -break; -case 101: -#line 913 "grammar.y" - { - new_ident_list(&yyval.param_list); - add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text); - } -#line 1927 "grammar.tab.c" -break; -case 102: -#line 918 "grammar.y" - { - add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text); - } -#line 1934 "grammar.tab.c" -break; -case 103: -#line 925 "grammar.y" - { - yyval.text = yystack.l_mark[0].text; - } -#line 1941 "grammar.tab.c" -break; -case 104: -#line 929 "grammar.y" - { -#if OPT_LINTLIBRARY - if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */ - yyval.text = yystack.l_mark[0].text; - } else -#endif - (void)sprintf(yyval.text.text, "&%.*s", TEXT_LEN, yystack.l_mark[0].text.text); - yyval.text.begin = yystack.l_mark[-1].text.begin; - } -#line 1954 "grammar.tab.c" -break; -case 105: -#line 942 "grammar.y" - { - yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); - } -#line 1961 "grammar.tab.c" -break; -case 106: -#line 946 "grammar.y" - { - yyval.declarator = yystack.l_mark[0].declarator; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - yyval.declarator->begin = yystack.l_mark[-1].text.begin; - } -#line 1972 "grammar.tab.c" -break; -case 108: -#line 958 "grammar.y" - { - yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - yyval.declarator->begin = yystack.l_mark[-2].text.begin; - } -#line 1983 "grammar.tab.c" -break; -case 109: -#line 966 "grammar.y" - { - yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); - free(yyval.declarator->text); - yyval.declarator->text = xstrdup(buf); - } -#line 1993 "grammar.tab.c" -break; -case 110: -#line 973 "grammar.y" - { - yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); - } -#line 2000 "grammar.tab.c" -break; -case 111: -#line 977 "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; - } -#line 2011 "grammar.tab.c" -break; -case 112: -#line 985 "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; - } -#line 2021 "grammar.tab.c" -break; -case 113: -#line 992 "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; - } -#line 2035 "grammar.tab.c" -break; -case 114: -#line 1003 "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; - } -#line 2048 "grammar.tab.c" -break; -#line 2050 "grammar.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/grammar.tab.h b/test/yacc/grammar.tab.h deleted file mode 100644 index 531dd2e849b..00000000000 --- a/test/yacc/grammar.tab.h +++ /dev/null @@ -1,35 +0,0 @@ -#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 diff --git a/test/yacc/help.error b/test/yacc/help.error deleted file mode 100644 index c4d890b024c..00000000000 --- a/test/yacc/help.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: error message -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/yacc/help.output b/test/yacc/help.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_b_opt.error b/test/yacc/no_b_opt.error deleted file mode 100644 index c4d890b024c..00000000000 --- a/test/yacc/no_b_opt.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: error message -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/yacc/no_b_opt.output b/test/yacc/no_b_opt.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_b_opt1.error b/test/yacc/no_b_opt1.error deleted file mode 100644 index 87286c2661e..00000000000 --- a/test/yacc/no_b_opt1.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/test/yacc/no_b_opt1.output b/test/yacc/no_b_opt1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_code_c.error b/test/yacc/no_code_c.error deleted file mode 100644 index 87286c2661e..00000000000 --- a/test/yacc/no_code_c.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/test/yacc/no_code_c.output b/test/yacc/no_code_c.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_defines.error b/test/yacc/no_defines.error deleted file mode 100644 index 773985d66f3..00000000000 --- a/test/yacc/no_defines.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.h" diff --git a/test/yacc/no_defines.output b/test/yacc/no_defines.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_graph.error b/test/yacc/no_graph.error deleted file mode 100644 index d5575f40042..00000000000 --- a/test/yacc/no_graph.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.dot" diff --git a/test/yacc/no_graph.output b/test/yacc/no_graph.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_include.error b/test/yacc/no_include.error deleted file mode 100644 index 3ece4a454e3..00000000000 --- a/test/yacc/no_include.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.i" diff --git a/test/yacc/no_include.output b/test/yacc/no_include.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_opts.error b/test/yacc/no_opts.error deleted file mode 100644 index ad3131a69ab..00000000000 --- a/test/yacc/no_opts.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.y" diff --git a/test/yacc/no_opts.output b/test/yacc/no_opts.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_output.error b/test/yacc/no_output.error deleted file mode 100644 index a2f142a9d53..00000000000 --- a/test/yacc/no_output.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/test/yacc/no_output.output b/test/yacc/no_output.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_output1.error b/test/yacc/no_output1.error deleted file mode 100644 index a2f142a9d53..00000000000 --- a/test/yacc/no_output1.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/test/yacc/no_output1.output b/test/yacc/no_output1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_output2.error b/test/yacc/no_output2.error deleted file mode 100644 index c4d890b024c..00000000000 --- a/test/yacc/no_output2.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: error message -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/yacc/no_output2.output b/test/yacc/no_output2.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_p_opt.error b/test/yacc/no_p_opt.error deleted file mode 100644 index c4d890b024c..00000000000 --- a/test/yacc/no_p_opt.error +++ /dev/null @@ -1,31 +0,0 @@ -YACC: error message -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/yacc/no_p_opt.output b/test/yacc/no_p_opt.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_p_opt1.error b/test/yacc/no_p_opt1.error deleted file mode 100644 index 87286c2661e..00000000000 --- a/test/yacc/no_p_opt1.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/test/yacc/no_p_opt1.output b/test/yacc/no_p_opt1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/no_verbose.error b/test/yacc/no_verbose.error deleted file mode 100644 index a2f142a9d53..00000000000 --- a/test/yacc/no_verbose.error +++ /dev/null @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/test/yacc/no_verbose.output b/test/yacc/no_verbose.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/nostdin.error b/test/yacc/nostdin.error deleted file mode 100644 index 7f74f49a89b..00000000000 --- a/test/yacc/nostdin.error +++ /dev/null @@ -1,30 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -h print this help-message - -H defines_file write definitions to defines_file - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit - -Long options: - --defines -H - --file-prefix -b - --graph -g - --help -h - --name-prefix -p - --no-lines -l - --output -o - --version -V diff --git a/test/yacc/nostdin.output b/test/yacc/nostdin.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/ok_syntax1.error b/test/yacc/ok_syntax1.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/ok_syntax1.output b/test/yacc/ok_syntax1.output deleted file mode 100644 index 105a1d30d48..00000000000 --- a/test/yacc/ok_syntax1.output +++ /dev/null @@ -1,461 +0,0 @@ - 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/test/yacc/ok_syntax1.tab.c b/test/yacc/ok_syntax1.tab.c deleted file mode 100644 index 3d97e7db7c3..00000000000 --- a/test/yacc/ok_syntax1.tab.c +++ /dev/null @@ -1,731 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 - -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 43 "ok_syntax1.y" -typedef union YYSTYPE -{ - 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 int 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 - -#if YYDEBUG -int yydebug; -#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 - -#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 390 "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; - int yynerrs; - - /* 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 - - memset(&yyval, 0, sizeof(yyval)); - memset(&yylval, 0, sizeof(yylval)); - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 66 "ok_syntax1.y" - { yyerrok ; } -#line 603 "ok_syntax1.tab.c" -break; -case 4: -#line 70 "ok_syntax1.y" - { printf("%d\n",yystack.l_mark[0].ival);} -#line 608 "ok_syntax1.tab.c" -break; -case 5: -#line 72 "ok_syntax1.y" - { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; } -#line 613 "ok_syntax1.tab.c" -break; -case 6: -#line 76 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-1].ival; } -#line 618 "ok_syntax1.tab.c" -break; -case 7: -#line 78 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; } -#line 623 "ok_syntax1.tab.c" -break; -case 8: -#line 80 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; } -#line 628 "ok_syntax1.tab.c" -break; -case 9: -#line 82 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; } -#line 633 "ok_syntax1.tab.c" -break; -case 10: -#line 84 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; } -#line 638 "ok_syntax1.tab.c" -break; -case 11: -#line 86 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; } -#line 643 "ok_syntax1.tab.c" -break; -case 12: -#line 88 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; } -#line 648 "ok_syntax1.tab.c" -break; -case 13: -#line 90 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; } -#line 653 "ok_syntax1.tab.c" -break; -case 14: -#line 92 "ok_syntax1.y" - { yyval.ival = - yystack.l_mark[0].ival; } -#line 658 "ok_syntax1.tab.c" -break; -case 15: -#line 94 "ok_syntax1.y" - { yyval.ival = regs[yystack.l_mark[0].ival]; } -#line 663 "ok_syntax1.tab.c" -break; -case 17: -#line 99 "ok_syntax1.y" - { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; } -#line 668 "ok_syntax1.tab.c" -break; -case 18: -#line 101 "ok_syntax1.y" - { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } -#line 673 "ok_syntax1.tab.c" -break; -#line 675 "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) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/ok_syntax1.tab.h b/test/yacc/ok_syntax1.tab.h deleted file mode 100644 index ca92fd77dfc..00000000000 --- a/test/yacc/ok_syntax1.tab.h +++ /dev/null @@ -1,29 +0,0 @@ -#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 YYSTYPE -{ - char * cval; - int ival; - double dval; -} YYSTYPE; -#endif /* !YYSTYPE_IS_DECLARED */ diff --git a/test/yacc/pure_calc.error b/test/yacc/pure_calc.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/pure_calc.output b/test/yacc/pure_calc.output deleted file mode 100644 index 3aed47511c9..00000000000 --- a/test/yacc/pure_calc.output +++ /dev/null @@ -1,461 +0,0 @@ - 0 $accept : list $end - - 1 list : - 2 | list stat '\n' - 3 | list error '\n' - - 4 stat : expr - 5 | LETTER '=' expr - - 6 expr : '(' expr ')' - 7 | expr '+' expr - 8 | expr '-' expr - 9 | expr '*' expr - 10 | expr '/' expr - 11 | expr '%' expr - 12 | expr '&' expr - 13 | expr '|' expr - 14 | '-' expr - 15 | LETTER - 16 | number - - 17 number : DIGIT - 18 | number DIGIT - -state 0 - $accept : . list $end (0) - list : . (1) - - . reduce 1 - - list goto 1 - - -state 1 - $accept : list . $end (0) - list : list . stat '\n' (2) - list : list . error '\n' (3) - - $end accept - error shift 2 - DIGIT shift 3 - LETTER shift 4 - '-' shift 5 - '(' shift 6 - . error - - stat goto 7 - expr goto 8 - number goto 9 - - -state 2 - list : list error . '\n' (3) - - '\n' shift 10 - . error - - -state 3 - number : DIGIT . (17) - - . reduce 17 - - -state 4 - stat : LETTER . '=' expr (5) - expr : LETTER . (15) - - '=' shift 11 - '|' reduce 15 - '&' reduce 15 - '+' reduce 15 - '-' reduce 15 - '*' reduce 15 - '/' reduce 15 - '%' reduce 15 - '\n' reduce 15 - - -state 5 - expr : '-' . expr (14) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 13 - number goto 9 - - -state 6 - expr : '(' . expr ')' (6) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 14 - number goto 9 - - -state 7 - list : list stat . '\n' (2) - - '\n' shift 15 - . error - - -state 8 - stat : expr . (4) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 4 - - -state 9 - expr : number . (16) - number : number . DIGIT (18) - - DIGIT shift 23 - '|' reduce 16 - '&' reduce 16 - '+' reduce 16 - '-' reduce 16 - '*' reduce 16 - '/' reduce 16 - '%' reduce 16 - '\n' reduce 16 - ')' reduce 16 - - -state 10 - list : list error '\n' . (3) - - . reduce 3 - - -state 11 - stat : LETTER '=' . expr (5) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 24 - number goto 9 - - -state 12 - expr : LETTER . (15) - - . reduce 15 - - -state 13 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : '-' expr . (14) - - . reduce 14 - - -state 14 - expr : '(' expr . ')' (6) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - ')' shift 25 - . error - - -state 15 - list : list stat '\n' . (2) - - . reduce 2 - - -state 16 - expr : expr '|' . expr (13) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 26 - number goto 9 - - -state 17 - expr : expr '&' . expr (12) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 27 - number goto 9 - - -state 18 - expr : expr '+' . expr (7) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 28 - number goto 9 - - -state 19 - expr : expr '-' . expr (8) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 29 - number goto 9 - - -state 20 - expr : expr '*' . expr (9) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 30 - number goto 9 - - -state 21 - expr : expr '/' . expr (10) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 31 - number goto 9 - - -state 22 - expr : expr '%' . expr (11) - - DIGIT shift 3 - LETTER shift 12 - '-' shift 5 - '(' shift 6 - . error - - expr goto 32 - number goto 9 - - -state 23 - number : number DIGIT . (18) - - . reduce 18 - - -state 24 - stat : LETTER '=' expr . (5) - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '|' shift 16 - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '\n' reduce 5 - - -state 25 - expr : '(' expr ')' . (6) - - . reduce 6 - - -state 26 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - expr : expr '|' expr . (13) - - '&' shift 17 - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 13 - '\n' reduce 13 - ')' reduce 13 - - -state 27 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr '&' expr . (12) - expr : expr . '|' expr (13) - - '+' shift 18 - '-' shift 19 - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 12 - '&' reduce 12 - '\n' reduce 12 - ')' reduce 12 - - -state 28 - expr : expr . '+' expr (7) - expr : expr '+' expr . (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 7 - '&' reduce 7 - '+' reduce 7 - '-' reduce 7 - '\n' reduce 7 - ')' reduce 7 - - -state 29 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr '-' expr . (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - '*' shift 20 - '/' shift 21 - '%' shift 22 - '|' reduce 8 - '&' reduce 8 - '+' reduce 8 - '-' reduce 8 - '\n' reduce 8 - ')' reduce 8 - - -state 30 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr '*' expr . (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 9 - - -state 31 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr '/' expr . (10) - expr : expr . '%' expr (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 10 - - -state 32 - expr : expr . '+' expr (7) - expr : expr . '-' expr (8) - expr : expr . '*' expr (9) - expr : expr . '/' expr (10) - expr : expr . '%' expr (11) - expr : expr '%' expr . (11) - expr : expr . '&' expr (12) - expr : expr . '|' expr (13) - - . reduce 11 - - -16 terminals, 5 nonterminals -19 grammar rules, 33 states diff --git a/test/yacc/pure_calc.tab.c b/test/yacc/pure_calc.tab.c deleted file mode 100644 index eb0021549e2..00000000000 --- a/test/yacc/pure_calc.tab.c +++ /dev/null @@ -1,703 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#endif /* yyparse */ - -#ifndef yylex -#define yylex calc_lex -#endif /* yylex */ - -#ifndef yyerror -#define yyerror calc_error -#endif /* yyerror */ - -#ifndef yychar -#define yychar calc_char -#endif /* yychar */ - -#ifndef yyval -#define yyval calc_val -#endif /* yyval */ - -#ifndef yylval -#define yylval calc_lval -#endif /* yylval */ - -#ifndef yydebug -#define yydebug calc_debug -#endif /* yydebug */ - -#ifndef yynerrs -#define yynerrs calc_nerrs -#endif /* yynerrs */ - -#ifndef yyerrflag -#define yyerrflag calc_errflag -#endif /* yyerrflag */ - -#ifndef yylhs -#define yylhs calc_lhs -#endif /* yylhs */ - -#ifndef yylen -#define yylen calc_len -#endif /* yylen */ - -#ifndef yydefred -#define yydefred calc_defred -#endif /* yydefred */ - -#ifndef yydgoto -#define yydgoto calc_dgoto -#endif /* yydgoto */ - -#ifndef yysindex -#define yysindex calc_sindex -#endif /* yysindex */ - -#ifndef yyrindex -#define yyrindex calc_rindex -#endif /* yyrindex */ - -#ifndef yygindex -#define yygindex calc_gindex -#endif /* yygindex */ - -#ifndef yytable -#define yytable calc_table -#endif /* yytable */ - -#ifndef yycheck -#define yycheck calc_check -#endif /* yycheck */ - -#ifndef yyname -#define yyname calc_name -#endif /* yyname */ - -#ifndef yyrule -#define yyrule calc_rule -#endif /* yyrule */ -#define YYPREFIX "calc_" - -#define YYPURE 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 117 "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 int 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_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, -}; -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-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const calc_rule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -/* 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 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 362 "pure_calc.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; - int yynerrs; - - /* 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 - - memset(&yyval, 0, sizeof(yyval)); - memset(&yylval, 0, sizeof(yylval)); - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 34 "pure_calc.y" - { yyerrok ; } -#line 575 "pure_calc.tab.c" -break; -case 4: -#line 38 "pure_calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 580 "pure_calc.tab.c" -break; -case 5: -#line 40 "pure_calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 585 "pure_calc.tab.c" -break; -case 6: -#line 44 "pure_calc.y" - { yyval = yystack.l_mark[-1]; } -#line 590 "pure_calc.tab.c" -break; -case 7: -#line 46 "pure_calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 595 "pure_calc.tab.c" -break; -case 8: -#line 48 "pure_calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 600 "pure_calc.tab.c" -break; -case 9: -#line 50 "pure_calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 605 "pure_calc.tab.c" -break; -case 10: -#line 52 "pure_calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 610 "pure_calc.tab.c" -break; -case 11: -#line 54 "pure_calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 615 "pure_calc.tab.c" -break; -case 12: -#line 56 "pure_calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 620 "pure_calc.tab.c" -break; -case 13: -#line 58 "pure_calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 625 "pure_calc.tab.c" -break; -case 14: -#line 60 "pure_calc.y" - { yyval = - yystack.l_mark[0]; } -#line 630 "pure_calc.tab.c" -break; -case 15: -#line 62 "pure_calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 635 "pure_calc.tab.c" -break; -case 17: -#line 67 "pure_calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 640 "pure_calc.tab.c" -break; -case 18: -#line 69 "pure_calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 645 "pure_calc.tab.c" -break; -#line 647 "pure_calc.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/pure_calc.tab.h b/test/yacc/pure_calc.tab.h deleted file mode 100644 index 19211182d6b..00000000000 --- a/test/yacc/pure_calc.tab.h +++ /dev/null @@ -1,3 +0,0 @@ -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 diff --git a/test/yacc/pure_error.error b/test/yacc/pure_error.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/pure_error.output b/test/yacc/pure_error.output deleted file mode 100644 index 0c4db6225e2..00000000000 --- a/test/yacc/pure_error.output +++ /dev/null @@ -1,27 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -2 terminals, 2 nonterminals -2 grammar rules, 3 states diff --git a/test/yacc/pure_error.tab.c b/test/yacc/pure_error.tab.c deleted file mode 100644 index f3e13bee933..00000000000 --- a/test/yacc/pure_error.tab.c +++ /dev/null @@ -1,524 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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_" - -#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 112 "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 int 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_dgoto[] = { 2, -}; -static const YYINT error_sindex[] = { -256, - 0, 0, -}; -static const YYINT error_rindex[] = { 0, - 0, 0, -}; -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-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 error_rule[] = { -"$accept : S", -"S : error", - -}; -#endif - -#if YYDEBUG -int yydebug; -#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 - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -#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 259 "pure_error.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; - int yynerrs; - - /* 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 - - memset(&yyval, 0, sizeof(yyval)); - memset(&yylval, 0, sizeof(yylval)); - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/pure_error.tab.h b/test/yacc/pure_error.tab.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/quote_calc-s.error b/test/yacc/quote_calc-s.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/yacc/quote_calc-s.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc-s.output b/test/yacc/quote_calc-s.output deleted file mode 100644 index 0306652bfaa..00000000000 --- a/test/yacc/quote_calc-s.output +++ /dev/null @@ -1,557 +0,0 @@ - 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 diff --git a/test/yacc/quote_calc-s.tab.c b/test/yacc/quote_calc-s.tab.c deleted file mode 100644 index 588c14b76a3..00000000000 --- a/test/yacc/quote_calc-s.tab.c +++ /dev/null @@ -1,701 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 111 "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 int 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_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, -}; -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-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,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", -"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, -0,0,"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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 371 "quote_calc-s.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "quote_calc.y" - { yyerrok ; } -#line 573 "quote_calc-s.tab.c" -break; -case 4: -#line 39 "quote_calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 578 "quote_calc-s.tab.c" -break; -case 5: -#line 41 "quote_calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 583 "quote_calc-s.tab.c" -break; -case 6: -#line 45 "quote_calc.y" - { yyval = yystack.l_mark[-1]; } -#line 588 "quote_calc-s.tab.c" -break; -case 7: -#line 47 "quote_calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 593 "quote_calc-s.tab.c" -break; -case 8: -#line 49 "quote_calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 598 "quote_calc-s.tab.c" -break; -case 9: -#line 51 "quote_calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 603 "quote_calc-s.tab.c" -break; -case 10: -#line 53 "quote_calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 608 "quote_calc-s.tab.c" -break; -case 11: -#line 55 "quote_calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 613 "quote_calc-s.tab.c" -break; -case 12: -#line 57 "quote_calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 618 "quote_calc-s.tab.c" -break; -case 13: -#line 59 "quote_calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 623 "quote_calc-s.tab.c" -break; -case 14: -#line 61 "quote_calc.y" - { yyval = - yystack.l_mark[0]; } -#line 628 "quote_calc-s.tab.c" -break; -case 15: -#line 63 "quote_calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 633 "quote_calc-s.tab.c" -break; -case 17: -#line 68 "quote_calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 638 "quote_calc-s.tab.c" -break; -case 18: -#line 70 "quote_calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 643 "quote_calc-s.tab.c" -break; -#line 645 "quote_calc-s.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/quote_calc-s.tab.h b/test/yacc/quote_calc-s.tab.h deleted file mode 100644 index 1a465790341..00000000000 --- a/test/yacc/quote_calc-s.tab.h +++ /dev/null @@ -1,9 +0,0 @@ -#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 diff --git a/test/yacc/quote_calc.error b/test/yacc/quote_calc.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/yacc/quote_calc.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc.output b/test/yacc/quote_calc.output deleted file mode 100644 index 0306652bfaa..00000000000 --- a/test/yacc/quote_calc.output +++ /dev/null @@ -1,557 +0,0 @@ - 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 diff --git a/test/yacc/quote_calc.tab.c b/test/yacc/quote_calc.tab.c deleted file mode 100644 index 33a718e5eaa..00000000000 --- a/test/yacc/quote_calc.tab.c +++ /dev/null @@ -1,707 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 111 "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 int 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_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, -}; -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-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,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", -"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, -0,0,"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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 377 "quote_calc.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "quote_calc.y" - { yyerrok ; } -#line 579 "quote_calc.tab.c" -break; -case 4: -#line 39 "quote_calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 584 "quote_calc.tab.c" -break; -case 5: -#line 41 "quote_calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 589 "quote_calc.tab.c" -break; -case 6: -#line 45 "quote_calc.y" - { yyval = yystack.l_mark[-1]; } -#line 594 "quote_calc.tab.c" -break; -case 7: -#line 47 "quote_calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 599 "quote_calc.tab.c" -break; -case 8: -#line 49 "quote_calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 604 "quote_calc.tab.c" -break; -case 9: -#line 51 "quote_calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 609 "quote_calc.tab.c" -break; -case 10: -#line 53 "quote_calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 614 "quote_calc.tab.c" -break; -case 11: -#line 55 "quote_calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 619 "quote_calc.tab.c" -break; -case 12: -#line 57 "quote_calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 624 "quote_calc.tab.c" -break; -case 13: -#line 59 "quote_calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 629 "quote_calc.tab.c" -break; -case 14: -#line 61 "quote_calc.y" - { yyval = - yystack.l_mark[0]; } -#line 634 "quote_calc.tab.c" -break; -case 15: -#line 63 "quote_calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 639 "quote_calc.tab.c" -break; -case 17: -#line 68 "quote_calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 644 "quote_calc.tab.c" -break; -case 18: -#line 70 "quote_calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 649 "quote_calc.tab.c" -break; -#line 651 "quote_calc.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/quote_calc.tab.h b/test/yacc/quote_calc.tab.h deleted file mode 100644 index 498eff210db..00000000000 --- a/test/yacc/quote_calc.tab.h +++ /dev/null @@ -1,15 +0,0 @@ -#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 diff --git a/test/yacc/quote_calc2-s.error b/test/yacc/quote_calc2-s.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/yacc/quote_calc2-s.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc2-s.output b/test/yacc/quote_calc2-s.output deleted file mode 100644 index ed28ae2f21c..00000000000 --- a/test/yacc/quote_calc2-s.output +++ /dev/null @@ -1,557 +0,0 @@ - 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 diff --git a/test/yacc/quote_calc2-s.tab.c b/test/yacc/quote_calc2-s.tab.c deleted file mode 100644 index 98438d9f567..00000000000 --- a/test/yacc/quote_calc2-s.tab.c +++ /dev/null @@ -1,701 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 111 "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 int 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_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, -}; -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-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,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", -"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, -0,0,"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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 371 "quote_calc2-s.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "quote_calc2.y" - { yyerrok ; } -#line 573 "quote_calc2-s.tab.c" -break; -case 4: -#line 39 "quote_calc2.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 578 "quote_calc2-s.tab.c" -break; -case 5: -#line 41 "quote_calc2.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 583 "quote_calc2-s.tab.c" -break; -case 6: -#line 45 "quote_calc2.y" - { yyval = yystack.l_mark[-1]; } -#line 588 "quote_calc2-s.tab.c" -break; -case 7: -#line 47 "quote_calc2.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 593 "quote_calc2-s.tab.c" -break; -case 8: -#line 49 "quote_calc2.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 598 "quote_calc2-s.tab.c" -break; -case 9: -#line 51 "quote_calc2.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 603 "quote_calc2-s.tab.c" -break; -case 10: -#line 53 "quote_calc2.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 608 "quote_calc2-s.tab.c" -break; -case 11: -#line 55 "quote_calc2.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 613 "quote_calc2-s.tab.c" -break; -case 12: -#line 57 "quote_calc2.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 618 "quote_calc2-s.tab.c" -break; -case 13: -#line 59 "quote_calc2.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 623 "quote_calc2-s.tab.c" -break; -case 14: -#line 61 "quote_calc2.y" - { yyval = - yystack.l_mark[0]; } -#line 628 "quote_calc2-s.tab.c" -break; -case 15: -#line 63 "quote_calc2.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 633 "quote_calc2-s.tab.c" -break; -case 17: -#line 68 "quote_calc2.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 638 "quote_calc2-s.tab.c" -break; -case 18: -#line 70 "quote_calc2.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 643 "quote_calc2-s.tab.c" -break; -#line 645 "quote_calc2-s.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/quote_calc2-s.tab.h b/test/yacc/quote_calc2-s.tab.h deleted file mode 100644 index 1a465790341..00000000000 --- a/test/yacc/quote_calc2-s.tab.h +++ /dev/null @@ -1,9 +0,0 @@ -#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 diff --git a/test/yacc/quote_calc2.error b/test/yacc/quote_calc2.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/yacc/quote_calc2.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc2.output b/test/yacc/quote_calc2.output deleted file mode 100644 index ed28ae2f21c..00000000000 --- a/test/yacc/quote_calc2.output +++ /dev/null @@ -1,557 +0,0 @@ - 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 diff --git a/test/yacc/quote_calc2.tab.c b/test/yacc/quote_calc2.tab.c deleted file mode 100644 index 8301c570b69..00000000000 --- a/test/yacc/quote_calc2.tab.c +++ /dev/null @@ -1,707 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 111 "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 int 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_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, -}; -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-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,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", -"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, -0,0,"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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 377 "quote_calc2.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "quote_calc2.y" - { yyerrok ; } -#line 579 "quote_calc2.tab.c" -break; -case 4: -#line 39 "quote_calc2.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 584 "quote_calc2.tab.c" -break; -case 5: -#line 41 "quote_calc2.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 589 "quote_calc2.tab.c" -break; -case 6: -#line 45 "quote_calc2.y" - { yyval = yystack.l_mark[-1]; } -#line 594 "quote_calc2.tab.c" -break; -case 7: -#line 47 "quote_calc2.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 599 "quote_calc2.tab.c" -break; -case 8: -#line 49 "quote_calc2.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 604 "quote_calc2.tab.c" -break; -case 9: -#line 51 "quote_calc2.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 609 "quote_calc2.tab.c" -break; -case 10: -#line 53 "quote_calc2.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 614 "quote_calc2.tab.c" -break; -case 11: -#line 55 "quote_calc2.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 619 "quote_calc2.tab.c" -break; -case 12: -#line 57 "quote_calc2.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 624 "quote_calc2.tab.c" -break; -case 13: -#line 59 "quote_calc2.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 629 "quote_calc2.tab.c" -break; -case 14: -#line 61 "quote_calc2.y" - { yyval = - yystack.l_mark[0]; } -#line 634 "quote_calc2.tab.c" -break; -case 15: -#line 63 "quote_calc2.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 639 "quote_calc2.tab.c" -break; -case 17: -#line 68 "quote_calc2.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 644 "quote_calc2.tab.c" -break; -case 18: -#line 70 "quote_calc2.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 649 "quote_calc2.tab.c" -break; -#line 651 "quote_calc2.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/quote_calc2.tab.h b/test/yacc/quote_calc2.tab.h deleted file mode 100644 index 498eff210db..00000000000 --- a/test/yacc/quote_calc2.tab.h +++ /dev/null @@ -1,15 +0,0 @@ -#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 diff --git a/test/yacc/quote_calc3-s.error b/test/yacc/quote_calc3-s.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/yacc/quote_calc3-s.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc3-s.output b/test/yacc/quote_calc3-s.output deleted file mode 100644 index 0306652bfaa..00000000000 --- a/test/yacc/quote_calc3-s.output +++ /dev/null @@ -1,557 +0,0 @@ - 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 diff --git a/test/yacc/quote_calc3-s.tab.c b/test/yacc/quote_calc3-s.tab.c deleted file mode 100644 index 599ff8bfa75..00000000000 --- a/test/yacc/quote_calc3-s.tab.c +++ /dev/null @@ -1,702 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 111 "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 int 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_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, -}; -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-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,"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",0,0,0,0,0, -"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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 372 "quote_calc3-s.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "quote_calc3.y" - { yyerrok ; } -#line 574 "quote_calc3-s.tab.c" -break; -case 4: -#line 39 "quote_calc3.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 579 "quote_calc3-s.tab.c" -break; -case 5: -#line 41 "quote_calc3.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 584 "quote_calc3-s.tab.c" -break; -case 6: -#line 45 "quote_calc3.y" - { yyval = yystack.l_mark[-1]; } -#line 589 "quote_calc3-s.tab.c" -break; -case 7: -#line 47 "quote_calc3.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 594 "quote_calc3-s.tab.c" -break; -case 8: -#line 49 "quote_calc3.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 599 "quote_calc3-s.tab.c" -break; -case 9: -#line 51 "quote_calc3.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 604 "quote_calc3-s.tab.c" -break; -case 10: -#line 53 "quote_calc3.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 609 "quote_calc3-s.tab.c" -break; -case 11: -#line 55 "quote_calc3.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 614 "quote_calc3-s.tab.c" -break; -case 12: -#line 57 "quote_calc3.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 619 "quote_calc3-s.tab.c" -break; -case 13: -#line 59 "quote_calc3.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 624 "quote_calc3-s.tab.c" -break; -case 14: -#line 61 "quote_calc3.y" - { yyval = - yystack.l_mark[0]; } -#line 629 "quote_calc3-s.tab.c" -break; -case 15: -#line 63 "quote_calc3.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 634 "quote_calc3-s.tab.c" -break; -case 17: -#line 68 "quote_calc3.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 639 "quote_calc3-s.tab.c" -break; -case 18: -#line 70 "quote_calc3.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 644 "quote_calc3-s.tab.c" -break; -#line 646 "quote_calc3-s.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/quote_calc3-s.tab.h b/test/yacc/quote_calc3-s.tab.h deleted file mode 100644 index 1a465790341..00000000000 --- a/test/yacc/quote_calc3-s.tab.h +++ /dev/null @@ -1,9 +0,0 @@ -#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 diff --git a/test/yacc/quote_calc3.error b/test/yacc/quote_calc3.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/yacc/quote_calc3.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc3.output b/test/yacc/quote_calc3.output deleted file mode 100644 index 0306652bfaa..00000000000 --- a/test/yacc/quote_calc3.output +++ /dev/null @@ -1,557 +0,0 @@ - 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 diff --git a/test/yacc/quote_calc3.tab.c b/test/yacc/quote_calc3.tab.c deleted file mode 100644 index 4ba3ce72f31..00000000000 --- a/test/yacc/quote_calc3.tab.c +++ /dev/null @@ -1,702 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 111 "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 int 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_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, -}; -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-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,"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",0,0,0,0,0, -"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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 372 "quote_calc3.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "quote_calc3.y" - { yyerrok ; } -#line 574 "quote_calc3.tab.c" -break; -case 4: -#line 39 "quote_calc3.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 579 "quote_calc3.tab.c" -break; -case 5: -#line 41 "quote_calc3.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 584 "quote_calc3.tab.c" -break; -case 6: -#line 45 "quote_calc3.y" - { yyval = yystack.l_mark[-1]; } -#line 589 "quote_calc3.tab.c" -break; -case 7: -#line 47 "quote_calc3.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 594 "quote_calc3.tab.c" -break; -case 8: -#line 49 "quote_calc3.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 599 "quote_calc3.tab.c" -break; -case 9: -#line 51 "quote_calc3.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 604 "quote_calc3.tab.c" -break; -case 10: -#line 53 "quote_calc3.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 609 "quote_calc3.tab.c" -break; -case 11: -#line 55 "quote_calc3.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 614 "quote_calc3.tab.c" -break; -case 12: -#line 57 "quote_calc3.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 619 "quote_calc3.tab.c" -break; -case 13: -#line 59 "quote_calc3.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 624 "quote_calc3.tab.c" -break; -case 14: -#line 61 "quote_calc3.y" - { yyval = - yystack.l_mark[0]; } -#line 629 "quote_calc3.tab.c" -break; -case 15: -#line 63 "quote_calc3.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 634 "quote_calc3.tab.c" -break; -case 17: -#line 68 "quote_calc3.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 639 "quote_calc3.tab.c" -break; -case 18: -#line 70 "quote_calc3.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 644 "quote_calc3.tab.c" -break; -#line 646 "quote_calc3.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/quote_calc3.tab.h b/test/yacc/quote_calc3.tab.h deleted file mode 100644 index 1a465790341..00000000000 --- a/test/yacc/quote_calc3.tab.h +++ /dev/null @@ -1,9 +0,0 @@ -#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 diff --git a/test/yacc/quote_calc4-s.error b/test/yacc/quote_calc4-s.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/yacc/quote_calc4-s.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc4-s.output b/test/yacc/quote_calc4-s.output deleted file mode 100644 index a1d5afc9579..00000000000 --- a/test/yacc/quote_calc4-s.output +++ /dev/null @@ -1,557 +0,0 @@ - 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 diff --git a/test/yacc/quote_calc4-s.tab.c b/test/yacc/quote_calc4-s.tab.c deleted file mode 100644 index 86488292386..00000000000 --- a/test/yacc/quote_calc4-s.tab.c +++ /dev/null @@ -1,702 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 111 "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 int 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_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, -}; -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-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,"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",0,0,0,0,0, -"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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 372 "quote_calc4-s.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "quote_calc4.y" - { yyerrok ; } -#line 574 "quote_calc4-s.tab.c" -break; -case 4: -#line 39 "quote_calc4.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 579 "quote_calc4-s.tab.c" -break; -case 5: -#line 41 "quote_calc4.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 584 "quote_calc4-s.tab.c" -break; -case 6: -#line 45 "quote_calc4.y" - { yyval = yystack.l_mark[-1]; } -#line 589 "quote_calc4-s.tab.c" -break; -case 7: -#line 47 "quote_calc4.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 594 "quote_calc4-s.tab.c" -break; -case 8: -#line 49 "quote_calc4.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 599 "quote_calc4-s.tab.c" -break; -case 9: -#line 51 "quote_calc4.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 604 "quote_calc4-s.tab.c" -break; -case 10: -#line 53 "quote_calc4.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 609 "quote_calc4-s.tab.c" -break; -case 11: -#line 55 "quote_calc4.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 614 "quote_calc4-s.tab.c" -break; -case 12: -#line 57 "quote_calc4.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 619 "quote_calc4-s.tab.c" -break; -case 13: -#line 59 "quote_calc4.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 624 "quote_calc4-s.tab.c" -break; -case 14: -#line 61 "quote_calc4.y" - { yyval = - yystack.l_mark[0]; } -#line 629 "quote_calc4-s.tab.c" -break; -case 15: -#line 63 "quote_calc4.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 634 "quote_calc4-s.tab.c" -break; -case 17: -#line 68 "quote_calc4.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 639 "quote_calc4-s.tab.c" -break; -case 18: -#line 70 "quote_calc4.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 644 "quote_calc4-s.tab.c" -break; -#line 646 "quote_calc4-s.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/quote_calc4-s.tab.h b/test/yacc/quote_calc4-s.tab.h deleted file mode 100644 index 1a465790341..00000000000 --- a/test/yacc/quote_calc4-s.tab.h +++ /dev/null @@ -1,9 +0,0 @@ -#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 diff --git a/test/yacc/quote_calc4.error b/test/yacc/quote_calc4.error deleted file mode 100644 index 729d01c0abb..00000000000 --- a/test/yacc/quote_calc4.error +++ /dev/null @@ -1 +0,0 @@ -YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc4.output b/test/yacc/quote_calc4.output deleted file mode 100644 index a1d5afc9579..00000000000 --- a/test/yacc/quote_calc4.output +++ /dev/null @@ -1,557 +0,0 @@ - 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 diff --git a/test/yacc/quote_calc4.tab.c b/test/yacc/quote_calc4.tab.c deleted file mode 100644 index 115a2c0beb5..00000000000 --- a/test/yacc/quote_calc4.tab.c +++ /dev/null @@ -1,702 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 -#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 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 */ -#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 111 "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 int 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_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, -}; -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-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,"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",0,0,0,0,0, -"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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 372 "quote_calc4.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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 35 "quote_calc4.y" - { yyerrok ; } -#line 574 "quote_calc4.tab.c" -break; -case 4: -#line 39 "quote_calc4.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 579 "quote_calc4.tab.c" -break; -case 5: -#line 41 "quote_calc4.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 584 "quote_calc4.tab.c" -break; -case 6: -#line 45 "quote_calc4.y" - { yyval = yystack.l_mark[-1]; } -#line 589 "quote_calc4.tab.c" -break; -case 7: -#line 47 "quote_calc4.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 594 "quote_calc4.tab.c" -break; -case 8: -#line 49 "quote_calc4.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 599 "quote_calc4.tab.c" -break; -case 9: -#line 51 "quote_calc4.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 604 "quote_calc4.tab.c" -break; -case 10: -#line 53 "quote_calc4.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 609 "quote_calc4.tab.c" -break; -case 11: -#line 55 "quote_calc4.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 614 "quote_calc4.tab.c" -break; -case 12: -#line 57 "quote_calc4.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 619 "quote_calc4.tab.c" -break; -case 13: -#line 59 "quote_calc4.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 624 "quote_calc4.tab.c" -break; -case 14: -#line 61 "quote_calc4.y" - { yyval = - yystack.l_mark[0]; } -#line 629 "quote_calc4.tab.c" -break; -case 15: -#line 63 "quote_calc4.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 634 "quote_calc4.tab.c" -break; -case 17: -#line 68 "quote_calc4.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 639 "quote_calc4.tab.c" -break; -case 18: -#line 70 "quote_calc4.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 644 "quote_calc4.tab.c" -break; -#line 646 "quote_calc4.tab.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/quote_calc4.tab.h b/test/yacc/quote_calc4.tab.h deleted file mode 100644 index 1a465790341..00000000000 --- a/test/yacc/quote_calc4.tab.h +++ /dev/null @@ -1,9 +0,0 @@ -#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 diff --git a/test/yacc/rename_debug.c b/test/yacc/rename_debug.c deleted file mode 100644 index dad9d93ab7c..00000000000 --- a/test/yacc/rename_debug.c +++ /dev/null @@ -1,385 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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 int 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 132 "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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/rename_debug.error b/test/yacc/rename_debug.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/rename_debug.h b/test/yacc/rename_debug.h deleted file mode 100644 index e1d14cbda09..00000000000 --- a/test/yacc/rename_debug.h +++ /dev/null @@ -1 +0,0 @@ -#define YYERRCODE 256 diff --git a/test/yacc/rename_debug.i b/test/yacc/rename_debug.i deleted file mode 100644 index 1e81e02e8f9..00000000000 --- a/test/yacc/rename_debug.i +++ /dev/null @@ -1,66 +0,0 @@ -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "code_debug.y" - -#ifdef YYBISON -int yylex(void); -static void yyerror(const char *); -#endif - - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#ifndef YYDEBUG -#define YYDEBUG 1 -#endif - -#if YYDEBUG -extern int yydebug; -#endif - -extern int yyerrflag; -extern int yychar; -extern YYSTYPE yyval; -extern YYSTYPE yylval; -extern int yynerrs; diff --git a/test/yacc/rename_debug.output b/test/yacc/rename_debug.output deleted file mode 100644 index 0c4db6225e2..00000000000 --- a/test/yacc/rename_debug.output +++ /dev/null @@ -1,27 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -2 terminals, 2 nonterminals -2 grammar rules, 3 states diff --git a/test/yacc/stdin1.calc.c b/test/yacc/stdin1.calc.c deleted file mode 100644 index 19898028a66..00000000000 --- a/test/yacc/stdin1.calc.c +++ /dev/null @@ -1,610 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "(null)" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 31 "stdin1.calc.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 66 "(null)" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 280 "stdin1.calc.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 28 "(null)" - { yyerrok ; } -#line 482 "stdin1.calc.c" -break; -case 4: -#line 32 "(null)" - { printf("%d\n",yystack.l_mark[0]);} -#line 487 "stdin1.calc.c" -break; -case 5: -#line 34 "(null)" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 492 "stdin1.calc.c" -break; -case 6: -#line 38 "(null)" - { yyval = yystack.l_mark[-1]; } -#line 497 "stdin1.calc.c" -break; -case 7: -#line 40 "(null)" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 502 "stdin1.calc.c" -break; -case 8: -#line 42 "(null)" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 507 "stdin1.calc.c" -break; -case 9: -#line 44 "(null)" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 512 "stdin1.calc.c" -break; -case 10: -#line 46 "(null)" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 517 "stdin1.calc.c" -break; -case 11: -#line 48 "(null)" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 522 "stdin1.calc.c" -break; -case 12: -#line 50 "(null)" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 527 "stdin1.calc.c" -break; -case 13: -#line 52 "(null)" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 532 "stdin1.calc.c" -break; -case 14: -#line 54 "(null)" - { yyval = - yystack.l_mark[0]; } -#line 537 "stdin1.calc.c" -break; -case 15: -#line 56 "(null)" - { yyval = regs[yystack.l_mark[0]]; } -#line 542 "stdin1.calc.c" -break; -case 17: -#line 61 "(null)" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 547 "stdin1.calc.c" -break; -case 18: -#line 63 "(null)" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 552 "stdin1.calc.c" -break; -#line 554 "stdin1.calc.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/stdin1.error b/test/yacc/stdin1.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/stdin1.output b/test/yacc/stdin1.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/stdin2.calc.c b/test/yacc/stdin2.calc.c deleted file mode 100644 index 218350e19ab..00000000000 --- a/test/yacc/stdin2.calc.c +++ /dev/null @@ -1,610 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "calc.y" -# include -# include - -int regs[26]; -int base; - -extern int yylex(void); -static void yyerror(const char *s); - -#line 31 "stdin2.calc.c" - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -#if !(defined(yylex) || defined(YYSTATE)) -int YYLEX_DECL(); -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -#define DIGIT 257 -#define LETTER 258 -#define UMINUS 259 -#define YYERRCODE 256 -typedef int YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, -}; -static const YYINT yylen[] = { 2, - 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 1, 1, 1, 2, -}; -static const YYINT yydefred[] = { 1, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, - 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, - 10, 11, -}; -static const YYINT yydgoto[] = { 1, - 7, 8, 9, -}; -static const YYINT yysindex[] = { 0, - -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, - -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, - -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, - 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, - 0, 0, -}; -static const YYINT yygindex[] = { 0, - 0, 65, 0, -}; -#define YYTABLESIZE 220 -static const YYINT yytable[] = { 6, - 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, - 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, - 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, - 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, - 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, - 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, - 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, - 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, - 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, - 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, - 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, - 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, - 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, -}; -static const YYINT yycheck[] = { 40, - 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, - 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, - -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, - -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, - -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, - 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, - -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, - 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, - -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, - -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, - -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, - -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 259 -#define YYUNDFTOKEN 265 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) -#if YYDEBUG -static const char *const yyname[] = { - -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, -0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : list", -"list :", -"list : list stat '\\n'", -"list : list error '\\n'", -"stat : expr", -"stat : LETTER '=' expr", -"expr : '(' expr ')'", -"expr : expr '+' expr", -"expr : expr '-' expr", -"expr : expr '*' expr", -"expr : expr '/' expr", -"expr : expr '%' expr", -"expr : expr '&' expr", -"expr : expr '|' expr", -"expr : '-' expr", -"expr : LETTER", -"expr : number", -"number : DIGIT", -"number : number DIGIT", - -}; -#endif - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 66 "calc.y" - /* start of programs */ - -int -main (void) -{ - while(!feof(stdin)) { - yyparse(); - } - return 0; -} - -static void -yyerror(const char *s) -{ - fprintf(stderr, "%s\n", s); -} - -int -yylex(void) -{ - /* lexical analysis routine */ - /* returns LETTER for a lower case letter, yylval = 0 through 25 */ - /* return DIGIT for a digit, yylval = 0 through 9 */ - /* all other characters are returned immediately */ - - int c; - - while( (c=getchar()) == ' ' ) { /* skip blanks */ } - - /* c is now nonblank */ - - if( islower( c )) { - yylval = c - 'a'; - return ( LETTER ); - } - if( isdigit( c )) { - yylval = c - '0'; - return ( DIGIT ); - } - return( c ); -} -#line 280 "stdin2.calc.c" - -#if YYDEBUG -#include /* 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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 28 "calc.y" - { yyerrok ; } -#line 482 "stdin2.calc.c" -break; -case 4: -#line 32 "calc.y" - { printf("%d\n",yystack.l_mark[0]);} -#line 487 "stdin2.calc.c" -break; -case 5: -#line 34 "calc.y" - { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } -#line 492 "stdin2.calc.c" -break; -case 6: -#line 38 "calc.y" - { yyval = yystack.l_mark[-1]; } -#line 497 "stdin2.calc.c" -break; -case 7: -#line 40 "calc.y" - { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } -#line 502 "stdin2.calc.c" -break; -case 8: -#line 42 "calc.y" - { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } -#line 507 "stdin2.calc.c" -break; -case 9: -#line 44 "calc.y" - { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } -#line 512 "stdin2.calc.c" -break; -case 10: -#line 46 "calc.y" - { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } -#line 517 "stdin2.calc.c" -break; -case 11: -#line 48 "calc.y" - { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } -#line 522 "stdin2.calc.c" -break; -case 12: -#line 50 "calc.y" - { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } -#line 527 "stdin2.calc.c" -break; -case 13: -#line 52 "calc.y" - { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } -#line 532 "stdin2.calc.c" -break; -case 14: -#line 54 "calc.y" - { yyval = - yystack.l_mark[0]; } -#line 537 "stdin2.calc.c" -break; -case 15: -#line 56 "calc.y" - { yyval = regs[yystack.l_mark[0]]; } -#line 542 "stdin2.calc.c" -break; -case 17: -#line 61 "calc.y" - { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } -#line 547 "stdin2.calc.c" -break; -case 18: -#line 63 "calc.y" - { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } -#line 552 "stdin2.calc.c" -break; -#line 554 "stdin2.calc.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/stdin2.error b/test/yacc/stdin2.error deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/stdin2.output b/test/yacc/stdin2.output deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/yacc/varsyntax_calc1.error b/test/yacc/varsyntax_calc1.error deleted file mode 100644 index 9c1f7152c30..00000000000 --- a/test/yacc/varsyntax_calc1.error +++ /dev/null @@ -1,2 +0,0 @@ -YACC: 2 rules never reduced -YACC: 18 shift/reduce conflicts, 26 reduce/reduce conflicts. diff --git a/test/yacc/varsyntax_calc1.output b/test/yacc/varsyntax_calc1.output deleted file mode 100644 index 2b628d47ddb..00000000000 --- a/test/yacc/varsyntax_calc1.output +++ /dev/null @@ -1,877 +0,0 @@ - 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/test/yacc/varsyntax_calc1.tab.c b/test/yacc/varsyntax_calc1.tab.c deleted file mode 100644 index c151810d423..00000000000 --- a/test/yacc/varsyntax_calc1.tab.c +++ /dev/null @@ -1,937 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 2 -#define YYMINOR 0 -#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]; - -#ifdef YYSTYPE -#undef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#endif -#ifndef YYSTYPE_IS_DECLARED -#define YYSTYPE_IS_DECLARED 1 -#line 32 "varsyntax_calc1.y" -typedef union YYSTYPE -{ - 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 int 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 - -#if YYDEBUG -int yydebug; -#endif - -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -int yynerrs; - -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif -#endif - -#define YYINITSTACKSIZE 200 - -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; -#line 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 494 "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 - - /* yym is set below */ - /* yyn is set below */ - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag != 0) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; /* redundant goto avoids 'unused label' warning */ -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym > 0) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - - switch (yyn) - { -case 3: -#line 59 "varsyntax_calc1.y" - { - (void) printf("%15.8f\n", yystack.l_mark[-1].dval); - } -#line 698 "varsyntax_calc1.tab.c" -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); - } -#line 705 "varsyntax_calc1.tab.c" -break; -case 5: -#line 67 "varsyntax_calc1.y" - { - dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; - } -#line 712 "varsyntax_calc1.tab.c" -break; -case 6: -#line 71 "varsyntax_calc1.y" - { - vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; - } -#line 719 "varsyntax_calc1.tab.c" -break; -case 7: -#line 75 "varsyntax_calc1.y" - { - yyerrok; - } -#line 726 "varsyntax_calc1.tab.c" -break; -case 9: -#line 82 "varsyntax_calc1.y" - { - yyval.dval = dreg[yystack.l_mark[0].ival]; /* $$ & $1 are sufficient here*/ - } -#line 733 "varsyntax_calc1.tab.c" -break; -case 10: -#line 86 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; - } -#line 740 "varsyntax_calc1.tab.c" -break; -case 11: -#line 90 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; - } -#line 747 "varsyntax_calc1.tab.c" -break; -case 12: -#line 94 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; - } -#line 754 "varsyntax_calc1.tab.c" -break; -case 13: -#line 98 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; - } -#line 761 "varsyntax_calc1.tab.c" -break; -case 14: -#line 102 "varsyntax_calc1.y" - { - yyval.dval = -yystack.l_mark[0].dval; - } -#line 768 "varsyntax_calc1.tab.c" -break; -case 15: -#line 106 "varsyntax_calc1.y" - { - yyval.dval = yystack.l_mark[-1].dval; - } -#line 775 "varsyntax_calc1.tab.c" -break; -case 16: -#line 112 "varsyntax_calc1.y" - { - yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; - } -#line 782 "varsyntax_calc1.tab.c" -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; - } - } -#line 795 "varsyntax_calc1.tab.c" -break; -case 18: -#line 126 "varsyntax_calc1.y" - { - yyval.vval = vreg[yystack.l_mark[0].ival]; - } -#line 802 "varsyntax_calc1.tab.c" -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; - } -#line 810 "varsyntax_calc1.tab.c" -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; - } -#line 818 "varsyntax_calc1.tab.c" -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; - } -#line 826 "varsyntax_calc1.tab.c" -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; - } -#line 834 "varsyntax_calc1.tab.c" -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 ); - } -#line 841 "varsyntax_calc1.tab.c" -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 ); - } -#line 848 "varsyntax_calc1.tab.c" -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 ); - } -#line 856 "varsyntax_calc1.tab.c" -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 ); - } -#line 864 "varsyntax_calc1.tab.c" -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; - } -#line 872 "varsyntax_calc1.tab.c" -break; -case 28: -#line 173 "varsyntax_calc1.y" - { - yyval.vval = yystack.l_mark[-1].vval; - } -#line 879 "varsyntax_calc1.tab.c" -break; -#line 881 "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) - { - yychar = YYLEX; - if (yychar < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/test/yacc/varsyntax_calc1.tab.h b/test/yacc/varsyntax_calc1.tab.h deleted file mode 100644 index 50369b22642..00000000000 --- a/test/yacc/varsyntax_calc1.tab.h +++ /dev/null @@ -1,18 +0,0 @@ -#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 YYSTYPE -{ - 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/yacc.1 b/yacc.1 index afed39ed871..30974ad2460 100644 --- a/yacc.1 +++ b/yacc.1 @@ -1,14 +1,21 @@ -.\" $Id: yacc.1,v 1.42 2022/11/06 17:07:16 tom Exp $ +.\" $Id: yacc.1,v 1.43 2024/01/10 00:30:34 tom Exp $ .\" -.\" .TH YACC 1 "July\ 15,\ 1990" -.\" .UC 6 +.TH YACC 1 2024-01-09 "Berkeley Yacc" "User Commands" +. .ds N Yacc .ds n yacc +. +.ie n .ds CW R +.el \{ +.ie \n(.g .ds CW CR +.el .ds CW CW +.\} +. .de Ex .RS +7 .PP .nf -.ft CW +.ft \*(CW .. .de Ee .fi @@ -16,20 +23,27 @@ .RE .. .\" 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 '' '' +.ie \n(.g \{\ +.ds `` \(lq +.ds '' \(rq +.ds ' \(aq +.\} +.el \{\ +.ie t .ds `` `` +.el .ds `` "" +.ie t .ds '' '' +.el .ds '' "" +.ie t .ds ' \(aq +.el .ds ' ' +.\}", .\" Bulleted paragraph .de bP .ie n .IP \(bu 4 .el .IP \(bu 2 .. -.TH YACC 1 "November 6, 2022" "Berkeley Yacc" "User Commands" .SH NAME -\*N \- an LALR(1) parser generator +\*N \- +an LALR(1) parser generator .SH SYNOPSIS .B \*n [ \-BdghilLPrtvVy ] [ \-b .I file_prefix @@ -208,6 +222,13 @@ However, \fB\*n\fP accepts a single \*(``\-\*('' to read the grammar from the standard input. A double \*(``\-\-\*('' marker denotes the end of options. A single \fIfilename\fP parameter is expected after a \*(``\-\-\*('' marker. +. +.SH DIAGNOSTICS +If there are rules that are never reduced, the number of such rules is +reported on standard error. +If there are any LALR(1) conflicts, the number of conflicts is reported +on standard error. + .SH EXTENSIONS .B \*N provides some extensions for @@ -357,6 +378,7 @@ However, .B \*n does not predefine \*(``$end\*('', \*(``$error\*('' or \*(``$undefined\*('' in this array. +. .SH PORTABILITY According to Robert Corbett, .Ex @@ -420,8 +442,9 @@ Bison puts the additional parameters \fIfirst\fP for \fByyparse\fP and \fByyerror\fP but \fIlast\fP for destructors. \fBYacc\fP matches this behavior. . -.SH DIAGNOSTICS -If there are rules that are never reduced, the number of such rules is -reported on standard error. -If there are any LALR(1) conflicts, the number of conflicts is reported -on standard error. +.SH SEE ALSO +\fBbison\fP(1), +\fBbtyacc\fP(1), +\fBlex\fP(1), +\fBflex\fP(1), +\fByacc\fP(1) From 85a764b2c52b853993b20c6291983a1aac223f47 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 20 Jun 2024 13:48:44 +0200 Subject: [PATCH 3/3] byacc: readd tests in the import --- test/README | 4 + test/btyacc/big_b.error | 30 + test/btyacc/big_b.output | 0 test/btyacc/big_l.error | 30 + test/btyacc/big_l.output | 0 test/btyacc/btyacc_calc1.error | 1 + test/btyacc/btyacc_calc1.output | 949 ++++++++ test/btyacc/btyacc_calc1.tab.c | 1803 +++++++++++++++ test/btyacc/btyacc_calc1.tab.h | 22 + test/btyacc/btyacc_demo.error | 1 + test/btyacc/btyacc_demo.output | 1298 +++++++++++ test/btyacc/btyacc_demo.tab.c | 2400 ++++++++++++++++++++ test/btyacc/btyacc_demo.tab.h | 51 + test/btyacc/btyacc_destroy1.error | 0 test/btyacc/btyacc_destroy1.output | 247 ++ test/btyacc/btyacc_destroy1.tab.c | 1477 ++++++++++++ test/btyacc/btyacc_destroy1.tab.h | 25 + test/btyacc/btyacc_destroy2.error | 0 test/btyacc/btyacc_destroy2.output | 247 ++ test/btyacc/btyacc_destroy2.tab.c | 1477 ++++++++++++ test/btyacc/btyacc_destroy2.tab.h | 25 + test/btyacc/btyacc_destroy3.error | 0 test/btyacc/btyacc_destroy3.output | 247 ++ test/btyacc/btyacc_destroy3.tab.c | 1477 ++++++++++++ test/btyacc/btyacc_destroy3.tab.h | 25 + test/btyacc/calc.error | 0 test/btyacc/calc.output | 485 ++++ test/btyacc/calc.tab.c | 1489 ++++++++++++ test/btyacc/calc.tab.h | 8 + test/btyacc/calc1.error | 2 + test/btyacc/calc1.output | 900 ++++++++ test/btyacc/calc1.tab.c | 1746 ++++++++++++++ test/btyacc/calc1.tab.h | 23 + test/btyacc/calc2.error | 0 test/btyacc/calc2.output | 485 ++++ test/btyacc/calc2.tab.c | 1502 ++++++++++++ test/btyacc/calc2.tab.h | 8 + test/btyacc/calc3.error | 0 test/btyacc/calc3.output | 485 ++++ test/btyacc/calc3.tab.c | 1516 +++++++++++++ test/btyacc/calc3.tab.h | 8 + test/btyacc/calc_code_all.error | 0 test/btyacc/calc_code_all.output | 485 ++++ test/btyacc/calc_code_all.tab.c | 1517 +++++++++++++ test/btyacc/calc_code_all.tab.h | 18 + test/btyacc/calc_code_default.error | 0 test/btyacc/calc_code_default.output | 485 ++++ test/btyacc/calc_code_default.tab.c | 1497 ++++++++++++ test/btyacc/calc_code_default.tab.h | 8 + test/btyacc/calc_code_imports.error | 0 test/btyacc/calc_code_imports.output | 485 ++++ test/btyacc/calc_code_imports.tab.c | 1489 ++++++++++++ test/btyacc/calc_code_imports.tab.h | 8 + test/btyacc/calc_code_provides.error | 0 test/btyacc/calc_code_provides.output | 485 ++++ test/btyacc/calc_code_provides.tab.c | 1497 ++++++++++++ test/btyacc/calc_code_provides.tab.h | 14 + test/btyacc/calc_code_requires.error | 0 test/btyacc/calc_code_requires.output | 485 ++++ test/btyacc/calc_code_requires.tab.c | 1497 ++++++++++++ test/btyacc/calc_code_requires.tab.h | 14 + test/btyacc/calc_code_top.error | 0 test/btyacc/calc_code_top.output | 485 ++++ test/btyacc/calc_code_top.tab.c | 1497 ++++++++++++ test/btyacc/calc_code_top.tab.h | 8 + test/btyacc/code_calc.code.c | 1362 +++++++++++ test/btyacc/code_calc.error | 0 test/btyacc/code_calc.output | 485 ++++ test/btyacc/code_calc.tab.c | 165 ++ test/btyacc/code_calc.tab.h | 10 + test/btyacc/code_error.code.c | 1256 +++++++++++ test/btyacc/code_error.error | 0 test/btyacc/code_error.output | 34 + test/btyacc/code_error.tab.c | 61 + test/btyacc/code_error.tab.h | 5 + test/btyacc/defines1.calc.c | 1396 ++++++++++++ test/btyacc/defines1.calc.h | 8 + test/btyacc/defines1.error | 0 test/btyacc/defines1.output | 0 test/btyacc/defines2.calc.c | 1396 ++++++++++++ test/btyacc/defines2.calc.h | 8 + test/btyacc/defines2.error | 0 test/btyacc/defines2.output | 0 test/btyacc/defines3.calc.c | 1396 ++++++++++++ test/btyacc/defines3.calc.h | 8 + test/btyacc/defines3.error | 0 test/btyacc/defines3.output | 0 test/btyacc/empty.error | 0 test/btyacc/empty.output | 28 + test/btyacc/empty.tab.c | 1275 +++++++++++ test/btyacc/empty.tab.h | 5 + test/btyacc/err_inherit1.error | 3 + test/btyacc/err_inherit1.output | 0 test/btyacc/err_inherit1.tab.c | 15 + test/btyacc/err_inherit1.tab.h | 0 test/btyacc/err_inherit2.error | 5 + test/btyacc/err_inherit2.output | 0 test/btyacc/err_inherit2.tab.c | 15 + test/btyacc/err_inherit2.tab.h | 0 test/btyacc/err_inherit3.error | 23 + test/btyacc/err_inherit3.output | 216 ++ test/btyacc/err_inherit3.tab.c | 1445 ++++++++++++ test/btyacc/err_inherit3.tab.h | 25 + test/btyacc/err_inherit4.error | 13 + test/btyacc/err_inherit4.output | 165 ++ test/btyacc/err_inherit4.tab.c | 1433 ++++++++++++ test/btyacc/err_inherit4.tab.h | 40 + test/btyacc/err_inherit5.error | 1 + test/btyacc/err_inherit5.output | 0 test/btyacc/err_inherit5.tab.c | 15 + test/btyacc/err_inherit5.tab.h | 0 test/btyacc/err_syntax1.error | 3 + test/btyacc/err_syntax1.output | 0 test/btyacc/err_syntax1.tab.c | 15 + test/btyacc/err_syntax1.tab.h | 0 test/btyacc/err_syntax10.error | 3 + test/btyacc/err_syntax10.output | 37 + test/btyacc/err_syntax10.tab.c | 1274 +++++++++++ test/btyacc/err_syntax10.tab.h | 5 + test/btyacc/err_syntax11.error | 1 + test/btyacc/err_syntax11.output | 35 + test/btyacc/err_syntax11.tab.c | 1280 +++++++++++ test/btyacc/err_syntax11.tab.h | 5 + test/btyacc/err_syntax12.error | 1 + test/btyacc/err_syntax12.output | 35 + test/btyacc/err_syntax12.tab.c | 1286 +++++++++++ test/btyacc/err_syntax12.tab.h | 6 + test/btyacc/err_syntax13.error | 1 + test/btyacc/err_syntax13.output | 0 test/btyacc/err_syntax13.tab.c | 15 + test/btyacc/err_syntax13.tab.h | 0 test/btyacc/err_syntax14.error | 2 + test/btyacc/err_syntax14.output | 0 test/btyacc/err_syntax14.tab.c | 15 + test/btyacc/err_syntax14.tab.h | 0 test/btyacc/err_syntax15.error | 1 + test/btyacc/err_syntax15.output | 0 test/btyacc/err_syntax15.tab.c | 15 + test/btyacc/err_syntax15.tab.h | 0 test/btyacc/err_syntax16.error | 1 + test/btyacc/err_syntax16.output | 0 test/btyacc/err_syntax16.tab.c | 15 + test/btyacc/err_syntax16.tab.h | 0 test/btyacc/err_syntax17.error | 3 + test/btyacc/err_syntax17.output | 0 test/btyacc/err_syntax17.tab.c | 15 + test/btyacc/err_syntax17.tab.h | 0 test/btyacc/err_syntax18.error | 1 + test/btyacc/err_syntax18.output | 52 + test/btyacc/err_syntax18.tab.c | 1289 +++++++++++ test/btyacc/err_syntax18.tab.h | 5 + test/btyacc/err_syntax19.error | 3 + test/btyacc/err_syntax19.output | 0 test/btyacc/err_syntax19.tab.c | 15 + test/btyacc/err_syntax19.tab.h | 0 test/btyacc/err_syntax2.error | 3 + test/btyacc/err_syntax2.output | 0 test/btyacc/err_syntax2.tab.c | 15 + test/btyacc/err_syntax2.tab.h | 0 test/btyacc/err_syntax20.error | 1 + test/btyacc/err_syntax20.output | 51 + test/btyacc/err_syntax20.tab.c | 1284 +++++++++++ test/btyacc/err_syntax20.tab.h | 6 + test/btyacc/err_syntax21.error | 1 + test/btyacc/err_syntax21.output | 0 test/btyacc/err_syntax21.tab.c | 15 + test/btyacc/err_syntax21.tab.h | 0 test/btyacc/err_syntax22.error | 1 + test/btyacc/err_syntax22.output | 0 test/btyacc/err_syntax22.tab.c | 15 + test/btyacc/err_syntax22.tab.h | 0 test/btyacc/err_syntax23.error | 1 + test/btyacc/err_syntax23.output | 0 test/btyacc/err_syntax23.tab.c | 15 + test/btyacc/err_syntax23.tab.h | 0 test/btyacc/err_syntax24.error | 2 + test/btyacc/err_syntax24.output | 0 test/btyacc/err_syntax24.tab.c | 15 + test/btyacc/err_syntax24.tab.h | 0 test/btyacc/err_syntax25.error | 3 + test/btyacc/err_syntax25.output | 0 test/btyacc/err_syntax25.tab.c | 15 + test/btyacc/err_syntax25.tab.h | 0 test/btyacc/err_syntax26.error | 1 + test/btyacc/err_syntax26.output | 0 test/btyacc/err_syntax26.tab.c | 15 + test/btyacc/err_syntax26.tab.h | 0 test/btyacc/err_syntax27.error | 1 + test/btyacc/err_syntax27.output | 0 test/btyacc/err_syntax27.tab.c | 15 + test/btyacc/err_syntax27.tab.h | 0 test/btyacc/err_syntax3.error | 3 + test/btyacc/err_syntax3.output | 0 test/btyacc/err_syntax3.tab.c | 15 + test/btyacc/err_syntax3.tab.h | 0 test/btyacc/err_syntax4.error | 3 + test/btyacc/err_syntax4.output | 0 test/btyacc/err_syntax4.tab.c | 15 + test/btyacc/err_syntax4.tab.h | 0 test/btyacc/err_syntax5.error | 3 + test/btyacc/err_syntax5.output | 0 test/btyacc/err_syntax5.tab.c | 15 + test/btyacc/err_syntax5.tab.h | 0 test/btyacc/err_syntax6.error | 3 + test/btyacc/err_syntax6.output | 0 test/btyacc/err_syntax6.tab.c | 15 + test/btyacc/err_syntax6.tab.h | 0 test/btyacc/err_syntax7.error | 3 + test/btyacc/err_syntax7.output | 0 test/btyacc/err_syntax7.tab.c | 15 + test/btyacc/err_syntax7.tab.h | 0 test/btyacc/err_syntax7a.error | 3 + test/btyacc/err_syntax7a.output | 0 test/btyacc/err_syntax7a.tab.c | 15 + test/btyacc/err_syntax7a.tab.h | 0 test/btyacc/err_syntax7b.error | 3 + test/btyacc/err_syntax7b.output | 0 test/btyacc/err_syntax7b.tab.c | 15 + test/btyacc/err_syntax7b.tab.h | 0 test/btyacc/err_syntax8.error | 1 + test/btyacc/err_syntax8.output | 0 test/btyacc/err_syntax8.tab.c | 15 + test/btyacc/err_syntax8.tab.h | 0 test/btyacc/err_syntax8a.error | 1 + test/btyacc/err_syntax8a.output | 0 test/btyacc/err_syntax8a.tab.c | 15 + test/btyacc/err_syntax8a.tab.h | 0 test/btyacc/err_syntax9.error | 1 + test/btyacc/err_syntax9.output | 0 test/btyacc/err_syntax9.tab.c | 15 + test/btyacc/err_syntax9.tab.h | 0 test/btyacc/error.error | 0 test/btyacc/error.output | 34 + test/btyacc/error.tab.c | 1279 +++++++++++ test/btyacc/error.tab.h | 5 + test/btyacc/expr.oxout.error | 1 + test/btyacc/expr.oxout.output | 227 ++ test/btyacc/expr.oxout.tab.c | 2768 +++++++++++++++++++++++ test/btyacc/expr.oxout.tab.h | 20 + test/btyacc/grammar.dot | 906 ++++++++ test/btyacc/grammar.error | 1 + test/btyacc/grammar.output | 2304 +++++++++++++++++++ test/btyacc/grammar.tab.c | 3010 +++++++++++++++++++++++++ test/btyacc/grammar.tab.h | 40 + test/btyacc/help.error | 31 + test/btyacc/help.output | 0 test/btyacc/inherit0.error | 0 test/btyacc/inherit0.output | 165 ++ test/btyacc/inherit0.tab.c | 1354 +++++++++++ test/btyacc/inherit0.tab.h | 10 + test/btyacc/inherit1.error | 0 test/btyacc/inherit1.output | 165 ++ test/btyacc/inherit1.tab.c | 1379 +++++++++++ test/btyacc/inherit1.tab.h | 25 + test/btyacc/inherit2.error | 0 test/btyacc/inherit2.output | 186 ++ test/btyacc/inherit2.tab.c | 1439 ++++++++++++ test/btyacc/inherit2.tab.h | 25 + test/btyacc/no_b_opt.error | 31 + test/btyacc/no_b_opt.output | 0 test/btyacc/no_b_opt1.error | 1 + test/btyacc/no_b_opt1.output | 0 test/btyacc/no_code_c.error | 1 + test/btyacc/no_code_c.output | 0 test/btyacc/no_defines.error | 1 + test/btyacc/no_defines.output | 0 test/btyacc/no_graph.error | 1 + test/btyacc/no_graph.output | 0 test/btyacc/no_include.error | 1 + test/btyacc/no_include.output | 0 test/btyacc/no_opts.error | 1 + test/btyacc/no_opts.output | 0 test/btyacc/no_output.error | 1 + test/btyacc/no_output.output | 0 test/btyacc/no_output1.error | 1 + test/btyacc/no_output1.output | 0 test/btyacc/no_output2.error | 31 + test/btyacc/no_output2.output | 0 test/btyacc/no_p_opt.error | 31 + test/btyacc/no_p_opt.output | 0 test/btyacc/no_p_opt1.error | 1 + test/btyacc/no_p_opt1.output | 0 test/btyacc/no_verbose.error | 1 + test/btyacc/no_verbose.output | 0 test/btyacc/nostdin.error | 30 + test/btyacc/nostdin.output | 0 test/btyacc/ok_syntax1.error | 0 test/btyacc/ok_syntax1.output | 511 +++++ test/btyacc/ok_syntax1.tab.c | 1539 +++++++++++++ test/btyacc/ok_syntax1.tab.h | 34 + test/btyacc/pure_calc.error | 0 test/btyacc/pure_calc.output | 485 ++++ test/btyacc/pure_calc.tab.c | 1512 +++++++++++++ test/btyacc/pure_calc.tab.h | 8 + test/btyacc/pure_error.error | 0 test/btyacc/pure_error.output | 34 + test/btyacc/pure_error.tab.c | 1304 +++++++++++ test/btyacc/pure_error.tab.h | 5 + test/btyacc/quote_calc-s.error | 1 + test/btyacc/quote_calc-s.output | 593 +++++ test/btyacc/quote_calc-s.tab.c | 1507 +++++++++++++ test/btyacc/quote_calc-s.tab.h | 14 + test/btyacc/quote_calc.error | 1 + test/btyacc/quote_calc.output | 593 +++++ test/btyacc/quote_calc.tab.c | 1513 +++++++++++++ test/btyacc/quote_calc.tab.h | 20 + test/btyacc/quote_calc2-s.error | 1 + test/btyacc/quote_calc2-s.output | 593 +++++ test/btyacc/quote_calc2-s.tab.c | 1507 +++++++++++++ test/btyacc/quote_calc2-s.tab.h | 14 + test/btyacc/quote_calc2.error | 1 + test/btyacc/quote_calc2.output | 593 +++++ test/btyacc/quote_calc2.tab.c | 1513 +++++++++++++ test/btyacc/quote_calc2.tab.h | 20 + test/btyacc/quote_calc3-s.error | 1 + test/btyacc/quote_calc3-s.output | 593 +++++ test/btyacc/quote_calc3-s.tab.c | 1508 +++++++++++++ test/btyacc/quote_calc3-s.tab.h | 14 + test/btyacc/quote_calc3.error | 1 + test/btyacc/quote_calc3.output | 593 +++++ test/btyacc/quote_calc3.tab.c | 1508 +++++++++++++ test/btyacc/quote_calc3.tab.h | 14 + test/btyacc/quote_calc4-s.error | 1 + test/btyacc/quote_calc4-s.output | 593 +++++ test/btyacc/quote_calc4-s.tab.c | 1508 +++++++++++++ test/btyacc/quote_calc4-s.tab.h | 14 + test/btyacc/quote_calc4.error | 1 + test/btyacc/quote_calc4.output | 593 +++++ test/btyacc/quote_calc4.tab.c | 1508 +++++++++++++ test/btyacc/quote_calc4.tab.h | 14 + test/btyacc/rename_debug.c | 1142 ++++++++++ test/btyacc/rename_debug.error | 0 test/btyacc/rename_debug.h | 6 + test/btyacc/rename_debug.i | 71 + test/btyacc/rename_debug.output | 34 + test/btyacc/stdin1.calc.c | 1396 ++++++++++++ test/btyacc/stdin1.error | 0 test/btyacc/stdin1.output | 0 test/btyacc/stdin2.calc.c | 1396 ++++++++++++ test/btyacc/stdin2.error | 0 test/btyacc/stdin2.output | 0 test/btyacc/varsyntax_calc1.error | 2 + test/btyacc/varsyntax_calc1.output | 900 ++++++++ test/btyacc/varsyntax_calc1.tab.c | 1747 ++++++++++++++ test/btyacc/varsyntax_calc1.tab.h | 23 + test/btyacc_calc1.y | 324 +++ test/btyacc_demo.y | 226 ++ test/btyacc_destroy1.y | 91 + test/btyacc_destroy2.y | 91 + test/btyacc_destroy3.y | 94 + test/calc.y | 106 + test/calc1.y | 305 +++ test/calc2.y | 124 + test/calc3.y | 127 ++ test/calc_code_all.y | 113 + test/calc_code_default.y | 109 + test/calc_code_imports.y | 109 + test/calc_code_provides.y | 109 + test/calc_code_requires.y | 109 + test/calc_code_top.y | 109 + test/code_calc.y | 114 + test/code_debug.y | 36 + test/code_error.y | 36 + test/empty.y | 24 + test/err_inherit1.y | 64 + test/err_inherit2.y | 80 + test/err_inherit3.y | 80 + test/err_inherit4.y | 82 + test/err_inherit5.y | 80 + test/err_syntax1.y | 28 + test/err_syntax10.y | 32 + test/err_syntax11.y | 32 + test/err_syntax12.y | 32 + test/err_syntax13.y | 32 + test/err_syntax14.y | 32 + test/err_syntax15.y | 32 + test/err_syntax16.y | 40 + test/err_syntax17.y | 30 + test/err_syntax18.y | 33 + test/err_syntax19.y | 33 + test/err_syntax2.y | 28 + test/err_syntax20.y | 36 + test/err_syntax21.y | 36 + test/err_syntax22.y | 44 + test/err_syntax23.y | 46 + test/err_syntax24.y | 46 + test/err_syntax25.y | 51 + test/err_syntax26.y | 6 + test/err_syntax27.y | 127 ++ test/err_syntax3.y | 31 + test/err_syntax4.y | 28 + test/err_syntax5.y | 33 + test/err_syntax6.y | 31 + test/err_syntax7.y | 31 + test/err_syntax7a.y | 31 + test/err_syntax7b.y | 31 + test/err_syntax8.y | 31 + test/err_syntax8a.y | 31 + test/err_syntax9.y | 32 + test/error.y | 28 + test/expr.oxout.h | 90 + test/expr.oxout.y | 1446 ++++++++++++ test/grammar.y | 1184 ++++++++++ test/inherit0.y | 48 + test/inherit1.y | 76 + test/inherit2.y | 80 + test/ok_syntax1.y | 155 ++ test/pure_calc.y | 116 + test/pure_error.y | 41 + test/quote_calc.y | 112 + test/quote_calc2.y | 112 + test/quote_calc3.y | 112 + test/quote_calc4.y | 112 + test/run_lint.sh | 29 + test/run_make.sh | 196 ++ test/run_test.sh | 311 +++ test/varsyntax_calc1.y | 307 +++ test/yacc/big_b.error | 31 + test/yacc/big_b.output | 0 test/yacc/big_l.error | 31 + test/yacc/big_l.output | 0 test/yacc/calc.error | 0 test/yacc/calc.output | 461 ++++ test/yacc/calc.tab.c | 686 ++++++ test/yacc/calc.tab.h | 3 + test/yacc/calc1.error | 2 + test/yacc/calc1.output | 877 +++++++ test/yacc/calc1.tab.c | 936 ++++++++ test/yacc/calc1.tab.h | 18 + test/yacc/calc2.error | 0 test/yacc/calc2.output | 461 ++++ test/yacc/calc2.tab.c | 699 ++++++ test/yacc/calc2.tab.h | 3 + test/yacc/calc3.error | 0 test/yacc/calc3.output | 461 ++++ test/yacc/calc3.tab.c | 707 ++++++ test/yacc/calc3.tab.h | 3 + test/yacc/calc_code_all.error | 0 test/yacc/calc_code_all.output | 461 ++++ test/yacc/calc_code_all.tab.c | 714 ++++++ test/yacc/calc_code_all.tab.h | 13 + test/yacc/calc_code_default.error | 0 test/yacc/calc_code_default.output | 461 ++++ test/yacc/calc_code_default.tab.c | 694 ++++++ test/yacc/calc_code_default.tab.h | 3 + test/yacc/calc_code_imports.error | 0 test/yacc/calc_code_imports.output | 461 ++++ test/yacc/calc_code_imports.tab.c | 686 ++++++ test/yacc/calc_code_imports.tab.h | 3 + test/yacc/calc_code_provides.error | 0 test/yacc/calc_code_provides.output | 461 ++++ test/yacc/calc_code_provides.tab.c | 694 ++++++ test/yacc/calc_code_provides.tab.h | 9 + test/yacc/calc_code_requires.error | 0 test/yacc/calc_code_requires.output | 461 ++++ test/yacc/calc_code_requires.tab.c | 694 ++++++ test/yacc/calc_code_requires.tab.h | 9 + test/yacc/calc_code_top.error | 0 test/yacc/calc_code_top.output | 461 ++++ test/yacc/calc_code_top.tab.c | 694 ++++++ test/yacc/calc_code_top.tab.h | 3 + test/yacc/code_calc.code.c | 595 +++++ test/yacc/code_calc.error | 0 test/yacc/code_calc.output | 461 ++++ test/yacc/code_calc.tab.c | 119 + test/yacc/code_calc.tab.h | 5 + test/yacc/code_error.code.c | 489 ++++ test/yacc/code_error.error | 0 test/yacc/code_error.output | 27 + test/yacc/code_error.tab.c | 44 + test/yacc/code_error.tab.h | 0 test/yacc/defines1.calc.c | 610 +++++ test/yacc/defines1.calc.h | 3 + test/yacc/defines1.error | 0 test/yacc/defines1.output | 0 test/yacc/defines2.calc.c | 610 +++++ test/yacc/defines2.calc.h | 3 + test/yacc/defines2.error | 0 test/yacc/defines2.output | 0 test/yacc/defines3.calc.c | 610 +++++ test/yacc/defines3.calc.h | 3 + test/yacc/defines3.error | 0 test/yacc/defines3.output | 0 test/yacc/empty.error | 0 test/yacc/empty.output | 21 + test/yacc/empty.tab.c | 500 ++++ test/yacc/empty.tab.h | 0 test/yacc/err_syntax1.error | 3 + test/yacc/err_syntax1.output | 0 test/yacc/err_syntax1.tab.c | 15 + test/yacc/err_syntax1.tab.h | 0 test/yacc/err_syntax10.error | 3 + test/yacc/err_syntax10.output | 27 + test/yacc/err_syntax10.tab.c | 499 ++++ test/yacc/err_syntax10.tab.h | 0 test/yacc/err_syntax11.error | 1 + test/yacc/err_syntax11.output | 27 + test/yacc/err_syntax11.tab.c | 505 +++++ test/yacc/err_syntax11.tab.h | 0 test/yacc/err_syntax12.error | 1 + test/yacc/err_syntax12.output | 27 + test/yacc/err_syntax12.tab.c | 511 +++++ test/yacc/err_syntax12.tab.h | 1 + test/yacc/err_syntax13.error | 1 + test/yacc/err_syntax13.output | 0 test/yacc/err_syntax13.tab.c | 15 + test/yacc/err_syntax13.tab.h | 0 test/yacc/err_syntax14.error | 2 + test/yacc/err_syntax14.output | 0 test/yacc/err_syntax14.tab.c | 15 + test/yacc/err_syntax14.tab.h | 0 test/yacc/err_syntax15.error | 1 + test/yacc/err_syntax15.output | 0 test/yacc/err_syntax15.tab.c | 15 + test/yacc/err_syntax15.tab.h | 0 test/yacc/err_syntax16.error | 1 + test/yacc/err_syntax16.output | 0 test/yacc/err_syntax16.tab.c | 15 + test/yacc/err_syntax16.tab.h | 0 test/yacc/err_syntax17.error | 3 + test/yacc/err_syntax17.output | 0 test/yacc/err_syntax17.tab.c | 15 + test/yacc/err_syntax17.tab.h | 0 test/yacc/err_syntax18.error | 1 + test/yacc/err_syntax18.output | 43 + test/yacc/err_syntax18.tab.c | 513 +++++ test/yacc/err_syntax18.tab.h | 0 test/yacc/err_syntax19.error | 3 + test/yacc/err_syntax19.output | 0 test/yacc/err_syntax19.tab.c | 15 + test/yacc/err_syntax19.tab.h | 0 test/yacc/err_syntax2.error | 3 + test/yacc/err_syntax2.output | 0 test/yacc/err_syntax2.tab.c | 15 + test/yacc/err_syntax2.tab.h | 0 test/yacc/err_syntax20.error | 1 + test/yacc/err_syntax20.output | 41 + test/yacc/err_syntax20.tab.c | 509 +++++ test/yacc/err_syntax20.tab.h | 1 + test/yacc/err_syntax21.error | 1 + test/yacc/err_syntax21.output | 0 test/yacc/err_syntax21.tab.c | 15 + test/yacc/err_syntax21.tab.h | 0 test/yacc/err_syntax22.error | 1 + test/yacc/err_syntax22.output | 0 test/yacc/err_syntax22.tab.c | 15 + test/yacc/err_syntax22.tab.h | 0 test/yacc/err_syntax23.error | 1 + test/yacc/err_syntax23.output | 0 test/yacc/err_syntax23.tab.c | 15 + test/yacc/err_syntax23.tab.h | 0 test/yacc/err_syntax24.error | 2 + test/yacc/err_syntax24.output | 0 test/yacc/err_syntax24.tab.c | 15 + test/yacc/err_syntax24.tab.h | 0 test/yacc/err_syntax25.error | 3 + test/yacc/err_syntax25.output | 0 test/yacc/err_syntax25.tab.c | 15 + test/yacc/err_syntax25.tab.h | 0 test/yacc/err_syntax26.error | 1 + test/yacc/err_syntax26.output | 0 test/yacc/err_syntax26.tab.c | 15 + test/yacc/err_syntax26.tab.h | 0 test/yacc/err_syntax27.error | 1 + test/yacc/err_syntax27.output | 0 test/yacc/err_syntax27.tab.c | 15 + test/yacc/err_syntax27.tab.h | 0 test/yacc/err_syntax3.error | 3 + test/yacc/err_syntax3.output | 0 test/yacc/err_syntax3.tab.c | 15 + test/yacc/err_syntax3.tab.h | 0 test/yacc/err_syntax4.error | 3 + test/yacc/err_syntax4.output | 0 test/yacc/err_syntax4.tab.c | 15 + test/yacc/err_syntax4.tab.h | 0 test/yacc/err_syntax5.error | 3 + test/yacc/err_syntax5.output | 0 test/yacc/err_syntax5.tab.c | 15 + test/yacc/err_syntax5.tab.h | 0 test/yacc/err_syntax6.error | 3 + test/yacc/err_syntax6.output | 0 test/yacc/err_syntax6.tab.c | 15 + test/yacc/err_syntax6.tab.h | 0 test/yacc/err_syntax7.error | 3 + test/yacc/err_syntax7.output | 0 test/yacc/err_syntax7.tab.c | 15 + test/yacc/err_syntax7.tab.h | 0 test/yacc/err_syntax7a.error | 3 + test/yacc/err_syntax7a.output | 0 test/yacc/err_syntax7a.tab.c | 15 + test/yacc/err_syntax7a.tab.h | 0 test/yacc/err_syntax7b.error | 3 + test/yacc/err_syntax7b.output | 0 test/yacc/err_syntax7b.tab.c | 15 + test/yacc/err_syntax7b.tab.h | 0 test/yacc/err_syntax8.error | 1 + test/yacc/err_syntax8.output | 0 test/yacc/err_syntax8.tab.c | 15 + test/yacc/err_syntax8.tab.h | 0 test/yacc/err_syntax8a.error | 1 + test/yacc/err_syntax8a.output | 0 test/yacc/err_syntax8a.tab.c | 15 + test/yacc/err_syntax8a.tab.h | 0 test/yacc/err_syntax9.error | 1 + test/yacc/err_syntax9.output | 0 test/yacc/err_syntax9.tab.c | 15 + test/yacc/err_syntax9.tab.h | 0 test/yacc/error.error | 0 test/yacc/error.output | 27 + test/yacc/error.tab.c | 505 +++++ test/yacc/error.tab.h | 0 test/yacc/expr.oxout.error | 1 + test/yacc/expr.oxout.output | 209 ++ test/yacc/expr.oxout.tab.c | 1970 ++++++++++++++++ test/yacc/expr.oxout.tab.h | 15 + test/yacc/grammar.dot | 906 ++++++++ test/yacc/grammar.error | 1 + test/yacc/grammar.output | 2214 ++++++++++++++++++ test/yacc/grammar.tab.c | 2106 +++++++++++++++++ test/yacc/grammar.tab.h | 35 + test/yacc/help.error | 31 + test/yacc/help.output | 0 test/yacc/no_b_opt.error | 31 + test/yacc/no_b_opt.output | 0 test/yacc/no_b_opt1.error | 1 + test/yacc/no_b_opt1.output | 0 test/yacc/no_code_c.error | 1 + test/yacc/no_code_c.output | 0 test/yacc/no_defines.error | 1 + test/yacc/no_defines.output | 0 test/yacc/no_graph.error | 1 + test/yacc/no_graph.output | 0 test/yacc/no_include.error | 1 + test/yacc/no_include.output | 0 test/yacc/no_opts.error | 1 + test/yacc/no_opts.output | 0 test/yacc/no_output.error | 1 + test/yacc/no_output.output | 0 test/yacc/no_output1.error | 1 + test/yacc/no_output1.output | 0 test/yacc/no_output2.error | 31 + test/yacc/no_output2.output | 0 test/yacc/no_p_opt.error | 31 + test/yacc/no_p_opt.output | 0 test/yacc/no_p_opt1.error | 1 + test/yacc/no_p_opt1.output | 0 test/yacc/no_verbose.error | 1 + test/yacc/no_verbose.output | 0 test/yacc/nostdin.error | 30 + test/yacc/nostdin.output | 0 test/yacc/ok_syntax1.error | 0 test/yacc/ok_syntax1.output | 461 ++++ test/yacc/ok_syntax1.tab.c | 731 ++++++ test/yacc/ok_syntax1.tab.h | 29 + test/yacc/pure_calc.error | 0 test/yacc/pure_calc.output | 461 ++++ test/yacc/pure_calc.tab.c | 703 ++++++ test/yacc/pure_calc.tab.h | 3 + test/yacc/pure_error.error | 0 test/yacc/pure_error.output | 27 + test/yacc/pure_error.tab.c | 524 +++++ test/yacc/pure_error.tab.h | 0 test/yacc/quote_calc-s.error | 1 + test/yacc/quote_calc-s.output | 557 +++++ test/yacc/quote_calc-s.tab.c | 701 ++++++ test/yacc/quote_calc-s.tab.h | 9 + test/yacc/quote_calc.error | 1 + test/yacc/quote_calc.output | 557 +++++ test/yacc/quote_calc.tab.c | 707 ++++++ test/yacc/quote_calc.tab.h | 15 + test/yacc/quote_calc2-s.error | 1 + test/yacc/quote_calc2-s.output | 557 +++++ test/yacc/quote_calc2-s.tab.c | 701 ++++++ test/yacc/quote_calc2-s.tab.h | 9 + test/yacc/quote_calc2.error | 1 + test/yacc/quote_calc2.output | 557 +++++ test/yacc/quote_calc2.tab.c | 707 ++++++ test/yacc/quote_calc2.tab.h | 15 + test/yacc/quote_calc3-s.error | 1 + test/yacc/quote_calc3-s.output | 557 +++++ test/yacc/quote_calc3-s.tab.c | 702 ++++++ test/yacc/quote_calc3-s.tab.h | 9 + test/yacc/quote_calc3.error | 1 + test/yacc/quote_calc3.output | 557 +++++ test/yacc/quote_calc3.tab.c | 702 ++++++ test/yacc/quote_calc3.tab.h | 9 + test/yacc/quote_calc4-s.error | 1 + test/yacc/quote_calc4-s.output | 557 +++++ test/yacc/quote_calc4-s.tab.c | 702 ++++++ test/yacc/quote_calc4-s.tab.h | 9 + test/yacc/quote_calc4.error | 1 + test/yacc/quote_calc4.output | 557 +++++ test/yacc/quote_calc4.tab.c | 702 ++++++ test/yacc/quote_calc4.tab.h | 9 + test/yacc/rename_debug.c | 385 ++++ test/yacc/rename_debug.error | 0 test/yacc/rename_debug.h | 1 + test/yacc/rename_debug.i | 66 + test/yacc/rename_debug.output | 27 + test/yacc/stdin1.calc.c | 610 +++++ test/yacc/stdin1.error | 0 test/yacc/stdin1.output | 0 test/yacc/stdin2.calc.c | 610 +++++ test/yacc/stdin2.error | 0 test/yacc/stdin2.output | 0 test/yacc/varsyntax_calc1.error | 2 + test/yacc/varsyntax_calc1.output | 877 +++++++ test/yacc/varsyntax_calc1.tab.c | 937 ++++++++ test/yacc/varsyntax_calc1.tab.h | 18 + 709 files changed, 149244 insertions(+) create mode 100644 test/README create mode 100644 test/btyacc/big_b.error create mode 100644 test/btyacc/big_b.output create mode 100644 test/btyacc/big_l.error create mode 100644 test/btyacc/big_l.output create mode 100644 test/btyacc/btyacc_calc1.error create mode 100644 test/btyacc/btyacc_calc1.output create mode 100644 test/btyacc/btyacc_calc1.tab.c create mode 100644 test/btyacc/btyacc_calc1.tab.h create mode 100644 test/btyacc/btyacc_demo.error create mode 100644 test/btyacc/btyacc_demo.output create mode 100644 test/btyacc/btyacc_demo.tab.c create mode 100644 test/btyacc/btyacc_demo.tab.h create mode 100644 test/btyacc/btyacc_destroy1.error create mode 100644 test/btyacc/btyacc_destroy1.output create mode 100644 test/btyacc/btyacc_destroy1.tab.c create mode 100644 test/btyacc/btyacc_destroy1.tab.h create mode 100644 test/btyacc/btyacc_destroy2.error create mode 100644 test/btyacc/btyacc_destroy2.output create mode 100644 test/btyacc/btyacc_destroy2.tab.c create mode 100644 test/btyacc/btyacc_destroy2.tab.h create mode 100644 test/btyacc/btyacc_destroy3.error create mode 100644 test/btyacc/btyacc_destroy3.output create mode 100644 test/btyacc/btyacc_destroy3.tab.c create mode 100644 test/btyacc/btyacc_destroy3.tab.h create mode 100644 test/btyacc/calc.error create mode 100644 test/btyacc/calc.output create mode 100644 test/btyacc/calc.tab.c create mode 100644 test/btyacc/calc.tab.h create mode 100644 test/btyacc/calc1.error create mode 100644 test/btyacc/calc1.output create mode 100644 test/btyacc/calc1.tab.c create mode 100644 test/btyacc/calc1.tab.h create mode 100644 test/btyacc/calc2.error create mode 100644 test/btyacc/calc2.output create mode 100644 test/btyacc/calc2.tab.c create mode 100644 test/btyacc/calc2.tab.h create mode 100644 test/btyacc/calc3.error create mode 100644 test/btyacc/calc3.output create mode 100644 test/btyacc/calc3.tab.c create mode 100644 test/btyacc/calc3.tab.h create mode 100644 test/btyacc/calc_code_all.error create mode 100644 test/btyacc/calc_code_all.output create mode 100644 test/btyacc/calc_code_all.tab.c create mode 100644 test/btyacc/calc_code_all.tab.h create mode 100644 test/btyacc/calc_code_default.error create mode 100644 test/btyacc/calc_code_default.output create mode 100644 test/btyacc/calc_code_default.tab.c create mode 100644 test/btyacc/calc_code_default.tab.h create mode 100644 test/btyacc/calc_code_imports.error create mode 100644 test/btyacc/calc_code_imports.output create mode 100644 test/btyacc/calc_code_imports.tab.c create mode 100644 test/btyacc/calc_code_imports.tab.h create mode 100644 test/btyacc/calc_code_provides.error create mode 100644 test/btyacc/calc_code_provides.output create mode 100644 test/btyacc/calc_code_provides.tab.c create mode 100644 test/btyacc/calc_code_provides.tab.h create mode 100644 test/btyacc/calc_code_requires.error create mode 100644 test/btyacc/calc_code_requires.output create mode 100644 test/btyacc/calc_code_requires.tab.c create mode 100644 test/btyacc/calc_code_requires.tab.h create mode 100644 test/btyacc/calc_code_top.error create mode 100644 test/btyacc/calc_code_top.output create mode 100644 test/btyacc/calc_code_top.tab.c create mode 100644 test/btyacc/calc_code_top.tab.h create mode 100644 test/btyacc/code_calc.code.c create mode 100644 test/btyacc/code_calc.error create mode 100644 test/btyacc/code_calc.output create mode 100644 test/btyacc/code_calc.tab.c create mode 100644 test/btyacc/code_calc.tab.h create mode 100644 test/btyacc/code_error.code.c create mode 100644 test/btyacc/code_error.error create mode 100644 test/btyacc/code_error.output create mode 100644 test/btyacc/code_error.tab.c create mode 100644 test/btyacc/code_error.tab.h create mode 100644 test/btyacc/defines1.calc.c create mode 100644 test/btyacc/defines1.calc.h create mode 100644 test/btyacc/defines1.error create mode 100644 test/btyacc/defines1.output create mode 100644 test/btyacc/defines2.calc.c create mode 100644 test/btyacc/defines2.calc.h create mode 100644 test/btyacc/defines2.error create mode 100644 test/btyacc/defines2.output create mode 100644 test/btyacc/defines3.calc.c create mode 100644 test/btyacc/defines3.calc.h create mode 100644 test/btyacc/defines3.error create mode 100644 test/btyacc/defines3.output create mode 100644 test/btyacc/empty.error create mode 100644 test/btyacc/empty.output create mode 100644 test/btyacc/empty.tab.c create mode 100644 test/btyacc/empty.tab.h create mode 100644 test/btyacc/err_inherit1.error create mode 100644 test/btyacc/err_inherit1.output create mode 100644 test/btyacc/err_inherit1.tab.c create mode 100644 test/btyacc/err_inherit1.tab.h create mode 100644 test/btyacc/err_inherit2.error create mode 100644 test/btyacc/err_inherit2.output create mode 100644 test/btyacc/err_inherit2.tab.c create mode 100644 test/btyacc/err_inherit2.tab.h create mode 100644 test/btyacc/err_inherit3.error create mode 100644 test/btyacc/err_inherit3.output create mode 100644 test/btyacc/err_inherit3.tab.c create mode 100644 test/btyacc/err_inherit3.tab.h create mode 100644 test/btyacc/err_inherit4.error create mode 100644 test/btyacc/err_inherit4.output create mode 100644 test/btyacc/err_inherit4.tab.c create mode 100644 test/btyacc/err_inherit4.tab.h create mode 100644 test/btyacc/err_inherit5.error create mode 100644 test/btyacc/err_inherit5.output create mode 100644 test/btyacc/err_inherit5.tab.c create mode 100644 test/btyacc/err_inherit5.tab.h create mode 100644 test/btyacc/err_syntax1.error create mode 100644 test/btyacc/err_syntax1.output create mode 100644 test/btyacc/err_syntax1.tab.c create mode 100644 test/btyacc/err_syntax1.tab.h create mode 100644 test/btyacc/err_syntax10.error create mode 100644 test/btyacc/err_syntax10.output create mode 100644 test/btyacc/err_syntax10.tab.c create mode 100644 test/btyacc/err_syntax10.tab.h create mode 100644 test/btyacc/err_syntax11.error create mode 100644 test/btyacc/err_syntax11.output create mode 100644 test/btyacc/err_syntax11.tab.c create mode 100644 test/btyacc/err_syntax11.tab.h create mode 100644 test/btyacc/err_syntax12.error create mode 100644 test/btyacc/err_syntax12.output create mode 100644 test/btyacc/err_syntax12.tab.c create mode 100644 test/btyacc/err_syntax12.tab.h create mode 100644 test/btyacc/err_syntax13.error create mode 100644 test/btyacc/err_syntax13.output create mode 100644 test/btyacc/err_syntax13.tab.c create mode 100644 test/btyacc/err_syntax13.tab.h create mode 100644 test/btyacc/err_syntax14.error create mode 100644 test/btyacc/err_syntax14.output create mode 100644 test/btyacc/err_syntax14.tab.c create mode 100644 test/btyacc/err_syntax14.tab.h create mode 100644 test/btyacc/err_syntax15.error create mode 100644 test/btyacc/err_syntax15.output create mode 100644 test/btyacc/err_syntax15.tab.c create mode 100644 test/btyacc/err_syntax15.tab.h create mode 100644 test/btyacc/err_syntax16.error create mode 100644 test/btyacc/err_syntax16.output create mode 100644 test/btyacc/err_syntax16.tab.c create mode 100644 test/btyacc/err_syntax16.tab.h create mode 100644 test/btyacc/err_syntax17.error create mode 100644 test/btyacc/err_syntax17.output create mode 100644 test/btyacc/err_syntax17.tab.c create mode 100644 test/btyacc/err_syntax17.tab.h create mode 100644 test/btyacc/err_syntax18.error create mode 100644 test/btyacc/err_syntax18.output create mode 100644 test/btyacc/err_syntax18.tab.c create mode 100644 test/btyacc/err_syntax18.tab.h create mode 100644 test/btyacc/err_syntax19.error create mode 100644 test/btyacc/err_syntax19.output create mode 100644 test/btyacc/err_syntax19.tab.c create mode 100644 test/btyacc/err_syntax19.tab.h create mode 100644 test/btyacc/err_syntax2.error create mode 100644 test/btyacc/err_syntax2.output create mode 100644 test/btyacc/err_syntax2.tab.c create mode 100644 test/btyacc/err_syntax2.tab.h create mode 100644 test/btyacc/err_syntax20.error create mode 100644 test/btyacc/err_syntax20.output create mode 100644 test/btyacc/err_syntax20.tab.c create mode 100644 test/btyacc/err_syntax20.tab.h create mode 100644 test/btyacc/err_syntax21.error create mode 100644 test/btyacc/err_syntax21.output create mode 100644 test/btyacc/err_syntax21.tab.c create mode 100644 test/btyacc/err_syntax21.tab.h create mode 100644 test/btyacc/err_syntax22.error create mode 100644 test/btyacc/err_syntax22.output create mode 100644 test/btyacc/err_syntax22.tab.c create mode 100644 test/btyacc/err_syntax22.tab.h create mode 100644 test/btyacc/err_syntax23.error create mode 100644 test/btyacc/err_syntax23.output create mode 100644 test/btyacc/err_syntax23.tab.c create mode 100644 test/btyacc/err_syntax23.tab.h create mode 100644 test/btyacc/err_syntax24.error create mode 100644 test/btyacc/err_syntax24.output create mode 100644 test/btyacc/err_syntax24.tab.c create mode 100644 test/btyacc/err_syntax24.tab.h create mode 100644 test/btyacc/err_syntax25.error create mode 100644 test/btyacc/err_syntax25.output create mode 100644 test/btyacc/err_syntax25.tab.c create mode 100644 test/btyacc/err_syntax25.tab.h create mode 100644 test/btyacc/err_syntax26.error create mode 100644 test/btyacc/err_syntax26.output create mode 100644 test/btyacc/err_syntax26.tab.c create mode 100644 test/btyacc/err_syntax26.tab.h create mode 100644 test/btyacc/err_syntax27.error create mode 100644 test/btyacc/err_syntax27.output create mode 100644 test/btyacc/err_syntax27.tab.c create mode 100644 test/btyacc/err_syntax27.tab.h create mode 100644 test/btyacc/err_syntax3.error create mode 100644 test/btyacc/err_syntax3.output create mode 100644 test/btyacc/err_syntax3.tab.c create mode 100644 test/btyacc/err_syntax3.tab.h create mode 100644 test/btyacc/err_syntax4.error create mode 100644 test/btyacc/err_syntax4.output create mode 100644 test/btyacc/err_syntax4.tab.c create mode 100644 test/btyacc/err_syntax4.tab.h create mode 100644 test/btyacc/err_syntax5.error create mode 100644 test/btyacc/err_syntax5.output create mode 100644 test/btyacc/err_syntax5.tab.c create mode 100644 test/btyacc/err_syntax5.tab.h create mode 100644 test/btyacc/err_syntax6.error create mode 100644 test/btyacc/err_syntax6.output create mode 100644 test/btyacc/err_syntax6.tab.c create mode 100644 test/btyacc/err_syntax6.tab.h create mode 100644 test/btyacc/err_syntax7.error create mode 100644 test/btyacc/err_syntax7.output create mode 100644 test/btyacc/err_syntax7.tab.c create mode 100644 test/btyacc/err_syntax7.tab.h create mode 100644 test/btyacc/err_syntax7a.error create mode 100644 test/btyacc/err_syntax7a.output create mode 100644 test/btyacc/err_syntax7a.tab.c create mode 100644 test/btyacc/err_syntax7a.tab.h create mode 100644 test/btyacc/err_syntax7b.error create mode 100644 test/btyacc/err_syntax7b.output create mode 100644 test/btyacc/err_syntax7b.tab.c create mode 100644 test/btyacc/err_syntax7b.tab.h create mode 100644 test/btyacc/err_syntax8.error create mode 100644 test/btyacc/err_syntax8.output create mode 100644 test/btyacc/err_syntax8.tab.c create mode 100644 test/btyacc/err_syntax8.tab.h create mode 100644 test/btyacc/err_syntax8a.error create mode 100644 test/btyacc/err_syntax8a.output create mode 100644 test/btyacc/err_syntax8a.tab.c create mode 100644 test/btyacc/err_syntax8a.tab.h create mode 100644 test/btyacc/err_syntax9.error create mode 100644 test/btyacc/err_syntax9.output create mode 100644 test/btyacc/err_syntax9.tab.c create mode 100644 test/btyacc/err_syntax9.tab.h create mode 100644 test/btyacc/error.error create mode 100644 test/btyacc/error.output create mode 100644 test/btyacc/error.tab.c create mode 100644 test/btyacc/error.tab.h create mode 100644 test/btyacc/expr.oxout.error create mode 100644 test/btyacc/expr.oxout.output create mode 100644 test/btyacc/expr.oxout.tab.c create mode 100644 test/btyacc/expr.oxout.tab.h create mode 100644 test/btyacc/grammar.dot create mode 100644 test/btyacc/grammar.error create mode 100644 test/btyacc/grammar.output create mode 100644 test/btyacc/grammar.tab.c create mode 100644 test/btyacc/grammar.tab.h create mode 100644 test/btyacc/help.error create mode 100644 test/btyacc/help.output create mode 100644 test/btyacc/inherit0.error create mode 100644 test/btyacc/inherit0.output create mode 100644 test/btyacc/inherit0.tab.c create mode 100644 test/btyacc/inherit0.tab.h create mode 100644 test/btyacc/inherit1.error create mode 100644 test/btyacc/inherit1.output create mode 100644 test/btyacc/inherit1.tab.c create mode 100644 test/btyacc/inherit1.tab.h create mode 100644 test/btyacc/inherit2.error create mode 100644 test/btyacc/inherit2.output create mode 100644 test/btyacc/inherit2.tab.c create mode 100644 test/btyacc/inherit2.tab.h create mode 100644 test/btyacc/no_b_opt.error create mode 100644 test/btyacc/no_b_opt.output create mode 100644 test/btyacc/no_b_opt1.error create mode 100644 test/btyacc/no_b_opt1.output create mode 100644 test/btyacc/no_code_c.error create mode 100644 test/btyacc/no_code_c.output create mode 100644 test/btyacc/no_defines.error create mode 100644 test/btyacc/no_defines.output create mode 100644 test/btyacc/no_graph.error create mode 100644 test/btyacc/no_graph.output create mode 100644 test/btyacc/no_include.error create mode 100644 test/btyacc/no_include.output create mode 100644 test/btyacc/no_opts.error create mode 100644 test/btyacc/no_opts.output create mode 100644 test/btyacc/no_output.error create mode 100644 test/btyacc/no_output.output create mode 100644 test/btyacc/no_output1.error create mode 100644 test/btyacc/no_output1.output create mode 100644 test/btyacc/no_output2.error create mode 100644 test/btyacc/no_output2.output create mode 100644 test/btyacc/no_p_opt.error create mode 100644 test/btyacc/no_p_opt.output create mode 100644 test/btyacc/no_p_opt1.error create mode 100644 test/btyacc/no_p_opt1.output create mode 100644 test/btyacc/no_verbose.error create mode 100644 test/btyacc/no_verbose.output create mode 100644 test/btyacc/nostdin.error create mode 100644 test/btyacc/nostdin.output create mode 100644 test/btyacc/ok_syntax1.error create mode 100644 test/btyacc/ok_syntax1.output create mode 100644 test/btyacc/ok_syntax1.tab.c create mode 100644 test/btyacc/ok_syntax1.tab.h create mode 100644 test/btyacc/pure_calc.error create mode 100644 test/btyacc/pure_calc.output create mode 100644 test/btyacc/pure_calc.tab.c create mode 100644 test/btyacc/pure_calc.tab.h create mode 100644 test/btyacc/pure_error.error create mode 100644 test/btyacc/pure_error.output create mode 100644 test/btyacc/pure_error.tab.c create mode 100644 test/btyacc/pure_error.tab.h create mode 100644 test/btyacc/quote_calc-s.error create mode 100644 test/btyacc/quote_calc-s.output create mode 100644 test/btyacc/quote_calc-s.tab.c create mode 100644 test/btyacc/quote_calc-s.tab.h create mode 100644 test/btyacc/quote_calc.error create mode 100644 test/btyacc/quote_calc.output create mode 100644 test/btyacc/quote_calc.tab.c create mode 100644 test/btyacc/quote_calc.tab.h create mode 100644 test/btyacc/quote_calc2-s.error create mode 100644 test/btyacc/quote_calc2-s.output create mode 100644 test/btyacc/quote_calc2-s.tab.c create mode 100644 test/btyacc/quote_calc2-s.tab.h create mode 100644 test/btyacc/quote_calc2.error create mode 100644 test/btyacc/quote_calc2.output create mode 100644 test/btyacc/quote_calc2.tab.c create mode 100644 test/btyacc/quote_calc2.tab.h create mode 100644 test/btyacc/quote_calc3-s.error create mode 100644 test/btyacc/quote_calc3-s.output create mode 100644 test/btyacc/quote_calc3-s.tab.c create mode 100644 test/btyacc/quote_calc3-s.tab.h create mode 100644 test/btyacc/quote_calc3.error create mode 100644 test/btyacc/quote_calc3.output create mode 100644 test/btyacc/quote_calc3.tab.c create mode 100644 test/btyacc/quote_calc3.tab.h create mode 100644 test/btyacc/quote_calc4-s.error create mode 100644 test/btyacc/quote_calc4-s.output create mode 100644 test/btyacc/quote_calc4-s.tab.c create mode 100644 test/btyacc/quote_calc4-s.tab.h create mode 100644 test/btyacc/quote_calc4.error create mode 100644 test/btyacc/quote_calc4.output create mode 100644 test/btyacc/quote_calc4.tab.c create mode 100644 test/btyacc/quote_calc4.tab.h create mode 100644 test/btyacc/rename_debug.c create mode 100644 test/btyacc/rename_debug.error create mode 100644 test/btyacc/rename_debug.h create mode 100644 test/btyacc/rename_debug.i create mode 100644 test/btyacc/rename_debug.output create mode 100644 test/btyacc/stdin1.calc.c create mode 100644 test/btyacc/stdin1.error create mode 100644 test/btyacc/stdin1.output create mode 100644 test/btyacc/stdin2.calc.c create mode 100644 test/btyacc/stdin2.error create mode 100644 test/btyacc/stdin2.output create mode 100644 test/btyacc/varsyntax_calc1.error create mode 100644 test/btyacc/varsyntax_calc1.output create mode 100644 test/btyacc/varsyntax_calc1.tab.c create mode 100644 test/btyacc/varsyntax_calc1.tab.h create mode 100644 test/btyacc_calc1.y create mode 100644 test/btyacc_demo.y create mode 100644 test/btyacc_destroy1.y create mode 100644 test/btyacc_destroy2.y create mode 100644 test/btyacc_destroy3.y create mode 100644 test/calc.y create mode 100644 test/calc1.y create mode 100644 test/calc2.y create mode 100644 test/calc3.y create mode 100644 test/calc_code_all.y create mode 100644 test/calc_code_default.y create mode 100644 test/calc_code_imports.y create mode 100644 test/calc_code_provides.y create mode 100644 test/calc_code_requires.y create mode 100644 test/calc_code_top.y create mode 100644 test/code_calc.y create mode 100644 test/code_debug.y create mode 100644 test/code_error.y create mode 100644 test/empty.y create mode 100644 test/err_inherit1.y create mode 100644 test/err_inherit2.y create mode 100644 test/err_inherit3.y create mode 100644 test/err_inherit4.y create mode 100644 test/err_inherit5.y create mode 100644 test/err_syntax1.y create mode 100644 test/err_syntax10.y create mode 100644 test/err_syntax11.y create mode 100644 test/err_syntax12.y create mode 100644 test/err_syntax13.y create mode 100644 test/err_syntax14.y create mode 100644 test/err_syntax15.y create mode 100644 test/err_syntax16.y create mode 100644 test/err_syntax17.y create mode 100644 test/err_syntax18.y create mode 100644 test/err_syntax19.y create mode 100644 test/err_syntax2.y create mode 100644 test/err_syntax20.y create mode 100644 test/err_syntax21.y create mode 100644 test/err_syntax22.y create mode 100644 test/err_syntax23.y create mode 100644 test/err_syntax24.y create mode 100644 test/err_syntax25.y create mode 100644 test/err_syntax26.y create mode 100644 test/err_syntax27.y create mode 100644 test/err_syntax3.y create mode 100644 test/err_syntax4.y create mode 100644 test/err_syntax5.y create mode 100644 test/err_syntax6.y create mode 100644 test/err_syntax7.y create mode 100644 test/err_syntax7a.y create mode 100644 test/err_syntax7b.y create mode 100644 test/err_syntax8.y create mode 100644 test/err_syntax8a.y create mode 100644 test/err_syntax9.y create mode 100644 test/error.y create mode 100644 test/expr.oxout.h create mode 100644 test/expr.oxout.y create mode 100644 test/grammar.y create mode 100644 test/inherit0.y create mode 100644 test/inherit1.y create mode 100644 test/inherit2.y create mode 100644 test/ok_syntax1.y create mode 100644 test/pure_calc.y create mode 100644 test/pure_error.y create mode 100644 test/quote_calc.y create mode 100644 test/quote_calc2.y create mode 100644 test/quote_calc3.y create mode 100644 test/quote_calc4.y create mode 100755 test/run_lint.sh create mode 100755 test/run_make.sh create mode 100755 test/run_test.sh create mode 100644 test/varsyntax_calc1.y create mode 100644 test/yacc/big_b.error create mode 100644 test/yacc/big_b.output create mode 100644 test/yacc/big_l.error create mode 100644 test/yacc/big_l.output create mode 100644 test/yacc/calc.error create mode 100644 test/yacc/calc.output create mode 100644 test/yacc/calc.tab.c create mode 100644 test/yacc/calc.tab.h create mode 100644 test/yacc/calc1.error create mode 100644 test/yacc/calc1.output create mode 100644 test/yacc/calc1.tab.c create mode 100644 test/yacc/calc1.tab.h create mode 100644 test/yacc/calc2.error create mode 100644 test/yacc/calc2.output create mode 100644 test/yacc/calc2.tab.c create mode 100644 test/yacc/calc2.tab.h create mode 100644 test/yacc/calc3.error create mode 100644 test/yacc/calc3.output create mode 100644 test/yacc/calc3.tab.c create mode 100644 test/yacc/calc3.tab.h create mode 100644 test/yacc/calc_code_all.error create mode 100644 test/yacc/calc_code_all.output create mode 100644 test/yacc/calc_code_all.tab.c create mode 100644 test/yacc/calc_code_all.tab.h create mode 100644 test/yacc/calc_code_default.error create mode 100644 test/yacc/calc_code_default.output create mode 100644 test/yacc/calc_code_default.tab.c create mode 100644 test/yacc/calc_code_default.tab.h create mode 100644 test/yacc/calc_code_imports.error create mode 100644 test/yacc/calc_code_imports.output create mode 100644 test/yacc/calc_code_imports.tab.c create mode 100644 test/yacc/calc_code_imports.tab.h create mode 100644 test/yacc/calc_code_provides.error create mode 100644 test/yacc/calc_code_provides.output create mode 100644 test/yacc/calc_code_provides.tab.c create mode 100644 test/yacc/calc_code_provides.tab.h create mode 100644 test/yacc/calc_code_requires.error create mode 100644 test/yacc/calc_code_requires.output create mode 100644 test/yacc/calc_code_requires.tab.c create mode 100644 test/yacc/calc_code_requires.tab.h create mode 100644 test/yacc/calc_code_top.error create mode 100644 test/yacc/calc_code_top.output create mode 100644 test/yacc/calc_code_top.tab.c create mode 100644 test/yacc/calc_code_top.tab.h create mode 100644 test/yacc/code_calc.code.c create mode 100644 test/yacc/code_calc.error create mode 100644 test/yacc/code_calc.output create mode 100644 test/yacc/code_calc.tab.c create mode 100644 test/yacc/code_calc.tab.h create mode 100644 test/yacc/code_error.code.c create mode 100644 test/yacc/code_error.error create mode 100644 test/yacc/code_error.output create mode 100644 test/yacc/code_error.tab.c create mode 100644 test/yacc/code_error.tab.h create mode 100644 test/yacc/defines1.calc.c create mode 100644 test/yacc/defines1.calc.h create mode 100644 test/yacc/defines1.error create mode 100644 test/yacc/defines1.output create mode 100644 test/yacc/defines2.calc.c create mode 100644 test/yacc/defines2.calc.h create mode 100644 test/yacc/defines2.error create mode 100644 test/yacc/defines2.output create mode 100644 test/yacc/defines3.calc.c create mode 100644 test/yacc/defines3.calc.h create mode 100644 test/yacc/defines3.error create mode 100644 test/yacc/defines3.output create mode 100644 test/yacc/empty.error create mode 100644 test/yacc/empty.output create mode 100644 test/yacc/empty.tab.c create mode 100644 test/yacc/empty.tab.h create mode 100644 test/yacc/err_syntax1.error create mode 100644 test/yacc/err_syntax1.output create mode 100644 test/yacc/err_syntax1.tab.c create mode 100644 test/yacc/err_syntax1.tab.h create mode 100644 test/yacc/err_syntax10.error create mode 100644 test/yacc/err_syntax10.output create mode 100644 test/yacc/err_syntax10.tab.c create mode 100644 test/yacc/err_syntax10.tab.h create mode 100644 test/yacc/err_syntax11.error create mode 100644 test/yacc/err_syntax11.output create mode 100644 test/yacc/err_syntax11.tab.c create mode 100644 test/yacc/err_syntax11.tab.h create mode 100644 test/yacc/err_syntax12.error create mode 100644 test/yacc/err_syntax12.output create mode 100644 test/yacc/err_syntax12.tab.c create mode 100644 test/yacc/err_syntax12.tab.h create mode 100644 test/yacc/err_syntax13.error create mode 100644 test/yacc/err_syntax13.output create mode 100644 test/yacc/err_syntax13.tab.c create mode 100644 test/yacc/err_syntax13.tab.h create mode 100644 test/yacc/err_syntax14.error create mode 100644 test/yacc/err_syntax14.output create mode 100644 test/yacc/err_syntax14.tab.c create mode 100644 test/yacc/err_syntax14.tab.h create mode 100644 test/yacc/err_syntax15.error create mode 100644 test/yacc/err_syntax15.output create mode 100644 test/yacc/err_syntax15.tab.c create mode 100644 test/yacc/err_syntax15.tab.h create mode 100644 test/yacc/err_syntax16.error create mode 100644 test/yacc/err_syntax16.output create mode 100644 test/yacc/err_syntax16.tab.c create mode 100644 test/yacc/err_syntax16.tab.h create mode 100644 test/yacc/err_syntax17.error create mode 100644 test/yacc/err_syntax17.output create mode 100644 test/yacc/err_syntax17.tab.c create mode 100644 test/yacc/err_syntax17.tab.h create mode 100644 test/yacc/err_syntax18.error create mode 100644 test/yacc/err_syntax18.output create mode 100644 test/yacc/err_syntax18.tab.c create mode 100644 test/yacc/err_syntax18.tab.h create mode 100644 test/yacc/err_syntax19.error create mode 100644 test/yacc/err_syntax19.output create mode 100644 test/yacc/err_syntax19.tab.c create mode 100644 test/yacc/err_syntax19.tab.h create mode 100644 test/yacc/err_syntax2.error create mode 100644 test/yacc/err_syntax2.output create mode 100644 test/yacc/err_syntax2.tab.c create mode 100644 test/yacc/err_syntax2.tab.h create mode 100644 test/yacc/err_syntax20.error create mode 100644 test/yacc/err_syntax20.output create mode 100644 test/yacc/err_syntax20.tab.c create mode 100644 test/yacc/err_syntax20.tab.h create mode 100644 test/yacc/err_syntax21.error create mode 100644 test/yacc/err_syntax21.output create mode 100644 test/yacc/err_syntax21.tab.c create mode 100644 test/yacc/err_syntax21.tab.h create mode 100644 test/yacc/err_syntax22.error create mode 100644 test/yacc/err_syntax22.output create mode 100644 test/yacc/err_syntax22.tab.c create mode 100644 test/yacc/err_syntax22.tab.h create mode 100644 test/yacc/err_syntax23.error create mode 100644 test/yacc/err_syntax23.output create mode 100644 test/yacc/err_syntax23.tab.c create mode 100644 test/yacc/err_syntax23.tab.h create mode 100644 test/yacc/err_syntax24.error create mode 100644 test/yacc/err_syntax24.output create mode 100644 test/yacc/err_syntax24.tab.c create mode 100644 test/yacc/err_syntax24.tab.h create mode 100644 test/yacc/err_syntax25.error create mode 100644 test/yacc/err_syntax25.output create mode 100644 test/yacc/err_syntax25.tab.c create mode 100644 test/yacc/err_syntax25.tab.h create mode 100644 test/yacc/err_syntax26.error create mode 100644 test/yacc/err_syntax26.output create mode 100644 test/yacc/err_syntax26.tab.c create mode 100644 test/yacc/err_syntax26.tab.h create mode 100644 test/yacc/err_syntax27.error create mode 100644 test/yacc/err_syntax27.output create mode 100644 test/yacc/err_syntax27.tab.c create mode 100644 test/yacc/err_syntax27.tab.h create mode 100644 test/yacc/err_syntax3.error create mode 100644 test/yacc/err_syntax3.output create mode 100644 test/yacc/err_syntax3.tab.c create mode 100644 test/yacc/err_syntax3.tab.h create mode 100644 test/yacc/err_syntax4.error create mode 100644 test/yacc/err_syntax4.output create mode 100644 test/yacc/err_syntax4.tab.c create mode 100644 test/yacc/err_syntax4.tab.h create mode 100644 test/yacc/err_syntax5.error create mode 100644 test/yacc/err_syntax5.output create mode 100644 test/yacc/err_syntax5.tab.c create mode 100644 test/yacc/err_syntax5.tab.h create mode 100644 test/yacc/err_syntax6.error create mode 100644 test/yacc/err_syntax6.output create mode 100644 test/yacc/err_syntax6.tab.c create mode 100644 test/yacc/err_syntax6.tab.h create mode 100644 test/yacc/err_syntax7.error create mode 100644 test/yacc/err_syntax7.output create mode 100644 test/yacc/err_syntax7.tab.c create mode 100644 test/yacc/err_syntax7.tab.h create mode 100644 test/yacc/err_syntax7a.error create mode 100644 test/yacc/err_syntax7a.output create mode 100644 test/yacc/err_syntax7a.tab.c create mode 100644 test/yacc/err_syntax7a.tab.h create mode 100644 test/yacc/err_syntax7b.error create mode 100644 test/yacc/err_syntax7b.output create mode 100644 test/yacc/err_syntax7b.tab.c create mode 100644 test/yacc/err_syntax7b.tab.h create mode 100644 test/yacc/err_syntax8.error create mode 100644 test/yacc/err_syntax8.output create mode 100644 test/yacc/err_syntax8.tab.c create mode 100644 test/yacc/err_syntax8.tab.h create mode 100644 test/yacc/err_syntax8a.error create mode 100644 test/yacc/err_syntax8a.output create mode 100644 test/yacc/err_syntax8a.tab.c create mode 100644 test/yacc/err_syntax8a.tab.h create mode 100644 test/yacc/err_syntax9.error create mode 100644 test/yacc/err_syntax9.output create mode 100644 test/yacc/err_syntax9.tab.c create mode 100644 test/yacc/err_syntax9.tab.h create mode 100644 test/yacc/error.error create mode 100644 test/yacc/error.output create mode 100644 test/yacc/error.tab.c create mode 100644 test/yacc/error.tab.h create mode 100644 test/yacc/expr.oxout.error create mode 100644 test/yacc/expr.oxout.output create mode 100644 test/yacc/expr.oxout.tab.c create mode 100644 test/yacc/expr.oxout.tab.h create mode 100644 test/yacc/grammar.dot create mode 100644 test/yacc/grammar.error create mode 100644 test/yacc/grammar.output create mode 100644 test/yacc/grammar.tab.c create mode 100644 test/yacc/grammar.tab.h create mode 100644 test/yacc/help.error create mode 100644 test/yacc/help.output create mode 100644 test/yacc/no_b_opt.error create mode 100644 test/yacc/no_b_opt.output create mode 100644 test/yacc/no_b_opt1.error create mode 100644 test/yacc/no_b_opt1.output create mode 100644 test/yacc/no_code_c.error create mode 100644 test/yacc/no_code_c.output create mode 100644 test/yacc/no_defines.error create mode 100644 test/yacc/no_defines.output create mode 100644 test/yacc/no_graph.error create mode 100644 test/yacc/no_graph.output create mode 100644 test/yacc/no_include.error create mode 100644 test/yacc/no_include.output create mode 100644 test/yacc/no_opts.error create mode 100644 test/yacc/no_opts.output create mode 100644 test/yacc/no_output.error create mode 100644 test/yacc/no_output.output create mode 100644 test/yacc/no_output1.error create mode 100644 test/yacc/no_output1.output create mode 100644 test/yacc/no_output2.error create mode 100644 test/yacc/no_output2.output create mode 100644 test/yacc/no_p_opt.error create mode 100644 test/yacc/no_p_opt.output create mode 100644 test/yacc/no_p_opt1.error create mode 100644 test/yacc/no_p_opt1.output create mode 100644 test/yacc/no_verbose.error create mode 100644 test/yacc/no_verbose.output create mode 100644 test/yacc/nostdin.error create mode 100644 test/yacc/nostdin.output create mode 100644 test/yacc/ok_syntax1.error create mode 100644 test/yacc/ok_syntax1.output create mode 100644 test/yacc/ok_syntax1.tab.c create mode 100644 test/yacc/ok_syntax1.tab.h create mode 100644 test/yacc/pure_calc.error create mode 100644 test/yacc/pure_calc.output create mode 100644 test/yacc/pure_calc.tab.c create mode 100644 test/yacc/pure_calc.tab.h create mode 100644 test/yacc/pure_error.error create mode 100644 test/yacc/pure_error.output create mode 100644 test/yacc/pure_error.tab.c create mode 100644 test/yacc/pure_error.tab.h create mode 100644 test/yacc/quote_calc-s.error create mode 100644 test/yacc/quote_calc-s.output create mode 100644 test/yacc/quote_calc-s.tab.c create mode 100644 test/yacc/quote_calc-s.tab.h create mode 100644 test/yacc/quote_calc.error create mode 100644 test/yacc/quote_calc.output create mode 100644 test/yacc/quote_calc.tab.c create mode 100644 test/yacc/quote_calc.tab.h create mode 100644 test/yacc/quote_calc2-s.error create mode 100644 test/yacc/quote_calc2-s.output create mode 100644 test/yacc/quote_calc2-s.tab.c create mode 100644 test/yacc/quote_calc2-s.tab.h create mode 100644 test/yacc/quote_calc2.error create mode 100644 test/yacc/quote_calc2.output create mode 100644 test/yacc/quote_calc2.tab.c create mode 100644 test/yacc/quote_calc2.tab.h create mode 100644 test/yacc/quote_calc3-s.error create mode 100644 test/yacc/quote_calc3-s.output create mode 100644 test/yacc/quote_calc3-s.tab.c create mode 100644 test/yacc/quote_calc3-s.tab.h create mode 100644 test/yacc/quote_calc3.error create mode 100644 test/yacc/quote_calc3.output create mode 100644 test/yacc/quote_calc3.tab.c create mode 100644 test/yacc/quote_calc3.tab.h create mode 100644 test/yacc/quote_calc4-s.error create mode 100644 test/yacc/quote_calc4-s.output create mode 100644 test/yacc/quote_calc4-s.tab.c create mode 100644 test/yacc/quote_calc4-s.tab.h create mode 100644 test/yacc/quote_calc4.error create mode 100644 test/yacc/quote_calc4.output create mode 100644 test/yacc/quote_calc4.tab.c create mode 100644 test/yacc/quote_calc4.tab.h create mode 100644 test/yacc/rename_debug.c create mode 100644 test/yacc/rename_debug.error create mode 100644 test/yacc/rename_debug.h create mode 100644 test/yacc/rename_debug.i create mode 100644 test/yacc/rename_debug.output create mode 100644 test/yacc/stdin1.calc.c create mode 100644 test/yacc/stdin1.error create mode 100644 test/yacc/stdin1.output create mode 100644 test/yacc/stdin2.calc.c create mode 100644 test/yacc/stdin2.error create mode 100644 test/yacc/stdin2.output create mode 100644 test/yacc/varsyntax_calc1.error create mode 100644 test/yacc/varsyntax_calc1.output create mode 100644 test/yacc/varsyntax_calc1.tab.c create mode 100644 test/yacc/varsyntax_calc1.tab.h diff --git a/test/README b/test/README new file mode 100644 index 00000000000..c9133c5bc87 --- /dev/null +++ b/test/README @@ -0,0 +1,4 @@ +-- $Id: README,v 1.1 2004/03/28 19:10:48 tom Exp $ + +The files in this directory are input (.y) and output (.output, .tab.c, .tab.h) +examples. diff --git a/test/btyacc/big_b.error b/test/btyacc/big_b.error new file mode 100644 index 00000000000..7f74f49a89b --- /dev/null +++ b/test/btyacc/big_b.error @@ -0,0 +1,30 @@ +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/btyacc/big_b.output b/test/btyacc/big_b.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/big_l.error b/test/btyacc/big_l.error new file mode 100644 index 00000000000..7f74f49a89b --- /dev/null +++ b/test/btyacc/big_l.error @@ -0,0 +1,30 @@ +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/btyacc/big_l.output b/test/btyacc/big_l.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/btyacc_calc1.error b/test/btyacc/btyacc_calc1.error new file mode 100644 index 00000000000..1807ff98801 --- /dev/null +++ b/test/btyacc/btyacc_calc1.error @@ -0,0 +1 @@ +YACC: 17 shift/reduce conflicts, 27 reduce/reduce conflicts. diff --git a/test/btyacc/btyacc_calc1.output b/test/btyacc/btyacc_calc1.output new file mode 100644 index 00000000000..fe68c43780c --- /dev/null +++ b/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/test/btyacc/btyacc_calc1.tab.c b/test/btyacc/btyacc_calc1.tab.c new file mode 100644 index 00000000000..53edd4e8889 --- /dev/null +++ b/test/btyacc/btyacc_calc1.tab.c @@ -0,0 +1,1803 @@ +/* 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 2 +#define YYMINOR 0 +#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]; + +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 29 "btyacc_calc1.y" +typedef union YYSTYPE +{ + 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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +#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 620 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; + int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* 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 YYINT *yylexp = 0; + + static YYINT *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[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + + yyerrflag = 0; + yychar = 0; + memset(&yyval, 0, sizeof(yyval)); + memset(&yylval, 0, sizeof(yylval)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(&yyloc, 0, sizeof(yyloc)); + memset(&yylloc, 0, sizeof(yylloc)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 2: +#line 51 "btyacc_calc1.y" +{YYVALID;} +#line 1354 "btyacc_calc1.tab.c" +break; +case 3: +#line 52 "btyacc_calc1.y" +{YYVALID;} if (!yytrial) +#line 53 "btyacc_calc1.y" +{ + yyerrok; + } +#line 1363 "btyacc_calc1.tab.c" +break; +case 4: + if (!yytrial) +#line 59 "btyacc_calc1.y" + { + (void) printf("%15.8f\n", yystack.l_mark[0].dval); + } +#line 1371 "btyacc_calc1.tab.c" +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); + } +#line 1379 "btyacc_calc1.tab.c" +break; +case 6: + if (!yytrial) +#line 67 "btyacc_calc1.y" + { + dreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].dval; + } +#line 1387 "btyacc_calc1.tab.c" +break; +case 7: + if (!yytrial) +#line 71 "btyacc_calc1.y" + { + vreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].vval; + } +#line 1395 "btyacc_calc1.tab.c" +break; +case 9: + if (!yytrial) +#line 78 "btyacc_calc1.y" + { + yyval.dval = dreg[yystack.l_mark[0].ival]; + } +#line 1403 "btyacc_calc1.tab.c" +break; +case 10: + if (!yytrial) +#line 82 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; + } +#line 1411 "btyacc_calc1.tab.c" +break; +case 11: + if (!yytrial) +#line 86 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; + } +#line 1419 "btyacc_calc1.tab.c" +break; +case 12: + if (!yytrial) +#line 90 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; + } +#line 1427 "btyacc_calc1.tab.c" +break; +case 13: + if (!yytrial) +#line 94 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; + } +#line 1435 "btyacc_calc1.tab.c" +break; +case 14: + if (!yytrial) +#line 98 "btyacc_calc1.y" + { + yyval.dval = -yystack.l_mark[0].dval; + } +#line 1443 "btyacc_calc1.tab.c" +break; +case 15: + if (!yytrial) +#line 102 "btyacc_calc1.y" + { + yyval.dval = yystack.l_mark[-1].dval; + } +#line 1451 "btyacc_calc1.tab.c" +break; +case 16: + if (!yytrial) +#line 108 "btyacc_calc1.y" + { + yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; + } +#line 1459 "btyacc_calc1.tab.c" +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; + } + } +#line 1473 "btyacc_calc1.tab.c" +break; +case 18: + if (!yytrial) +#line 122 "btyacc_calc1.y" + { + yyval.vval = vreg[yystack.l_mark[0].ival]; + } +#line 1481 "btyacc_calc1.tab.c" +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; + } +#line 1490 "btyacc_calc1.tab.c" +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; + } +#line 1499 "btyacc_calc1.tab.c" +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; + } +#line 1508 "btyacc_calc1.tab.c" +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; + } +#line 1517 "btyacc_calc1.tab.c" +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 ); + } +#line 1525 "btyacc_calc1.tab.c" +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 ); + } +#line 1533 "btyacc_calc1.tab.c" +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 ); + } +#line 1542 "btyacc_calc1.tab.c" +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 ); + } +#line 1551 "btyacc_calc1.tab.c" +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; + } +#line 1560 "btyacc_calc1.tab.c" +break; +case 28: + if (!yytrial) +#line 169 "btyacc_calc1.y" + { + yyval.vval = yystack.l_mark[-1].vval; + } +#line 1568 "btyacc_calc1.tab.c" +break; +#line 1570 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/btyacc_calc1.tab.h b/test/btyacc/btyacc_calc1.tab.h new file mode 100644 index 00000000000..114d213cd96 --- /dev/null +++ b/test/btyacc/btyacc_calc1.tab.h @@ -0,0 +1,22 @@ +#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 YYSTYPE +{ + int ival; + double dval; + INTERVAL vval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ + +#endif /* _calc1__defines_h_ */ diff --git a/test/btyacc/btyacc_demo.error b/test/btyacc/btyacc_demo.error new file mode 100644 index 00000000000..c070d881ffa --- /dev/null +++ b/test/btyacc/btyacc_demo.error @@ -0,0 +1 @@ +YACC: 12 shift/reduce conflicts. diff --git a/test/btyacc/btyacc_demo.output b/test/btyacc/btyacc_demo.output new file mode 100644 index 00000000000..a281c242a37 --- /dev/null +++ b/test/btyacc/btyacc_demo.output @@ -0,0 +1,1298 @@ + 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 decl : decl_specs declarator_list ';' + + 11 $$3 : + + 12 decl : decl_specs declarator $$3 block_statement + + 13 decl_specs : decl_spec + 14 | decl_specs $$2 decl_spec + + 15 cv_quals : + 16 | cv_quals cv_qual + + 17 decl_spec : cv_qual + 18 | typename + 19 | EXTERN + 20 | REGISTER + 21 | STATIC + + 22 cv_qual : CONST + 23 | VOLATILE + + 24 $$4 : + + 25 $$5 : + + 26 declarator_list : declarator_list ',' $$4 $$5 declarator + 27 | declarator + + 28 declarator : + 29 | ID + + 30 $$6 : + + 31 $$7 : + + 32 declarator : '(' $$6 $$7 declarator ')' + 33 | '*' cv_quals $$4 $$5 declarator + 34 | declarator '[' $$4 expr ']' + 35 | declarator '(' $$4 formal_arg_list ')' cv_quals + + 36 formal_arg_list : + 37 | nonempty_formal_arg_list + + 38 nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg + 39 | formal_arg + + 40 formal_arg : decl_specs declarator + + 41 expr : expr '+' $$6 expr + 42 | expr '-' $$6 expr + 43 | expr '*' $$6 expr + 44 | expr '%' $$6 expr + 45 | expr '/' $$6 expr + 46 | '*' $$2 expr + 47 | ID + 48 | CONSTANT + + 49 statement : decl + 50 | expr ';' + + 51 $$8 : + + 52 $$9 : + + 53 statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement + 54 | IF '(' $$6 expr ')' THEN $$8 statement + + 55 $$10 : + + 56 statement : $$10 block_statement + + 57 statement_list : + 58 | statement_list $$2 statement + + 59 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 . (19) + + . reduce 19 + + +state 6 + decl_spec : REGISTER . (20) + + . reduce 20 + + +state 7 + decl_spec : STATIC . (21) + + . reduce 21 + + +state 8 + cv_qual : CONST . (22) + + . reduce 22 + + +state 9 + cv_qual : VOLATILE . (23) + + . reduce 23 + + +state 10 + opt_scope : CLCL . (2) + + . reduce 2 + + +state 11 + decl_list : decl_list $$2 decl . (9) + + . reduce 9 + + +12: shift/reduce conflict (shift 18, reduce 28) on '(' +12: shift/reduce conflict (shift 19, reduce 8) on ID +state 12 + decl : decl_specs . declarator_list ';' (10) + decl : decl_specs . declarator $$3 block_statement (12) + decl_specs : decl_specs . $$2 decl_spec (14) + $$2 : . (8) + declarator : . (28) + + '*' shift 17 + '(' [trial] shift 18 + ID [trial] shift 19 + '(' [trial] reduce 28 + '[' reduce 28 + ID [trial] reduce 8 + EXTERN reduce 8 + REGISTER reduce 8 + STATIC reduce 8 + CONST reduce 8 + VOLATILE reduce 8 + CLCL reduce 8 + ';' reduce 28 + ',' reduce 28 + '{' reduce 28 + + declarator_list goto 20 + declarator goto 21 + $$2 goto 22 + + +state 13 + decl_specs : decl_spec . (13) + + . reduce 13 + + +state 14 + decl_spec : typename . (18) + + . reduce 18 + + +state 15 + decl_spec : cv_qual . (17) + + . reduce 17 + + +state 16 + opt_scope : opt_scope . ID CLCL (3) + typename : opt_scope . ID (4) + + ID shift 23 + . error + + +state 17 + declarator : '*' . cv_quals $$4 $$5 declarator (33) + cv_quals : . (15) + + . reduce 15 + + cv_quals goto 24 + + +state 18 + declarator : '(' . $$6 $$7 declarator ')' (32) + $$6 : . (30) + + . reduce 30 + + $$6 goto 25 + + +state 19 + declarator : ID . (29) + + . reduce 29 + + +state 20 + decl : decl_specs declarator_list . ';' (10) + declarator_list : declarator_list . ',' $$4 $$5 declarator (26) + + ';' shift 26 + ',' shift 27 + . error + + +state 21 + decl : decl_specs declarator . $$3 block_statement (12) + declarator_list : declarator . (27) + declarator : declarator . '[' $$4 expr ']' (34) + declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) + $$3 : . (11) + + '(' shift 28 + '[' shift 29 + ';' reduce 27 + ',' reduce 27 + '{' reduce 11 + + $$3 goto 30 + + +state 22 + decl_specs : decl_specs $$2 . decl_spec (14) + 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_spec goto 31 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + + +23: shift/reduce conflict (shift 32, reduce 4) on CLCL +state 23 + opt_scope : opt_scope ID . CLCL (3) + typename : opt_scope ID . (4) + + CLCL [trial] shift 32 + '*' 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 24 + cv_quals : cv_quals . cv_qual (16) + declarator : '*' cv_quals . $$4 $$5 declarator (33) + $$4 : . (24) + + CONST shift 8 + VOLATILE shift 9 + '*' reduce 24 + '(' reduce 24 + '[' reduce 24 + ID reduce 24 + ';' reduce 24 + ',' reduce 24 + ')' reduce 24 + '{' reduce 24 + + cv_qual goto 33 + $$4 goto 34 + + +state 25 + declarator : '(' $$6 . $$7 declarator ')' (32) + $$7 : . (31) + + . reduce 31 + + $$7 goto 35 + + +state 26 + decl : decl_specs declarator_list ';' . (10) + + . reduce 10 + + +state 27 + declarator_list : declarator_list ',' . $$4 $$5 declarator (26) + $$4 : . (24) + + . reduce 24 + + $$4 goto 36 + + +state 28 + declarator : declarator '(' . $$4 formal_arg_list ')' cv_quals (35) + $$4 : . (24) + + . reduce 24 + + $$4 goto 37 + + +state 29 + declarator : declarator '[' . $$4 expr ']' (34) + $$4 : . (24) + + . reduce 24 + + $$4 goto 38 + + +state 30 + decl : decl_specs declarator $$3 . block_statement (12) + + '{' shift 39 + . error + + block_statement goto 40 + + +state 31 + decl_specs : decl_specs $$2 decl_spec . (14) + + . reduce 14 + + +state 32 + opt_scope : opt_scope ID CLCL . (3) + + . reduce 3 + + +state 33 + cv_quals : cv_quals cv_qual . (16) + + . reduce 16 + + +state 34 + declarator : '*' cv_quals $$4 . $$5 declarator (33) + $$5 : . (25) + + . reduce 25 + + $$5 goto 41 + + +35: shift/reduce conflict (shift 18, reduce 28) on '(' +state 35 + declarator : '(' $$6 $$7 . declarator ')' (32) + declarator : . (28) + + '*' shift 17 + '(' [trial] shift 18 + ID shift 19 + '(' [trial] reduce 28 + '[' reduce 28 + ')' reduce 28 + + declarator goto 42 + + +state 36 + declarator_list : declarator_list ',' $$4 . $$5 declarator (26) + $$5 : . (25) + + . reduce 25 + + $$5 goto 43 + + +state 37 + declarator : declarator '(' $$4 . formal_arg_list ')' cv_quals (35) + opt_scope : . (1) + formal_arg_list : . (36) + + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + CLCL shift 10 + ID reduce 1 + ')' reduce 36 + + formal_arg goto 44 + decl_specs goto 45 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + formal_arg_list goto 46 + nonempty_formal_arg_list goto 47 + + +state 38 + declarator : declarator '[' $$4 . expr ']' (34) + + '*' shift 48 + ID shift 49 + CONSTANT shift 50 + . error + + expr goto 51 + + +state 39 + block_statement : '{' . $$2 statement_list '}' (59) + $$2 : . (8) + + . reduce 8 + + $$2 goto 52 + + +state 40 + decl : decl_specs declarator $$3 block_statement . (12) + + . reduce 12 + + +41: shift/reduce conflict (shift 18, reduce 28) on '(' +state 41 + declarator : '*' cv_quals $$4 $$5 . declarator (33) + declarator : . (28) + + '*' shift 17 + '(' [trial] shift 18 + ID shift 19 + '(' [trial] reduce 28 + '[' reduce 28 + ';' reduce 28 + ',' reduce 28 + ')' reduce 28 + '{' reduce 28 + + declarator goto 53 + + +state 42 + declarator : '(' $$6 $$7 declarator . ')' (32) + declarator : declarator . '[' $$4 expr ']' (34) + declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) + + '(' shift 28 + '[' shift 29 + ')' shift 54 + . error + + +43: shift/reduce conflict (shift 18, reduce 28) on '(' +state 43 + declarator_list : declarator_list ',' $$4 $$5 . declarator (26) + declarator : . (28) + + '*' shift 17 + '(' [trial] shift 18 + ID shift 19 + '(' [trial] reduce 28 + '[' reduce 28 + ';' reduce 28 + ',' reduce 28 + + declarator goto 55 + + +state 44 + nonempty_formal_arg_list : formal_arg . (39) + + . reduce 39 + + +45: shift/reduce conflict (shift 18, reduce 28) on '(' +45: shift/reduce conflict (shift 19, reduce 8) on ID +state 45 + decl_specs : decl_specs . $$2 decl_spec (14) + formal_arg : decl_specs . declarator (40) + $$2 : . (8) + declarator : . (28) + + '*' shift 17 + '(' [trial] shift 18 + ID [trial] shift 19 + '(' [trial] reduce 28 + '[' reduce 28 + ID [trial] reduce 8 + EXTERN reduce 8 + REGISTER reduce 8 + STATIC reduce 8 + CONST reduce 8 + VOLATILE reduce 8 + CLCL reduce 8 + ',' reduce 28 + ')' reduce 28 + + declarator goto 56 + $$2 goto 22 + + +state 46 + declarator : declarator '(' $$4 formal_arg_list . ')' cv_quals (35) + + ')' shift 57 + . error + + +state 47 + formal_arg_list : nonempty_formal_arg_list . (37) + nonempty_formal_arg_list : nonempty_formal_arg_list . ',' $$6 formal_arg (38) + + ',' shift 58 + ')' reduce 37 + + +state 48 + expr : '*' . $$2 expr (46) + $$2 : . (8) + + . reduce 8 + + $$2 goto 59 + + +state 49 + expr : ID . (47) + + . reduce 47 + + +state 50 + expr : CONSTANT . (48) + + . reduce 48 + + +state 51 + declarator : declarator '[' $$4 expr . ']' (34) + expr : expr . '+' $$6 expr (41) + expr : expr . '-' $$6 expr (42) + expr : expr . '*' $$6 expr (43) + expr : expr . '%' $$6 expr (44) + expr : expr . '/' $$6 expr (45) + + '+' shift 60 + '-' shift 61 + '*' shift 62 + '/' shift 63 + '%' shift 64 + ']' shift 65 + . error + + +state 52 + block_statement : '{' $$2 . statement_list '}' (59) + statement_list : . (57) + + . reduce 57 + + statement_list goto 66 + + +state 53 + declarator : '*' cv_quals $$4 $$5 declarator . (33) + declarator : declarator . '[' $$4 expr ']' (34) + declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) + + '(' shift 28 + '[' shift 29 + ';' reduce 33 + ',' reduce 33 + ')' reduce 33 + '{' reduce 33 + + +state 54 + declarator : '(' $$6 $$7 declarator ')' . (32) + + . reduce 32 + + +state 55 + declarator_list : declarator_list ',' $$4 $$5 declarator . (26) + declarator : declarator . '[' $$4 expr ']' (34) + declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) + + '(' shift 28 + '[' shift 29 + ';' reduce 26 + ',' reduce 26 + + +state 56 + declarator : declarator . '[' $$4 expr ']' (34) + declarator : declarator . '(' $$4 formal_arg_list ')' cv_quals (35) + formal_arg : decl_specs declarator . (40) + + '(' shift 28 + '[' shift 29 + ',' reduce 40 + ')' reduce 40 + + +state 57 + declarator : declarator '(' $$4 formal_arg_list ')' . cv_quals (35) + cv_quals : . (15) + + . reduce 15 + + cv_quals goto 67 + + +state 58 + nonempty_formal_arg_list : nonempty_formal_arg_list ',' . $$6 formal_arg (38) + $$6 : . (30) + + . reduce 30 + + $$6 goto 68 + + +state 59 + expr : '*' $$2 . expr (46) + + '*' shift 48 + ID shift 49 + CONSTANT shift 50 + . error + + expr goto 69 + + +state 60 + expr : expr '+' . $$6 expr (41) + $$6 : . (30) + + . reduce 30 + + $$6 goto 70 + + +state 61 + expr : expr '-' . $$6 expr (42) + $$6 : . (30) + + . reduce 30 + + $$6 goto 71 + + +state 62 + expr : expr '*' . $$6 expr (43) + $$6 : . (30) + + . reduce 30 + + $$6 goto 72 + + +state 63 + expr : expr '/' . $$6 expr (45) + $$6 : . (30) + + . reduce 30 + + $$6 goto 73 + + +state 64 + expr : expr '%' . $$6 expr (44) + $$6 : . (30) + + . reduce 30 + + $$6 goto 74 + + +state 65 + declarator : declarator '[' $$4 expr ']' . (34) + + . reduce 34 + + +state 66 + statement_list : statement_list . $$2 statement (58) + block_statement : '{' $$2 statement_list . '}' (59) + $$2 : . (8) + + '}' shift 75 + '*' 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 76 + + +state 67 + cv_quals : cv_quals . cv_qual (16) + declarator : declarator '(' $$4 formal_arg_list ')' cv_quals . (35) + + CONST shift 8 + VOLATILE shift 9 + '(' reduce 35 + '[' reduce 35 + ';' reduce 35 + ',' reduce 35 + ')' reduce 35 + '{' reduce 35 + + cv_qual goto 33 + + +state 68 + nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 . formal_arg (38) + 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 77 + decl_specs goto 45 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + + +state 69 + expr : expr . '+' $$6 expr (41) + expr : expr . '-' $$6 expr (42) + expr : expr . '*' $$6 expr (43) + expr : expr . '%' $$6 expr (44) + expr : expr . '/' $$6 expr (45) + expr : '*' $$2 expr . (46) + + . reduce 46 + + +state 70 + expr : expr '+' $$6 . expr (41) + + '*' shift 48 + ID shift 49 + CONSTANT shift 50 + . error + + expr goto 78 + + +state 71 + expr : expr '-' $$6 . expr (42) + + '*' shift 48 + ID shift 49 + CONSTANT shift 50 + . error + + expr goto 79 + + +state 72 + expr : expr '*' $$6 . expr (43) + + '*' shift 48 + ID shift 49 + CONSTANT shift 50 + . error + + expr goto 80 + + +state 73 + expr : expr '/' $$6 . expr (45) + + '*' shift 48 + ID shift 49 + CONSTANT shift 50 + . error + + expr goto 81 + + +state 74 + expr : expr '%' $$6 . expr (44) + + '*' shift 48 + ID shift 49 + CONSTANT shift 50 + . error + + expr goto 82 + + +state 75 + block_statement : '{' $$2 statement_list '}' . (59) + + . reduce 59 + + +76: shift/reduce conflict (shift 49, reduce 1) on ID +state 76 + statement_list : statement_list $$2 . statement (58) + opt_scope : . (1) + $$10 : . (55) + + '*' shift 48 + ID [trial] shift 49 + CONSTANT shift 50 + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + IF shift 83 + CLCL shift 10 + ID [trial] reduce 1 + '{' reduce 55 + + expr goto 84 + decl goto 85 + statement goto 86 + decl_specs goto 12 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + $$10 goto 87 + + +state 77 + nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg . (38) + + . reduce 38 + + +state 78 + expr : expr . '+' $$6 expr (41) + expr : expr '+' $$6 expr . (41) + expr : expr . '-' $$6 expr (42) + expr : expr . '*' $$6 expr (43) + expr : expr . '%' $$6 expr (44) + expr : expr . '/' $$6 expr (45) + + '*' shift 62 + '/' shift 63 + '%' shift 64 + '+' reduce 41 + '-' reduce 41 + ';' reduce 41 + ')' reduce 41 + ']' reduce 41 + + +state 79 + expr : expr . '+' $$6 expr (41) + expr : expr . '-' $$6 expr (42) + expr : expr '-' $$6 expr . (42) + expr : expr . '*' $$6 expr (43) + expr : expr . '%' $$6 expr (44) + expr : expr . '/' $$6 expr (45) + + '*' shift 62 + '/' shift 63 + '%' shift 64 + '+' reduce 42 + '-' reduce 42 + ';' reduce 42 + ')' reduce 42 + ']' reduce 42 + + +state 80 + expr : expr . '+' $$6 expr (41) + expr : expr . '-' $$6 expr (42) + expr : expr . '*' $$6 expr (43) + expr : expr '*' $$6 expr . (43) + expr : expr . '%' $$6 expr (44) + expr : expr . '/' $$6 expr (45) + + . reduce 43 + + +state 81 + expr : expr . '+' $$6 expr (41) + expr : expr . '-' $$6 expr (42) + expr : expr . '*' $$6 expr (43) + expr : expr . '%' $$6 expr (44) + expr : expr . '/' $$6 expr (45) + expr : expr '/' $$6 expr . (45) + + . reduce 45 + + +state 82 + expr : expr . '+' $$6 expr (41) + expr : expr . '-' $$6 expr (42) + expr : expr . '*' $$6 expr (43) + expr : expr . '%' $$6 expr (44) + expr : expr '%' $$6 expr . (44) + expr : expr . '/' $$6 expr (45) + + . reduce 44 + + +state 83 + statement : IF . '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement (53) + statement : IF . '(' $$6 expr ')' THEN $$8 statement (54) + + '(' shift 88 + . error + + +state 84 + expr : expr . '+' $$6 expr (41) + expr : expr . '-' $$6 expr (42) + expr : expr . '*' $$6 expr (43) + expr : expr . '%' $$6 expr (44) + expr : expr . '/' $$6 expr (45) + statement : expr . ';' (50) + + '+' shift 60 + '-' shift 61 + '*' shift 62 + '/' shift 63 + '%' shift 64 + ';' shift 89 + . error + + +state 85 + statement : decl . (49) + + . reduce 49 + + +state 86 + statement_list : statement_list $$2 statement . (58) + + . reduce 58 + + +state 87 + statement : $$10 . block_statement (56) + + '{' shift 39 + . error + + block_statement goto 90 + + +state 88 + statement : IF '(' . $$6 expr ')' THEN $$8 statement ELSE $$9 statement (53) + statement : IF '(' . $$6 expr ')' THEN $$8 statement (54) + $$6 : . (30) + + . reduce 30 + + $$6 goto 91 + + +state 89 + statement : expr ';' . (50) + + . reduce 50 + + +state 90 + statement : $$10 block_statement . (56) + + . reduce 56 + + +state 91 + statement : IF '(' $$6 . expr ')' THEN $$8 statement ELSE $$9 statement (53) + statement : IF '(' $$6 . expr ')' THEN $$8 statement (54) + + '*' shift 48 + ID shift 49 + CONSTANT shift 50 + . error + + expr goto 92 + + +state 92 + expr : expr . '+' $$6 expr (41) + expr : expr . '-' $$6 expr (42) + expr : expr . '*' $$6 expr (43) + expr : expr . '%' $$6 expr (44) + expr : expr . '/' $$6 expr (45) + statement : IF '(' $$6 expr . ')' THEN $$8 statement ELSE $$9 statement (53) + statement : IF '(' $$6 expr . ')' THEN $$8 statement (54) + + '+' shift 60 + '-' shift 61 + '*' shift 62 + '/' shift 63 + '%' shift 64 + ')' shift 93 + . error + + +state 93 + statement : IF '(' $$6 expr ')' . THEN $$8 statement ELSE $$9 statement (53) + statement : IF '(' $$6 expr ')' . THEN $$8 statement (54) + + THEN shift 94 + . error + + +state 94 + statement : IF '(' $$6 expr ')' THEN . $$8 statement ELSE $$9 statement (53) + statement : IF '(' $$6 expr ')' THEN . $$8 statement (54) + $$8 : . (51) + + . reduce 51 + + $$8 goto 95 + + +95: shift/reduce conflict (shift 49, reduce 1) on ID +state 95 + statement : IF '(' $$6 expr ')' THEN $$8 . statement ELSE $$9 statement (53) + statement : IF '(' $$6 expr ')' THEN $$8 . statement (54) + opt_scope : . (1) + $$10 : . (55) + + '*' shift 48 + ID [trial] shift 49 + CONSTANT shift 50 + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + IF shift 83 + CLCL shift 10 + ID [trial] reduce 1 + '{' reduce 55 + + expr goto 84 + decl goto 85 + statement goto 96 + decl_specs goto 12 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + $$10 goto 87 + + +96: shift/reduce conflict (shift 97, reduce 54) on ELSE +state 96 + statement : IF '(' $$6 expr ')' THEN $$8 statement . ELSE $$9 statement (53) + statement : IF '(' $$6 expr ')' THEN $$8 statement . (54) + + ELSE [trial] shift 97 + '*' reduce 54 + ID reduce 54 + CONSTANT reduce 54 + EXTERN reduce 54 + REGISTER reduce 54 + STATIC reduce 54 + CONST reduce 54 + VOLATILE reduce 54 + IF reduce 54 + ELSE [trial] reduce 54 + CLCL reduce 54 + '{' reduce 54 + '}' reduce 54 + + +state 97 + statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE . $$9 statement (53) + $$9 : . (52) + + . reduce 52 + + $$9 goto 98 + + +98: shift/reduce conflict (shift 49, reduce 1) on ID +state 98 + statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 . statement (53) + opt_scope : . (1) + $$10 : . (55) + + '*' shift 48 + ID [trial] shift 49 + CONSTANT shift 50 + EXTERN shift 5 + REGISTER shift 6 + STATIC shift 7 + CONST shift 8 + VOLATILE shift 9 + IF shift 83 + CLCL shift 10 + ID [trial] reduce 1 + '{' reduce 55 + + expr goto 84 + decl goto 85 + statement goto 99 + decl_specs goto 12 + decl_spec goto 13 + typename goto 14 + cv_qual goto 15 + opt_scope goto 16 + $$10 goto 87 + + +state 99 + statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement . (53) + + . reduce 53 + + +State 12 contains 2 shift/reduce conflicts. +State 23 contains 1 shift/reduce conflict. +State 35 contains 1 shift/reduce conflict. +State 41 contains 1 shift/reduce conflict. +State 43 contains 1 shift/reduce conflict. +State 45 contains 2 shift/reduce conflicts. +State 76 contains 1 shift/reduce conflict. +State 95 contains 1 shift/reduce conflict. +State 96 contains 1 shift/reduce conflict. +State 98 contains 1 shift/reduce conflict. + + +29 terminals, 29 nonterminals +60 grammar rules, 100 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 diff --git a/test/btyacc/btyacc_demo.tab.c b/test/btyacc/btyacc_demo.tab.c new file mode 100644 index 00000000000..6b346f27cea --- /dev/null +++ b/test/btyacc/btyacc_demo.tab.c @@ -0,0 +1,2400 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 36 "btyacc_demo.y" +typedef union YYSTYPE { + 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; + unsigned source; +} YYLTYPE; +#define YYLTYPE_IS_DECLARED 1 +#endif +#define YYRHSLOC(rhs, k) ((rhs)[k]) + +/* 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 int YYINT; +static const YYINT demo_lhs[] = { -1, + 15, 15, 15, 12, 18, 0, 4, 19, 4, 2, + 20, 2, 10, 10, 13, 13, 11, 11, 11, 11, + 11, 14, 14, 21, 22, 3, 3, 8, 8, 23, + 24, 8, 8, 8, 8, 16, 16, 17, 17, 9, + 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, + 25, 26, 5, 5, 27, 5, 6, 6, 7, +}; +static const YYINT demo_len[] = { 2, + 0, 1, 3, 2, 0, 2, 0, 0, 3, 3, + 0, 4, 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, 2, + 4, 4, 4, 4, 4, 3, 1, 1, 1, 2, + 0, 0, 11, 8, 0, 2, 0, 3, 4, +}; +static const YYINT demo_defred[] = { 5, + 0, 7, 0, 0, 19, 20, 21, 22, 23, 2, + 9, 0, 13, 18, 17, 0, 15, 30, 29, 0, + 0, 0, 0, 0, 31, 10, 24, 24, 24, 0, + 14, 3, 16, 25, 0, 25, 0, 0, 8, 12, + 0, 0, 0, 39, 0, 0, 0, 8, 47, 48, + 0, 57, 0, 32, 0, 0, 15, 30, 0, 30, + 30, 30, 30, 30, 34, 0, 0, 0, 46, 0, + 0, 0, 0, 0, 59, 0, 38, 0, 0, 43, + 45, 44, 0, 0, 49, 58, 0, 30, 50, 56, + 0, 0, 0, 51, 0, 0, 52, 0, 53, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT demo_stos[] = { 0, + 271, 289, 275, 290, 261, 262, 263, 264, 265, 269, + 273, 281, 282, 283, 285, 286, 42, 40, 259, 274, + 279, 290, 259, 284, 294, 59, 44, 40, 91, 291, + 282, 269, 285, 292, 295, 292, 292, 292, 123, 278, + 293, 279, 293, 280, 281, 287, 288, 42, 259, 260, + 272, 290, 279, 41, 279, 279, 41, 44, 290, 43, + 45, 42, 47, 37, 93, 277, 284, 294, 272, 294, + 294, 294, 294, 294, 125, 290, 280, 272, 272, 272, + 272, 272, 266, 272, 273, 276, 298, 40, 59, 278, + 294, 272, 41, 267, 296, 276, 268, 297, 276, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT demo_dgoto[] = { 1, + 84, 85, 20, 3, 86, 66, 40, 21, 44, 12, + 13, 14, 24, 15, 16, 46, 47, 2, 22, 30, + 34, 41, 25, 35, 95, 98, 87, +}; +static const YYINT demo_sindex[] = { 0, + 0, 0, 0, -103, 0, 0, 0, 0, 0, 0, + 0, -31, 0, 0, 0, -238, 0, 0, 0, 4, + -36, -103, 0, -133, 0, 0, 0, 0, 0, -94, + 0, 0, 0, 0, -40, 0, -103, -33, 0, 0, + -40, -25, -40, 0, -31, 8, 15, 0, 0, 0, + -2, 0, -36, 0, -36, -36, 0, 0, -33, 0, + 0, 0, 0, 0, 0, -92, -133, -103, 0, -33, + -33, -33, -33, -33, 0, -8, 0, 23, 23, 0, + 0, 0, 11, 75, 0, 0, -94, 0, 0, 0, + -33, 96, -194, 0, -8, 0, 0, -8, 0, +}; +static const YYINT demo_rindex[] = { 0, + 0, 0, 1, -181, 0, 0, 0, 0, 0, 0, + 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, + -39, -181, 12, -34, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -5, 0, -11, 0, 0, 0, + -17, 0, 28, 0, -41, 0, 47, 0, 0, 0, + 0, 0, -13, 0, 18, 70, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -19, -27, -181, 0, 0, + 0, 0, 0, 0, 0, -29, 0, 56, 64, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -29, -30, 0, -29, 0, +}; +#if YYBTYACC +static const YYINT demo_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -22, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -179, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, + 58, 0, 62, 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, -146, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -143, -147, 0, -134, 0, +}; +#endif +static const YYINT demo_gindex[] = { 0, + 9, 143, 0, 0, 50, 0, 63, 101, 83, 7, + 130, 0, 98, 2, 0, 0, 0, 0, 19, 0, + 10, 117, 66, 0, 0, 0, 0, +}; +#define YYTABLESIZE 286 +static const YYINT demo_table[] = { 28, + 6, 17, 28, 28, 27, 24, 24, 24, 48, 24, + 17, 54, 35, 35, 28, 54, 35, 0, 0, 27, + 23, 4, 8, 28, 24, 33, 28, 33, 39, 36, + 33, 35, 75, 48, 64, 28, 36, 37, 38, 62, + 60, 28, 61, 45, 63, 33, 51, 27, 57, 28, + 88, 4, 4, 4, 29, 4, 24, 52, 58, 64, + 28, 26, 26, 35, 62, 29, 59, 69, 33, 63, + 4, 28, 94, 28, 45, 28, 26, 1, 78, 79, + 80, 81, 82, 11, 76, 28, 28, 37, 24, 6, + 65, 0, 54, 55, 54, 35, 41, 0, 41, 92, + 41, 0, 4, 8, 42, 28, 42, 28, 42, 33, + 40, 64, 9, 40, 41, 9, 62, 60, 28, 61, + 12, 63, 42, 68, 9, 70, 71, 72, 73, 74, + 8, 9, 64, 89, 4, 42, 93, 62, 60, 28, + 61, 53, 63, 55, 96, 56, 11, 99, 41, 90, + 77, 31, 43, 91, 67, 0, 42, 5, 6, 7, + 8, 9, 0, 0, 0, 10, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 19, 8, + 8, 8, 8, 8, 24, 49, 50, 8, 54, 54, + 54, 54, 54, 54, 54, 54, 3, 3, 54, 8, + 8, 8, 8, 8, 8, 8, 8, 1, 0, 8, + 0, 50, 5, 6, 7, 8, 9, 83, 0, 8, + 10, 8, 8, 8, 8, 8, 0, 0, 0, 8, + 4, 0, 4, 4, 4, 4, 4, 8, 8, 8, + 8, 8, 0, 0, 0, 8, +}; +static const YYINT demo_check[] = { 41, + 0, 42, 44, 40, 44, 40, 41, 42, 42, 44, + 42, 42, 40, 41, 40, 41, 44, 40, 40, 59, + 259, 3, 42, 41, 59, 24, 44, 41, 123, 41, + 44, 59, 125, 42, 37, 41, 27, 28, 29, 42, + 43, 59, 45, 37, 47, 59, 38, 44, 41, 91, + 40, 40, 41, 42, 91, 44, 91, 39, 44, 37, + 44, 44, 59, 91, 42, 91, 48, 59, 67, 47, + 59, 44, 267, 91, 68, 59, 59, 259, 70, 71, + 72, 73, 74, 123, 66, 91, 59, 41, 123, 269, + 93, 40, 123, 123, 125, 123, 41, 40, 43, 91, + 45, 40, 91, 123, 41, 123, 43, 91, 45, 123, + 41, 37, 259, 44, 59, 259, 42, 43, 91, 45, + 268, 47, 59, 58, 259, 60, 61, 62, 63, 64, + 264, 265, 37, 59, 123, 35, 41, 42, 43, 123, + 45, 41, 47, 43, 95, 45, 4, 98, 93, 87, + 68, 22, 36, 88, 57, -1, 93, 261, 262, 263, + 264, 265, -1, -1, -1, 269, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -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, 261, + 262, 263, 264, 265, 259, 259, 260, 269, 259, 260, + 261, 262, 263, 264, 265, 266, 259, 259, 269, 259, + 260, 261, 262, 263, 264, 265, 266, 259, -1, 269, + -1, 260, 261, 262, 263, 264, 265, 266, -1, 259, + 269, 261, 262, 263, 264, 265, -1, -1, -1, 269, + 259, -1, 261, 262, 263, 264, 265, 261, 262, 263, + 264, 265, -1, -1, -1, 269, +}; +#if YYBTYACC +static const YYINT demo_ctable[] = { 18, + 28, -1, 19, 8, -1, 32, 4, -1, 49, 1, + -1, 97, 54, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 269 +#define YYUNDFTOKEN 299 +#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","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", +"decl : decl_specs declarator_list ';'", +"$$3 :", +"decl : decl_specs declarator $$3 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", +"$$4 :", +"$$5 :", +"declarator_list : declarator_list ',' $$4 $$5 declarator", +"declarator_list : declarator", +"declarator :", +"declarator : ID", +"$$6 :", +"$$7 :", +"declarator : '(' $$6 $$7 declarator ')'", +"declarator : '*' cv_quals $$4 $$5 declarator", +"declarator : declarator '[' $$4 expr ']'", +"declarator : declarator '(' $$4 formal_arg_list ')' cv_quals", +"formal_arg_list :", +"formal_arg_list : nonempty_formal_arg_list", +"nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg", +"nonempty_formal_arg_list : formal_arg", +"formal_arg : decl_specs declarator", +"expr : expr '+' $$6 expr", +"expr : expr '-' $$6 expr", +"expr : expr '*' $$6 expr", +"expr : expr '%' $$6 expr", +"expr : expr '/' $$6 expr", +"expr : '*' $$2 expr", +"expr : ID", +"expr : CONSTANT", +"statement : decl", +"statement : expr ';'", +"$$8 :", +"$$9 :", +"statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement", +"statement : IF '(' $$6 expr ')' THEN $$8 statement", +"$$10 :", +"statement : $$10 block_statement", +"statement_list :", +"statement_list : statement_list $$2 statement", +"block_statement : '{' $$2 statement_list '}'", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 667 "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 */ } +#line 683 "btyacc_demo.tab.c" + break; + 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 */ } +#line 692 "btyacc_demo.tab.c" + break; + 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 */ } +#line 701 "btyacc_demo.tab.c" + break; + 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 */ } +#line 710 "btyacc_demo.tab.c" + break; + 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 */ } +#line 719 "btyacc_demo.tab.c" + break; + 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 */ } +#line 728 "btyacc_demo.tab.c" + break; + 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 */ } +#line 737 "btyacc_demo.tab.c" + break; + 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 */ } +#line 746 "btyacc_demo.tab.c" + break; + 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 */ } +#line 755 "btyacc_demo.tab.c" + break; + 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 */ } +#line 764 "btyacc_demo.tab.c" + break; + 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); } +#line 773 "btyacc_demo.tab.c" + break; + 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); } +#line 782 "btyacc_demo.tab.c" + break; + 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 */ } +#line 791 "btyacc_demo.tab.c" + break; + 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 */ } +#line 800 "btyacc_demo.tab.c" + break; + 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 */ } +#line 809 "btyacc_demo.tab.c" + break; + 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 */ } +#line 818 "btyacc_demo.tab.c" + break; + 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 */ } +#line 827 "btyacc_demo.tab.c" + break; + 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 */ } +#line 836 "btyacc_demo.tab.c" + break; + 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 */ } +#line 845 "btyacc_demo.tab.c" + break; + 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 */ } +#line 854 "btyacc_demo.tab.c" + break; + 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 */ } +#line 863 "btyacc_demo.tab.c" + break; + 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 */ } +#line 872 "btyacc_demo.tab.c" + break; + 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 */ } +#line 881 "btyacc_demo.tab.c" + break; + 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 */ } +#line 890 "btyacc_demo.tab.c" + break; + 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 */ } +#line 899 "btyacc_demo.tab.c" + break; + 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 */ } +#line 908 "btyacc_demo.tab.c" + break; + 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 */ } +#line 917 "btyacc_demo.tab.c" + break; + 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 */ } +#line 926 "btyacc_demo.tab.c" + break; + 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 */ } +#line 935 "btyacc_demo.tab.c" + break; + 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); } +#line 944 "btyacc_demo.tab.c" + break; + 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); } +#line 954 "btyacc_demo.tab.c" + break; + 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 */ } +#line 963 "btyacc_demo.tab.c" + break; + 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 */ } +#line 972 "btyacc_demo.tab.c" + break; + 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); } +#line 981 "btyacc_demo.tab.c" + break; + 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); } +#line 990 "btyacc_demo.tab.c" + break; + 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); } +#line 999 "btyacc_demo.tab.c" + break; + 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); } +#line 1008 "btyacc_demo.tab.c" + break; + 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); } +#line 1017 "btyacc_demo.tab.c" + break; + 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); } +#line 1026 "btyacc_demo.tab.c" + break; + 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); } +#line 1035 "btyacc_demo.tab.c" + break; + 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); } +#line 1044 "btyacc_demo.tab.c" + break; + 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); } +#line 1053 "btyacc_demo.tab.c" + break; + 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); } +#line 1062 "btyacc_demo.tab.c" + break; + 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); } +#line 1071 "btyacc_demo.tab.c" + break; + 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); } +#line 1080 "btyacc_demo.tab.c" + break; + 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); } +#line 1089 "btyacc_demo.tab.c" + break; + 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); } +#line 1098 "btyacc_demo.tab.c" + break; + 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); } +#line 1107 "btyacc_demo.tab.c" + break; + 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).scope); } +#line 1116 "btyacc_demo.tab.c" + break; + 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); } +#line 1125 "btyacc_demo.tab.c" + break; + 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).type); } +#line 1134 "btyacc_demo.tab.c" + break; + 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).scope); } +#line 1143 "btyacc_demo.tab.c" + break; + 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).type); } +#line 1152 "btyacc_demo.tab.c" + break; + 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).scope); } +#line 1161 "btyacc_demo.tab.c" + break; + 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); } +#line 1170 "btyacc_demo.tab.c" + break; + 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); } +#line 1179 "btyacc_demo.tab.c" + break; + } +} +#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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: +#line 93 "btyacc_demo.y" +{ yyval.scope = yystack.l_mark[0].scope; } +#line 1857 "btyacc_demo.tab.c" +break; +case 2: +#line 94 "btyacc_demo.y" +{ yyval.scope = global_scope; } +#line 1862 "btyacc_demo.tab.c" +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; } +#line 1869 "btyacc_demo.tab.c" +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; } +#line 1876 "btyacc_demo.tab.c" +break; +case 5: +#line 106 "btyacc_demo.y" +yyval.scope = global_scope = new_scope(0); +#line 1881 "btyacc_demo.tab.c" +break; +case 8: +#line 107 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-1].scope; +#line 1886 "btyacc_demo.tab.c" +break; +case 10: +#line 109 "btyacc_demo.y" +{YYVALID;} +#line 1891 "btyacc_demo.tab.c" +break; +case 11: +#line 110 "btyacc_demo.y" +yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl); +#line 1896 "btyacc_demo.tab.c" +break; +case 12: + 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[-3].first_line; + yyloc.first_column = yystack.p_mark[-3].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); } +#line 1908 "btyacc_demo.tab.c" +break; +case 13: +#line 121 "btyacc_demo.y" +{ yyval.type = yystack.l_mark[0].type; } +#line 1913 "btyacc_demo.tab.c" +break; +case 14: +#line 122 "btyacc_demo.y" +{ yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); } +#line 1918 "btyacc_demo.tab.c" +break; +case 15: +#line 125 "btyacc_demo.y" +{ yyval.type = 0; } +#line 1923 "btyacc_demo.tab.c" +break; +case 16: +#line 126 "btyacc_demo.y" +{ yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); } +#line 1928 "btyacc_demo.tab.c" +break; +case 17: +#line 130 "btyacc_demo.y" +{ yyval.type = yystack.l_mark[0].type; } +#line 1933 "btyacc_demo.tab.c" +break; +case 18: +#line 131 "btyacc_demo.y" +{ yyval.type = yystack.l_mark[0].type; } +#line 1938 "btyacc_demo.tab.c" +break; +case 19: +#line 132 "btyacc_demo.y" +{ yyval.type = bare_extern(); } +#line 1943 "btyacc_demo.tab.c" +break; +case 20: +#line 133 "btyacc_demo.y" +{ yyval.type = bare_register(); } +#line 1948 "btyacc_demo.tab.c" +break; +case 21: +#line 134 "btyacc_demo.y" +{ yyval.type = bare_static(); } +#line 1953 "btyacc_demo.tab.c" +break; +case 22: +#line 138 "btyacc_demo.y" +{ yyval.type = bare_const(); } +#line 1958 "btyacc_demo.tab.c" +break; +case 23: +#line 139 "btyacc_demo.y" +{ yyval.type = bare_volatile(); } +#line 1963 "btyacc_demo.tab.c" +break; +case 24: +#line 143 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-3].scope; +#line 1968 "btyacc_demo.tab.c" +break; +case 25: +#line 143 "btyacc_demo.y" +yyval.type = yystack.l_mark[-3].type; +#line 1973 "btyacc_demo.tab.c" +break; +case 28: +#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); } +#line 1980 "btyacc_demo.tab.c" +break; +case 29: + 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); } +#line 1986 "btyacc_demo.tab.c" +break; +case 30: +#line 151 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-2].scope; +#line 1991 "btyacc_demo.tab.c" +break; +case 31: +#line 151 "btyacc_demo.y" +yyval.type = yystack.l_mark[-2].type; +#line 1996 "btyacc_demo.tab.c" +break; +case 32: + if (!yytrial) +#line 151 "btyacc_demo.y" + { yyval.decl = yystack.l_mark[-1].decl; } +#line 2002 "btyacc_demo.tab.c" +break; +case 33: + if (!yytrial) +#line 153 "btyacc_demo.y" + { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); } +#line 2008 "btyacc_demo.tab.c" +break; +case 34: + if (!yytrial) +#line 155 "btyacc_demo.y" + { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); } +#line 2014 "btyacc_demo.tab.c" +break; +case 35: + 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); } +#line 2020 "btyacc_demo.tab.c" +break; +case 36: + if (!yytrial) +#line 160 "btyacc_demo.y" + { yyval.dlist = 0; } +#line 2026 "btyacc_demo.tab.c" +break; +case 37: + if (!yytrial) +#line 161 "btyacc_demo.y" + { yyval.dlist = yystack.l_mark[0].dlist; } +#line 2032 "btyacc_demo.tab.c" +break; +case 38: + if (!yytrial) +#line 164 "btyacc_demo.y" + { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); } +#line 2038 "btyacc_demo.tab.c" +break; +case 39: + if (!yytrial) +#line 165 "btyacc_demo.y" + { yyval.dlist = build_dlist(yystack.l_mark[0].decl); } +#line 2044 "btyacc_demo.tab.c" +break; +case 40: + if (!yytrial) +#line 168 "btyacc_demo.y" + { yyval.decl = yystack.l_mark[0].decl; } +#line 2050 "btyacc_demo.tab.c" +break; +case 41: + if (!yytrial) +#line 172 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); } +#line 2056 "btyacc_demo.tab.c" +break; +case 42: + if (!yytrial) +#line 173 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); } +#line 2062 "btyacc_demo.tab.c" +break; +case 43: + if (!yytrial) +#line 174 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); } +#line 2068 "btyacc_demo.tab.c" +break; +case 44: + if (!yytrial) +#line 175 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); } +#line 2074 "btyacc_demo.tab.c" +break; +case 45: + if (!yytrial) +#line 176 "btyacc_demo.y" + { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); } +#line 2080 "btyacc_demo.tab.c" +break; +case 46: + if (!yytrial) +#line 177 "btyacc_demo.y" + { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); } +#line 2086 "btyacc_demo.tab.c" +break; +case 47: + if (!yytrial) +#line 178 "btyacc_demo.y" + { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); } +#line 2092 "btyacc_demo.tab.c" +break; +case 48: + if (!yytrial) +#line 179 "btyacc_demo.y" + { yyval.expr = yystack.l_mark[0].expr; } +#line 2098 "btyacc_demo.tab.c" +break; +case 49: + if (!yytrial) +#line 183 "btyacc_demo.y" + { yyval.code = 0; } +#line 2104 "btyacc_demo.tab.c" +break; +case 50: +#line 184 "btyacc_demo.y" +{YYVALID;} if (!yytrial) +#line 184 "btyacc_demo.y" +{ yyval.code = build_expr_code(yystack.l_mark[-1].expr); } +#line 2111 "btyacc_demo.tab.c" +break; +case 51: +#line 185 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-6].scope; +#line 2116 "btyacc_demo.tab.c" +break; +case 52: +#line 185 "btyacc_demo.y" +yyval.scope = yystack.l_mark[-9].scope; +#line 2121 "btyacc_demo.tab.c" +break; +case 53: +#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); } +#line 2128 "btyacc_demo.tab.c" +break; +case 54: +#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); } +#line 2135 "btyacc_demo.tab.c" +break; +case 55: +#line 189 "btyacc_demo.y" +yyval.scope = new_scope(yystack.l_mark[0].scope); +#line 2140 "btyacc_demo.tab.c" +break; +case 56: +#line 189 "btyacc_demo.y" +{YYVALID;} if (!yytrial) +#line 189 "btyacc_demo.y" +{ yyval.code = yystack.l_mark[0].code; } +#line 2147 "btyacc_demo.tab.c" +break; +case 57: + if (!yytrial) +#line 192 "btyacc_demo.y" + { yyval.code = 0; } +#line 2153 "btyacc_demo.tab.c" +break; +case 58: + if (!yytrial) +#line 193 "btyacc_demo.y" + { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); } +#line 2159 "btyacc_demo.tab.c" +break; +case 59: + if (!yytrial) +#line 197 "btyacc_demo.y" + { yyval.code = yystack.l_mark[-1].code; } +#line 2165 "btyacc_demo.tab.c" +break; +#line 2167 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/btyacc_demo.tab.h b/test/btyacc/btyacc_demo.tab.h new file mode 100644 index 00000000000..082f5cdbfa9 --- /dev/null +++ b/test/btyacc/btyacc_demo.tab.h @@ -0,0 +1,51 @@ +#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 YYSTYPE { + 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; + +#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; + unsigned source; +} YYLTYPE; +#define YYLTYPE_IS_DECLARED 1 +#endif +#define YYRHSLOC(rhs, k) ((rhs)[k]) +extern YYLTYPE demo_lloc; + +#endif /* _demo__defines_h_ */ diff --git a/test/btyacc/btyacc_destroy1.error b/test/btyacc/btyacc_destroy1.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/btyacc_destroy1.output b/test/btyacc/btyacc_destroy1.output new file mode 100644 index 00000000000..918354cacb1 --- /dev/null +++ b/test/btyacc/btyacc_destroy1.output @@ -0,0 +1,247 @@ + 0 $accept : declaration $end + + 1 declaration : class type namelist '(' class ',' type ')' + 2 | type locnamelist '(' class ')' + + 3 class : GLOBAL + 4 | LOCAL + + 5 type : REAL + 6 | INTEGER + + 7 namelist : namelist NAME + 8 | NAME + + 9 locnamelist : namelist '(' LOCAL ',' type ')' + +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 '(' class ',' type ')' (1) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 8 + + +state 7 + declaration : type . locnamelist '(' class ')' (2) + + NAME shift 9 + . error + + locnamelist goto 10 + namelist goto 11 + + +state 8 + declaration : class type . namelist '(' class ',' type ')' (1) + + NAME shift 9 + . error + + namelist goto 12 + + +state 9 + namelist : NAME . (8) + + . reduce 8 + + +state 10 + declaration : type locnamelist . '(' class ')' (2) + + '(' shift 13 + . error + + +state 11 + namelist : namelist . NAME (7) + locnamelist : namelist . '(' LOCAL ',' type ')' (9) + + NAME shift 14 + '(' shift 15 + . error + + +state 12 + declaration : class type namelist . '(' class ',' type ')' (1) + namelist : namelist . NAME (7) + + NAME shift 14 + '(' shift 16 + . error + + +state 13 + declaration : type locnamelist '(' . class ')' (2) + + GLOBAL shift 1 + LOCAL shift 2 + . error + + class goto 17 + + +state 14 + namelist : namelist NAME . (7) + + . reduce 7 + + +state 15 + locnamelist : namelist '(' . LOCAL ',' type ')' (9) + + LOCAL shift 18 + . error + + +state 16 + declaration : class type namelist '(' . class ',' type ')' (1) + + GLOBAL shift 1 + LOCAL shift 2 + . error + + class goto 19 + + +state 17 + declaration : type locnamelist '(' class . ')' (2) + + ')' shift 20 + . error + + +state 18 + locnamelist : namelist '(' LOCAL . ',' type ')' (9) + + ',' shift 21 + . error + + +state 19 + declaration : class type namelist '(' class . ',' type ')' (1) + + ',' shift 22 + . error + + +state 20 + declaration : type locnamelist '(' class ')' . (2) + + . reduce 2 + + +state 21 + locnamelist : namelist '(' LOCAL ',' . type ')' (9) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 23 + + +state 22 + declaration : class type namelist '(' class ',' . type ')' (1) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 24 + + +state 23 + locnamelist : namelist '(' LOCAL ',' type . ')' (9) + + ')' shift 25 + . error + + +state 24 + declaration : class type namelist '(' class ',' type . ')' (1) + + ')' shift 26 + . error + + +state 25 + locnamelist : namelist '(' LOCAL ',' type ')' . (9) + + . reduce 9 + + +state 26 + declaration : class type namelist '(' class ',' type ')' . (1) + + . reduce 1 + + +10 terminals, 6 nonterminals +10 grammar rules, 27 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 40 '(' + 8 44 ',' + 9 41 ')' + 10 262 $accept + 11 263 declaration + 12 264 locnamelist + 13 265 class + 14 266 type + 15 267 namelist diff --git a/test/btyacc/btyacc_destroy1.tab.c b/test/btyacc/btyacc_destroy1.tab.c new file mode 100644 index 00000000000..6775aa3e498 --- /dev/null +++ b/test/btyacc/btyacc_destroy1.tab.c @@ -0,0 +1,1477 @@ +/* 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 2 +#define YYMINOR 0 +#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 destroy1_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex destroy1_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror destroy1_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar destroy1_char +#endif /* yychar */ + +#ifndef yyval +#define yyval destroy1_val +#endif /* yyval */ + +#ifndef yylval +#define yylval destroy1_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug destroy1_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs destroy1_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag destroy1_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs destroy1_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen destroy1_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred destroy1_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos destroy1_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto destroy1_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex destroy1_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex destroy1_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex destroy1_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable destroy1_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck destroy1_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname destroy1_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule destroy1_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex destroy1_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable destroy1_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "destroy1_" + +#define YYPURE 0 + +#line 4 "btyacc_destroy1.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; + +struct parser_param { + int *rtrn; + symbol ss; +}; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 50 "btyacc_destroy1.y" +typedef union YYSTYPE +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 160 "btyacc_destroy1.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(struct parser_param *param, int flag) +#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(struct parser_param *param, int flag, const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(param, flag, msg) +#endif + +#ifndef YYDESTRUCT_DECL +#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) +#endif +#ifndef YYDESTRUCT_CALL +#define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) +#endif + +extern int YYPARSE_DECL(); + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT destroy1_lhs[] = { -1, + 0, 0, 2, 2, 3, 3, 4, 4, 1, +}; +static const YYINT destroy1_len[] = { 2, + 8, 5, 1, 1, 1, 1, 2, 1, 6, +}; +static const YYINT destroy1_defred[] = { 0, + 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, + 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 9, 1, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT destroy1_stos[] = { 0, + 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, + 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, + 44, 44, 266, 266, 41, 41, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT destroy1_dgoto[] = { 5, + 10, 6, 7, 11, +}; +static const YYINT destroy1_sindex[] = { -254, + 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, + -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, + -251, -251, -22, -19, 0, 0, +}; +static const YYINT destroy1_rindex[] = { 0, + 0, 0, 0, 0, 0, 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 destroy1_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, +}; +#endif +static const YYINT destroy1_gindex[] = { 0, + 0, -6, -4, 15, +}; +#define YYTABLESIZE 222 +static const YYINT destroy1_table[] = { 15, + 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, + 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, + 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 14, 14, +}; +static const YYINT destroy1_check[] = { 40, + 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, + 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, + 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 261, 261, +}; +#if YYBTYACC +static const YYINT destroy1_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, +}; +#endif +#define YYFINAL 5 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 261 +#define YYUNDFTOKEN 268 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const destroy1_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","GLOBAL","LOCAL", +"REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", +"namelist","illegal-symbol", +}; +static const char *const destroy1_rule[] = { +"$accept : declaration", +"declaration : class type namelist '(' class ',' type ')'", +"declaration : type locnamelist '(' class ')'", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"namelist : namelist NAME", +"namelist : NAME", +"locnamelist : namelist '(' LOCAL ',' type ')'", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 89 "btyacc_destroy1.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 492 "btyacc_destroy1.tab.c" + +/* Release memory associated with symbol. */ +#if ! defined YYDESTRUCT_IS_DECLARED +static void +YYDESTRUCT_DECL() +{ + switch (psymb) + { + case 263: +#line 41 "btyacc_destroy1.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } +#line 511 "btyacc_destroy1.tab.c" + break; + } +} +#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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: + if (!yytrial) +#line 62 "btyacc_destroy1.y" + { yyval.nlist = yystack.l_mark[-5].nlist; } +#line 1190 "btyacc_destroy1.tab.c" +break; +case 2: + if (!yytrial) +#line 64 "btyacc_destroy1.y" + { yyval.nlist = yystack.l_mark[-3].nlist; } +#line 1196 "btyacc_destroy1.tab.c" +break; +case 3: + if (!yytrial) +#line 67 "btyacc_destroy1.y" + { yyval.cval = cGLOBAL; } +#line 1202 "btyacc_destroy1.tab.c" +break; +case 4: + if (!yytrial) +#line 68 "btyacc_destroy1.y" + { yyval.cval = cLOCAL; } +#line 1208 "btyacc_destroy1.tab.c" +break; +case 5: + if (!yytrial) +#line 71 "btyacc_destroy1.y" + { yyval.tval = tREAL; } +#line 1214 "btyacc_destroy1.tab.c" +break; +case 6: + if (!yytrial) +#line 72 "btyacc_destroy1.y" + { yyval.tval = tINTEGER; } +#line 1220 "btyacc_destroy1.tab.c" +break; +case 7: + if (!yytrial) +#line 76 "btyacc_destroy1.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); + yyval.nlist->next = yystack.l_mark[-1].nlist; + } +#line 1228 "btyacc_destroy1.tab.c" +break; +case 8: + if (!yytrial) +#line 80 "btyacc_destroy1.y" + { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); + yyval.nlist->next = NULL; + } +#line 1236 "btyacc_destroy1.tab.c" +break; +case 9: + if (!yytrial) +#line 86 "btyacc_destroy1.y" + { yyval.nlist = yystack.l_mark[-5].nlist; } +#line 1242 "btyacc_destroy1.tab.c" +break; +#line 1244 "btyacc_destroy1.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/btyacc_destroy1.tab.h b/test/btyacc/btyacc_destroy1.tab.h new file mode 100644 index 00000000000..fd25e13b001 --- /dev/null +++ b/test/btyacc/btyacc_destroy1.tab.h @@ -0,0 +1,25 @@ +#ifndef _destroy1__defines_h_ +#define _destroy1__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 YYSTYPE +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE destroy1_lval; + +#endif /* _destroy1__defines_h_ */ diff --git a/test/btyacc/btyacc_destroy2.error b/test/btyacc/btyacc_destroy2.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/btyacc_destroy2.output b/test/btyacc/btyacc_destroy2.output new file mode 100644 index 00000000000..918354cacb1 --- /dev/null +++ b/test/btyacc/btyacc_destroy2.output @@ -0,0 +1,247 @@ + 0 $accept : declaration $end + + 1 declaration : class type namelist '(' class ',' type ')' + 2 | type locnamelist '(' class ')' + + 3 class : GLOBAL + 4 | LOCAL + + 5 type : REAL + 6 | INTEGER + + 7 namelist : namelist NAME + 8 | NAME + + 9 locnamelist : namelist '(' LOCAL ',' type ')' + +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 '(' class ',' type ')' (1) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 8 + + +state 7 + declaration : type . locnamelist '(' class ')' (2) + + NAME shift 9 + . error + + locnamelist goto 10 + namelist goto 11 + + +state 8 + declaration : class type . namelist '(' class ',' type ')' (1) + + NAME shift 9 + . error + + namelist goto 12 + + +state 9 + namelist : NAME . (8) + + . reduce 8 + + +state 10 + declaration : type locnamelist . '(' class ')' (2) + + '(' shift 13 + . error + + +state 11 + namelist : namelist . NAME (7) + locnamelist : namelist . '(' LOCAL ',' type ')' (9) + + NAME shift 14 + '(' shift 15 + . error + + +state 12 + declaration : class type namelist . '(' class ',' type ')' (1) + namelist : namelist . NAME (7) + + NAME shift 14 + '(' shift 16 + . error + + +state 13 + declaration : type locnamelist '(' . class ')' (2) + + GLOBAL shift 1 + LOCAL shift 2 + . error + + class goto 17 + + +state 14 + namelist : namelist NAME . (7) + + . reduce 7 + + +state 15 + locnamelist : namelist '(' . LOCAL ',' type ')' (9) + + LOCAL shift 18 + . error + + +state 16 + declaration : class type namelist '(' . class ',' type ')' (1) + + GLOBAL shift 1 + LOCAL shift 2 + . error + + class goto 19 + + +state 17 + declaration : type locnamelist '(' class . ')' (2) + + ')' shift 20 + . error + + +state 18 + locnamelist : namelist '(' LOCAL . ',' type ')' (9) + + ',' shift 21 + . error + + +state 19 + declaration : class type namelist '(' class . ',' type ')' (1) + + ',' shift 22 + . error + + +state 20 + declaration : type locnamelist '(' class ')' . (2) + + . reduce 2 + + +state 21 + locnamelist : namelist '(' LOCAL ',' . type ')' (9) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 23 + + +state 22 + declaration : class type namelist '(' class ',' . type ')' (1) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 24 + + +state 23 + locnamelist : namelist '(' LOCAL ',' type . ')' (9) + + ')' shift 25 + . error + + +state 24 + declaration : class type namelist '(' class ',' type . ')' (1) + + ')' shift 26 + . error + + +state 25 + locnamelist : namelist '(' LOCAL ',' type ')' . (9) + + . reduce 9 + + +state 26 + declaration : class type namelist '(' class ',' type ')' . (1) + + . reduce 1 + + +10 terminals, 6 nonterminals +10 grammar rules, 27 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 40 '(' + 8 44 ',' + 9 41 ')' + 10 262 $accept + 11 263 declaration + 12 264 locnamelist + 13 265 class + 14 266 type + 15 267 namelist diff --git a/test/btyacc/btyacc_destroy2.tab.c b/test/btyacc/btyacc_destroy2.tab.c new file mode 100644 index 00000000000..8b7c153d213 --- /dev/null +++ b/test/btyacc/btyacc_destroy2.tab.c @@ -0,0 +1,1477 @@ +/* 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 2 +#define YYMINOR 0 +#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 destroy2_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex destroy2_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror destroy2_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar destroy2_char +#endif /* yychar */ + +#ifndef yyval +#define yyval destroy2_val +#endif /* yyval */ + +#ifndef yylval +#define yylval destroy2_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug destroy2_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs destroy2_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag destroy2_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs destroy2_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen destroy2_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred destroy2_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos destroy2_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto destroy2_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex destroy2_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex destroy2_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex destroy2_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable destroy2_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck destroy2_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname destroy2_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule destroy2_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex destroy2_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable destroy2_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "destroy2_" + +#define YYPURE 0 + +#line 4 "btyacc_destroy2.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; + +struct parser_param { + int *rtrn; + symbol ss; +}; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 50 "btyacc_destroy2.y" +typedef union YYSTYPE +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 160 "btyacc_destroy2.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(struct parser_param *param, int flag) +#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(struct parser_param *param, int flag, const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(param, flag, msg) +#endif + +#ifndef YYDESTRUCT_DECL +#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) +#endif +#ifndef YYDESTRUCT_CALL +#define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) +#endif + +extern int YYPARSE_DECL(); + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT destroy2_lhs[] = { -1, + 0, 0, 2, 2, 3, 3, 4, 4, 1, +}; +static const YYINT destroy2_len[] = { 2, + 8, 5, 1, 1, 1, 1, 2, 1, 6, +}; +static const YYINT destroy2_defred[] = { 0, + 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, + 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 9, 1, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT destroy2_stos[] = { 0, + 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, + 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, + 44, 44, 266, 266, 41, 41, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT destroy2_dgoto[] = { 5, + 10, 6, 7, 11, +}; +static const YYINT destroy2_sindex[] = { -254, + 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, + -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, + -251, -251, -22, -19, 0, 0, +}; +static const YYINT destroy2_rindex[] = { 0, + 0, 0, 0, 0, 0, 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 destroy2_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, +}; +#endif +static const YYINT destroy2_gindex[] = { 0, + 0, -6, -4, 15, +}; +#define YYTABLESIZE 222 +static const YYINT destroy2_table[] = { 15, + 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, + 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, + 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 14, 14, +}; +static const YYINT destroy2_check[] = { 40, + 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, + 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, + 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 261, 261, +}; +#if YYBTYACC +static const YYINT destroy2_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, +}; +#endif +#define YYFINAL 5 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 261 +#define YYUNDFTOKEN 268 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const destroy2_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","GLOBAL","LOCAL", +"REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", +"namelist","illegal-symbol", +}; +static const char *const destroy2_rule[] = { +"$accept : declaration", +"declaration : class type namelist '(' class ',' type ')'", +"declaration : type locnamelist '(' class ')'", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"namelist : namelist NAME", +"namelist : NAME", +"locnamelist : namelist '(' LOCAL ',' type ')'", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 89 "btyacc_destroy2.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 492 "btyacc_destroy2.tab.c" + +/* Release memory associated with symbol. */ +#if ! defined YYDESTRUCT_IS_DECLARED +static void +YYDESTRUCT_DECL() +{ + switch (psymb) + { + case 263: +#line 41 "btyacc_destroy2.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } +#line 511 "btyacc_destroy2.tab.c" + break; + } +} +#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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: + if (!yytrial) +#line 62 "btyacc_destroy2.y" + { yyval.nlist = yystack.l_mark[-5].nlist; } +#line 1190 "btyacc_destroy2.tab.c" +break; +case 2: + if (!yytrial) +#line 64 "btyacc_destroy2.y" + { yyval.nlist = yystack.l_mark[-3].nlist; } +#line 1196 "btyacc_destroy2.tab.c" +break; +case 3: + if (!yytrial) +#line 67 "btyacc_destroy2.y" + { yyval.cval = cGLOBAL; } +#line 1202 "btyacc_destroy2.tab.c" +break; +case 4: + if (!yytrial) +#line 68 "btyacc_destroy2.y" + { yyval.cval = cLOCAL; } +#line 1208 "btyacc_destroy2.tab.c" +break; +case 5: + if (!yytrial) +#line 71 "btyacc_destroy2.y" + { yyval.tval = tREAL; } +#line 1214 "btyacc_destroy2.tab.c" +break; +case 6: + if (!yytrial) +#line 72 "btyacc_destroy2.y" + { yyval.tval = tINTEGER; } +#line 1220 "btyacc_destroy2.tab.c" +break; +case 7: + if (!yytrial) +#line 76 "btyacc_destroy2.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); + yyval.nlist->next = yystack.l_mark[-1].nlist; + } +#line 1228 "btyacc_destroy2.tab.c" +break; +case 8: + if (!yytrial) +#line 80 "btyacc_destroy2.y" + { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); + yyval.nlist->next = NULL; + } +#line 1236 "btyacc_destroy2.tab.c" +break; +case 9: + if (!yytrial) +#line 86 "btyacc_destroy2.y" + { yyval.nlist = yystack.l_mark[-5].nlist; } +#line 1242 "btyacc_destroy2.tab.c" +break; +#line 1244 "btyacc_destroy2.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/btyacc_destroy2.tab.h b/test/btyacc/btyacc_destroy2.tab.h new file mode 100644 index 00000000000..5f59abdea12 --- /dev/null +++ b/test/btyacc/btyacc_destroy2.tab.h @@ -0,0 +1,25 @@ +#ifndef _destroy2__defines_h_ +#define _destroy2__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 YYSTYPE +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE destroy2_lval; + +#endif /* _destroy2__defines_h_ */ diff --git a/test/btyacc/btyacc_destroy3.error b/test/btyacc/btyacc_destroy3.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/btyacc_destroy3.output b/test/btyacc/btyacc_destroy3.output new file mode 100644 index 00000000000..918354cacb1 --- /dev/null +++ b/test/btyacc/btyacc_destroy3.output @@ -0,0 +1,247 @@ + 0 $accept : declaration $end + + 1 declaration : class type namelist '(' class ',' type ')' + 2 | type locnamelist '(' class ')' + + 3 class : GLOBAL + 4 | LOCAL + + 5 type : REAL + 6 | INTEGER + + 7 namelist : namelist NAME + 8 | NAME + + 9 locnamelist : namelist '(' LOCAL ',' type ')' + +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 '(' class ',' type ')' (1) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 8 + + +state 7 + declaration : type . locnamelist '(' class ')' (2) + + NAME shift 9 + . error + + locnamelist goto 10 + namelist goto 11 + + +state 8 + declaration : class type . namelist '(' class ',' type ')' (1) + + NAME shift 9 + . error + + namelist goto 12 + + +state 9 + namelist : NAME . (8) + + . reduce 8 + + +state 10 + declaration : type locnamelist . '(' class ')' (2) + + '(' shift 13 + . error + + +state 11 + namelist : namelist . NAME (7) + locnamelist : namelist . '(' LOCAL ',' type ')' (9) + + NAME shift 14 + '(' shift 15 + . error + + +state 12 + declaration : class type namelist . '(' class ',' type ')' (1) + namelist : namelist . NAME (7) + + NAME shift 14 + '(' shift 16 + . error + + +state 13 + declaration : type locnamelist '(' . class ')' (2) + + GLOBAL shift 1 + LOCAL shift 2 + . error + + class goto 17 + + +state 14 + namelist : namelist NAME . (7) + + . reduce 7 + + +state 15 + locnamelist : namelist '(' . LOCAL ',' type ')' (9) + + LOCAL shift 18 + . error + + +state 16 + declaration : class type namelist '(' . class ',' type ')' (1) + + GLOBAL shift 1 + LOCAL shift 2 + . error + + class goto 19 + + +state 17 + declaration : type locnamelist '(' class . ')' (2) + + ')' shift 20 + . error + + +state 18 + locnamelist : namelist '(' LOCAL . ',' type ')' (9) + + ',' shift 21 + . error + + +state 19 + declaration : class type namelist '(' class . ',' type ')' (1) + + ',' shift 22 + . error + + +state 20 + declaration : type locnamelist '(' class ')' . (2) + + . reduce 2 + + +state 21 + locnamelist : namelist '(' LOCAL ',' . type ')' (9) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 23 + + +state 22 + declaration : class type namelist '(' class ',' . type ')' (1) + + REAL shift 3 + INTEGER shift 4 + . error + + type goto 24 + + +state 23 + locnamelist : namelist '(' LOCAL ',' type . ')' (9) + + ')' shift 25 + . error + + +state 24 + declaration : class type namelist '(' class ',' type . ')' (1) + + ')' shift 26 + . error + + +state 25 + locnamelist : namelist '(' LOCAL ',' type ')' . (9) + + . reduce 9 + + +state 26 + declaration : class type namelist '(' class ',' type ')' . (1) + + . reduce 1 + + +10 terminals, 6 nonterminals +10 grammar rules, 27 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 40 '(' + 8 44 ',' + 9 41 ')' + 10 262 $accept + 11 263 declaration + 12 264 locnamelist + 13 265 class + 14 266 type + 15 267 namelist diff --git a/test/btyacc/btyacc_destroy3.tab.c b/test/btyacc/btyacc_destroy3.tab.c new file mode 100644 index 00000000000..7cd56e7bb5b --- /dev/null +++ b/test/btyacc/btyacc_destroy3.tab.c @@ -0,0 +1,1477 @@ +/* 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 2 +#define YYMINOR 0 +#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 destroy3_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex destroy3_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror destroy3_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar destroy3_char +#endif /* yychar */ + +#ifndef yyval +#define yyval destroy3_val +#endif /* yyval */ + +#ifndef yylval +#define yylval destroy3_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug destroy3_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs destroy3_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag destroy3_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs destroy3_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen destroy3_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred destroy3_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos destroy3_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto destroy3_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex destroy3_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex destroy3_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex destroy3_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable destroy3_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck destroy3_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname destroy3_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule destroy3_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex destroy3_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable destroy3_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "destroy3_" + +#define YYPURE 0 + +#line 7 "btyacc_destroy3.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; + +struct parser_param { + int *rtrn; + symbol ss; +}; + +extern symbol *mksymbol(type t, class c, name id); + +#ifdef YYBISON +#define YYLEX_DECL() yylex(void) +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 53 "btyacc_destroy3.y" +typedef union YYSTYPE +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 160 "btyacc_destroy3.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(struct parser_param *param, int flag) +#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(struct parser_param *param, int flag, const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(param, flag, msg) +#endif + +#ifndef YYDESTRUCT_DECL +#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) +#endif +#ifndef YYDESTRUCT_CALL +#define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) +#endif + +extern int YYPARSE_DECL(); + +#define GLOBAL 257 +#define LOCAL 258 +#define REAL 259 +#define INTEGER 260 +#define NAME 261 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT destroy3_lhs[] = { -1, + 0, 0, 2, 2, 3, 3, 4, 4, 1, +}; +static const YYINT destroy3_len[] = { 2, + 8, 5, 1, 1, 1, 1, 2, 1, 6, +}; +static const YYINT destroy3_defred[] = { 0, + 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, + 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 9, 1, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT destroy3_stos[] = { 0, + 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, + 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, + 44, 44, 266, 266, 41, 41, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT destroy3_dgoto[] = { 5, + 10, 6, 7, 11, +}; +static const YYINT destroy3_sindex[] = { -254, + 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, + -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, + -251, -251, -22, -19, 0, 0, +}; +static const YYINT destroy3_rindex[] = { 0, + 0, 0, 0, 0, 0, 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 destroy3_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, +}; +#endif +static const YYINT destroy3_gindex[] = { 0, + 0, -6, -4, 15, +}; +#define YYTABLESIZE 222 +static const YYINT destroy3_table[] = { 15, + 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, + 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, + 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 14, 14, +}; +static const YYINT destroy3_check[] = { 40, + 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, + 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, + 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 261, 261, +}; +#if YYBTYACC +static const YYINT destroy3_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, +}; +#endif +#define YYFINAL 5 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 261 +#define YYUNDFTOKEN 268 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const destroy3_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","GLOBAL","LOCAL", +"REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", +"namelist","illegal-symbol", +}; +static const char *const destroy3_rule[] = { +"$accept : declaration", +"declaration : class type namelist '(' class ',' type ')'", +"declaration : type locnamelist '(' class ')'", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"namelist : namelist NAME", +"namelist : NAME", +"locnamelist : namelist '(' LOCAL ',' type ')'", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 92 "btyacc_destroy3.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 492 "btyacc_destroy3.tab.c" + +/* Release memory associated with symbol. */ +#if ! defined YYDESTRUCT_IS_DECLARED +static void +YYDESTRUCT_DECL() +{ + switch (psymb) + { + case 263: +#line 44 "btyacc_destroy3.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } +#line 511 "btyacc_destroy3.tab.c" + break; + } +} +#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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: + if (!yytrial) +#line 65 "btyacc_destroy3.y" + { yyval.nlist = yystack.l_mark[-5].nlist; } +#line 1190 "btyacc_destroy3.tab.c" +break; +case 2: + if (!yytrial) +#line 67 "btyacc_destroy3.y" + { yyval.nlist = yystack.l_mark[-3].nlist; } +#line 1196 "btyacc_destroy3.tab.c" +break; +case 3: + if (!yytrial) +#line 70 "btyacc_destroy3.y" + { yyval.cval = cGLOBAL; } +#line 1202 "btyacc_destroy3.tab.c" +break; +case 4: + if (!yytrial) +#line 71 "btyacc_destroy3.y" + { yyval.cval = cLOCAL; } +#line 1208 "btyacc_destroy3.tab.c" +break; +case 5: + if (!yytrial) +#line 74 "btyacc_destroy3.y" + { yyval.tval = tREAL; } +#line 1214 "btyacc_destroy3.tab.c" +break; +case 6: + if (!yytrial) +#line 75 "btyacc_destroy3.y" + { yyval.tval = tINTEGER; } +#line 1220 "btyacc_destroy3.tab.c" +break; +case 7: + if (!yytrial) +#line 79 "btyacc_destroy3.y" + { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); + yyval.nlist->next = yystack.l_mark[-1].nlist; + } +#line 1228 "btyacc_destroy3.tab.c" +break; +case 8: + if (!yytrial) +#line 83 "btyacc_destroy3.y" + { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); + yyval.nlist->next = NULL; + } +#line 1236 "btyacc_destroy3.tab.c" +break; +case 9: + if (!yytrial) +#line 89 "btyacc_destroy3.y" + { yyval.nlist = yystack.l_mark[-5].nlist; } +#line 1242 "btyacc_destroy3.tab.c" +break; +#line 1244 "btyacc_destroy3.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/btyacc_destroy3.tab.h b/test/btyacc/btyacc_destroy3.tab.h new file mode 100644 index 00000000000..5a84568a6c0 --- /dev/null +++ b/test/btyacc/btyacc_destroy3.tab.h @@ -0,0 +1,25 @@ +#ifndef _destroy3__defines_h_ +#define _destroy3__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 YYSTYPE +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE destroy3_lval; + +#endif /* _destroy3__defines_h_ */ diff --git a/test/btyacc/calc.error b/test/btyacc/calc.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/calc.output b/test/btyacc/calc.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/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/test/btyacc/calc.tab.c b/test/btyacc/calc.tab.c new file mode 100644 index 00000000000..89ecffad77d --- /dev/null +++ b/test/btyacc/calc.tab.c @@ -0,0 +1,1489 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT calc_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 511 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 1184 "calc.tab.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1189 "calc.tab.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1194 "calc.tab.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 1199 "calc.tab.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1204 "calc.tab.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1209 "calc.tab.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1214 "calc.tab.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1219 "calc.tab.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1224 "calc.tab.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1229 "calc.tab.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1234 "calc.tab.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 1239 "calc.tab.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1244 "calc.tab.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1249 "calc.tab.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1254 "calc.tab.c" +break; +#line 1256 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc.tab.h b/test/btyacc/calc.tab.h new file mode 100644 index 00000000000..48f8993b83f --- /dev/null +++ b/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/test/btyacc/calc1.error b/test/btyacc/calc1.error new file mode 100644 index 00000000000..9c1f7152c30 --- /dev/null +++ b/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/test/btyacc/calc1.output b/test/btyacc/calc1.output new file mode 100644 index 00000000000..d6a869f6d35 --- /dev/null +++ b/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/test/btyacc/calc1.tab.c b/test/btyacc/calc1.tab.c new file mode 100644 index 00000000000..98394f988e9 --- /dev/null +++ b/test/btyacc/calc1.tab.c @@ -0,0 +1,1746 @@ +/* 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 2 +#define YYMINOR 0 +#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]; + +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 31 "calc1.y" +typedef union YYSTYPE +{ + 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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT calc1_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 655 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 57 "calc1.y" + { + (void) printf("%15.8f\n", yystack.l_mark[-1].dval); + } +#line 1330 "calc1.tab.c" +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); + } +#line 1337 "calc1.tab.c" +break; +case 5: +#line 65 "calc1.y" + { + dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; + } +#line 1344 "calc1.tab.c" +break; +case 6: +#line 69 "calc1.y" + { + vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; + } +#line 1351 "calc1.tab.c" +break; +case 7: +#line 73 "calc1.y" + { + yyerrok; + } +#line 1358 "calc1.tab.c" +break; +case 9: +#line 80 "calc1.y" + { + yyval.dval = dreg[yystack.l_mark[0].ival]; + } +#line 1365 "calc1.tab.c" +break; +case 10: +#line 84 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; + } +#line 1372 "calc1.tab.c" +break; +case 11: +#line 88 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; + } +#line 1379 "calc1.tab.c" +break; +case 12: +#line 92 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; + } +#line 1386 "calc1.tab.c" +break; +case 13: +#line 96 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; + } +#line 1393 "calc1.tab.c" +break; +case 14: +#line 100 "calc1.y" + { + yyval.dval = -yystack.l_mark[0].dval; + } +#line 1400 "calc1.tab.c" +break; +case 15: +#line 104 "calc1.y" + { + yyval.dval = yystack.l_mark[-1].dval; + } +#line 1407 "calc1.tab.c" +break; +case 16: +#line 110 "calc1.y" + { + yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; + } +#line 1414 "calc1.tab.c" +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; + } + } +#line 1427 "calc1.tab.c" +break; +case 18: +#line 124 "calc1.y" + { + yyval.vval = vreg[yystack.l_mark[0].ival]; + } +#line 1434 "calc1.tab.c" +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; + } +#line 1442 "calc1.tab.c" +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; + } +#line 1450 "calc1.tab.c" +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; + } +#line 1458 "calc1.tab.c" +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; + } +#line 1466 "calc1.tab.c" +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 ); + } +#line 1473 "calc1.tab.c" +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 ); + } +#line 1480 "calc1.tab.c" +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 ); + } +#line 1488 "calc1.tab.c" +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 ); + } +#line 1496 "calc1.tab.c" +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; + } +#line 1504 "calc1.tab.c" +break; +case 28: +#line 171 "calc1.y" + { + yyval.vval = yystack.l_mark[-1].vval; + } +#line 1511 "calc1.tab.c" +break; +#line 1513 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc1.tab.h b/test/btyacc/calc1.tab.h new file mode 100644 index 00000000000..0162b210747 --- /dev/null +++ b/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 YYSTYPE +{ + int ival; + double dval; + INTERVAL vval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE calc1_lval; + +#endif /* _calc1__defines_h_ */ diff --git a/test/btyacc/calc2.error b/test/btyacc/calc2.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/calc2.output b/test/btyacc/calc2.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/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/test/btyacc/calc2.tab.c b/test/btyacc/calc2.tab.c new file mode 100644 index 00000000000..ffe4d80c1f7 --- /dev/null +++ b/test/btyacc/calc2.tab.c @@ -0,0 +1,1502 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT calc2_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 524 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "calc2.y" + { yyerrok ; } +#line 1197 "calc2.tab.c" +break; +case 4: +#line 39 "calc2.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1202 "calc2.tab.c" +break; +case 5: +#line 41 "calc2.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1207 "calc2.tab.c" +break; +case 6: +#line 45 "calc2.y" + { yyval = yystack.l_mark[-1]; } +#line 1212 "calc2.tab.c" +break; +case 7: +#line 47 "calc2.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1217 "calc2.tab.c" +break; +case 8: +#line 49 "calc2.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1222 "calc2.tab.c" +break; +case 9: +#line 51 "calc2.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1227 "calc2.tab.c" +break; +case 10: +#line 53 "calc2.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1232 "calc2.tab.c" +break; +case 11: +#line 55 "calc2.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1237 "calc2.tab.c" +break; +case 12: +#line 57 "calc2.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1242 "calc2.tab.c" +break; +case 13: +#line 59 "calc2.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1247 "calc2.tab.c" +break; +case 14: +#line 61 "calc2.y" + { yyval = - yystack.l_mark[0]; } +#line 1252 "calc2.tab.c" +break; +case 15: +#line 63 "calc2.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1257 "calc2.tab.c" +break; +case 17: +#line 68 "calc2.y" + { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1262 "calc2.tab.c" +break; +case 18: +#line 70 "calc2.y" + { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1267 "calc2.tab.c" +break; +#line 1269 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc2.tab.h b/test/btyacc/calc2.tab.h new file mode 100644 index 00000000000..3f0ce8e7972 --- /dev/null +++ b/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/test/btyacc/calc3.error b/test/btyacc/calc3.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/calc3.output b/test/btyacc/calc3.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/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/test/btyacc/calc3.tab.c b/test/btyacc/calc3.tab.c new file mode 100644 index 00000000000..d41506e7f26 --- /dev/null +++ b/test/btyacc/calc3.tab.c @@ -0,0 +1,1516 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT calc3_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const 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 + +#if YYDEBUG +int yydebug; +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +#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 477 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; + int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* 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 YYINT *yylexp = 0; + + static YYINT *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[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + + yyerrflag = 0; + yychar = 0; + memset(&yyval, 0, sizeof(yyval)); + memset(&yylval, 0, sizeof(yylval)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(&yyloc, 0, sizeof(yyloc)); + memset(&yylloc, 0, sizeof(yylloc)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 38 "calc3.y" + { yyerrok ; } +#line 1211 "calc3.tab.c" +break; +case 4: +#line 42 "calc3.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1216 "calc3.tab.c" +break; +case 5: +#line 44 "calc3.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1221 "calc3.tab.c" +break; +case 6: +#line 48 "calc3.y" + { yyval = yystack.l_mark[-1]; } +#line 1226 "calc3.tab.c" +break; +case 7: +#line 50 "calc3.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1231 "calc3.tab.c" +break; +case 8: +#line 52 "calc3.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1236 "calc3.tab.c" +break; +case 9: +#line 54 "calc3.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1241 "calc3.tab.c" +break; +case 10: +#line 56 "calc3.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1246 "calc3.tab.c" +break; +case 11: +#line 58 "calc3.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1251 "calc3.tab.c" +break; +case 12: +#line 60 "calc3.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1256 "calc3.tab.c" +break; +case 13: +#line 62 "calc3.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1261 "calc3.tab.c" +break; +case 14: +#line 64 "calc3.y" + { yyval = - yystack.l_mark[0]; } +#line 1266 "calc3.tab.c" +break; +case 15: +#line 66 "calc3.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1271 "calc3.tab.c" +break; +case 17: +#line 71 "calc3.y" + { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1276 "calc3.tab.c" +break; +case 18: +#line 73 "calc3.y" + { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1281 "calc3.tab.c" +break; +#line 1283 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc3.tab.h b/test/btyacc/calc3.tab.h new file mode 100644 index 00000000000..95fbe0b8dc0 --- /dev/null +++ b/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/test/btyacc/calc_code_all.error b/test/btyacc/calc_code_all.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/calc_code_all.output b/test/btyacc/calc_code_all.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/test/btyacc/calc_code_all.output @@ -0,0 +1,485 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 DIGIT + 3 258 LETTER + 4 124 '|' + 5 38 '&' + 6 43 '+' + 7 45 '-' + 8 42 '*' + 9 47 '/' + 10 37 '%' + 11 259 UMINUS + 12 10 '\n' + 13 61 '=' + 14 40 '(' + 15 41 ')' + 16 260 $accept + 17 261 list + 18 262 stat + 19 263 expr + 20 264 number diff --git a/test/btyacc/calc_code_all.tab.c b/test/btyacc/calc_code_all.tab.c new file mode 100644 index 00000000000..db6c86f38a9 --- /dev/null +++ b/test/btyacc/calc_code_all.tab.c @@ -0,0 +1,1517 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +/* %code "top" block start */ +#line 5 "calc_code_all.y" +/* CODE-TOP */ +/* %code "top" block end */ +#line 22 "calc_code_all.tab.c" +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_all_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_all_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_all_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_all_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_all_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_all_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_all_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_all_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_all_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_all_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_all_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_all_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_all_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_all_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_all_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_all_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_all_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_all_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_all_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_all_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_all_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_all_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_all_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_all_" + +#define YYPURE 0 + +#line 9 "calc_code_all.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 137 "calc_code_all.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_all_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_all_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_all_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT calc_code_all_stos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT calc_code_all_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_all_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_all_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT calc_code_all_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT calc_code_all_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_all_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_all_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT calc_code_all_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_all_name[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const calc_code_all_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +/* %code "requires" block start */ +#line 3 "calc_code_all.y" +/* CODE-REQUIRES */ +/* %code "requires" block end */ +#line 367 "calc_code_all.tab.c" + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ + +/* %code "provides" block start */ +#line 4 "calc_code_all.y" +/* CODE-PROVIDES */ +#line 6 "calc_code_all.y" +/* CODE-PROVIDES2 */ +/* %code "provides" block end */ +#line 488 "calc_code_all.tab.c" + +/* %code "" block start */ +#line 1 "calc_code_all.y" +/* CODE-DEFAULT2 */ +#line 2 "calc_code_all.y" +/* CODE-DEFAULT */ +/* %code "" block end */ +#line 496 "calc_code_all.tab.c" +#line 73 "calc_code_all.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 539 "calc_code_all.tab.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "calc_code_all.y" + { yyerrok ; } +#line 1212 "calc_code_all.tab.c" +break; +case 4: +#line 39 "calc_code_all.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1217 "calc_code_all.tab.c" +break; +case 5: +#line 41 "calc_code_all.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1222 "calc_code_all.tab.c" +break; +case 6: +#line 45 "calc_code_all.y" + { yyval = yystack.l_mark[-1]; } +#line 1227 "calc_code_all.tab.c" +break; +case 7: +#line 47 "calc_code_all.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1232 "calc_code_all.tab.c" +break; +case 8: +#line 49 "calc_code_all.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1237 "calc_code_all.tab.c" +break; +case 9: +#line 51 "calc_code_all.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1242 "calc_code_all.tab.c" +break; +case 10: +#line 53 "calc_code_all.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1247 "calc_code_all.tab.c" +break; +case 11: +#line 55 "calc_code_all.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1252 "calc_code_all.tab.c" +break; +case 12: +#line 57 "calc_code_all.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1257 "calc_code_all.tab.c" +break; +case 13: +#line 59 "calc_code_all.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1262 "calc_code_all.tab.c" +break; +case 14: +#line 61 "calc_code_all.y" + { yyval = - yystack.l_mark[0]; } +#line 1267 "calc_code_all.tab.c" +break; +case 15: +#line 63 "calc_code_all.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1272 "calc_code_all.tab.c" +break; +case 17: +#line 68 "calc_code_all.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1277 "calc_code_all.tab.c" +break; +case 18: +#line 70 "calc_code_all.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1282 "calc_code_all.tab.c" +break; +#line 1284 "calc_code_all.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc_code_all.tab.h b/test/btyacc/calc_code_all.tab.h new file mode 100644 index 00000000000..e79ea7ab930 --- /dev/null +++ b/test/btyacc/calc_code_all.tab.h @@ -0,0 +1,18 @@ +#ifndef _calc_code_all__defines_h_ +#define _calc_code_all__defines_h_ + +/* %code "requires" block start */ +#line 3 "calc_code_all.y" +/* CODE-REQUIRES */ +/* %code "requires" block end */ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +/* %code "provides" block start */ +#line 4 "calc_code_all.y" +/* CODE-PROVIDES */ +#line 6 "calc_code_all.y" +/* CODE-PROVIDES2 */ +/* %code "provides" block end */ + +#endif /* _calc_code_all__defines_h_ */ diff --git a/test/btyacc/calc_code_default.error b/test/btyacc/calc_code_default.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/calc_code_default.output b/test/btyacc/calc_code_default.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/test/btyacc/calc_code_default.output @@ -0,0 +1,485 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 DIGIT + 3 258 LETTER + 4 124 '|' + 5 38 '&' + 6 43 '+' + 7 45 '-' + 8 42 '*' + 9 47 '/' + 10 37 '%' + 11 259 UMINUS + 12 10 '\n' + 13 61 '=' + 14 40 '(' + 15 41 ')' + 16 260 $accept + 17 261 list + 18 262 stat + 19 263 expr + 20 264 number diff --git a/test/btyacc/calc_code_default.tab.c b/test/btyacc/calc_code_default.tab.c new file mode 100644 index 00000000000..e3c10d86f5f --- /dev/null +++ b/test/btyacc/calc_code_default.tab.c @@ -0,0 +1,1497 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_default_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_default_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_default_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_default_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_default_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_default_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_default_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_default_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_default_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_default_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_default_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_default_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_default_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_default_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_default_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_default_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_default_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_default_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_default_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_default_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_default_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_default_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_default_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_default_" + +#define YYPURE 0 + +#line 5 "calc_code_default.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 131 "calc_code_default.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_default_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_default_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_default_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT calc_code_default_stos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT calc_code_default_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_default_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_default_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT calc_code_default_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT calc_code_default_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_default_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_default_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT calc_code_default_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_default_name[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const calc_code_default_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ + +/* %code "" block start */ +#line 1 "calc_code_default.y" +/* CODE-DEFAULT */ +#line 2 "calc_code_default.y" +/* CODE-DEFAULT2 */ +/* %code "" block end */ +#line 476 "calc_code_default.tab.c" +#line 69 "calc_code_default.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 519 "calc_code_default.tab.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_default.y" + { yyerrok ; } +#line 1192 "calc_code_default.tab.c" +break; +case 4: +#line 35 "calc_code_default.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1197 "calc_code_default.tab.c" +break; +case 5: +#line 37 "calc_code_default.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1202 "calc_code_default.tab.c" +break; +case 6: +#line 41 "calc_code_default.y" + { yyval = yystack.l_mark[-1]; } +#line 1207 "calc_code_default.tab.c" +break; +case 7: +#line 43 "calc_code_default.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1212 "calc_code_default.tab.c" +break; +case 8: +#line 45 "calc_code_default.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1217 "calc_code_default.tab.c" +break; +case 9: +#line 47 "calc_code_default.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1222 "calc_code_default.tab.c" +break; +case 10: +#line 49 "calc_code_default.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1227 "calc_code_default.tab.c" +break; +case 11: +#line 51 "calc_code_default.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1232 "calc_code_default.tab.c" +break; +case 12: +#line 53 "calc_code_default.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1237 "calc_code_default.tab.c" +break; +case 13: +#line 55 "calc_code_default.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1242 "calc_code_default.tab.c" +break; +case 14: +#line 57 "calc_code_default.y" + { yyval = - yystack.l_mark[0]; } +#line 1247 "calc_code_default.tab.c" +break; +case 15: +#line 59 "calc_code_default.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1252 "calc_code_default.tab.c" +break; +case 17: +#line 64 "calc_code_default.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1257 "calc_code_default.tab.c" +break; +case 18: +#line 66 "calc_code_default.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1262 "calc_code_default.tab.c" +break; +#line 1264 "calc_code_default.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc_code_default.tab.h b/test/btyacc/calc_code_default.tab.h new file mode 100644 index 00000000000..6f673cc8bc1 --- /dev/null +++ b/test/btyacc/calc_code_default.tab.h @@ -0,0 +1,8 @@ +#ifndef _calc_code_default__defines_h_ +#define _calc_code_default__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _calc_code_default__defines_h_ */ diff --git a/test/btyacc/calc_code_imports.error b/test/btyacc/calc_code_imports.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/calc_code_imports.output b/test/btyacc/calc_code_imports.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/test/btyacc/calc_code_imports.output @@ -0,0 +1,485 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 DIGIT + 3 258 LETTER + 4 124 '|' + 5 38 '&' + 6 43 '+' + 7 45 '-' + 8 42 '*' + 9 47 '/' + 10 37 '%' + 11 259 UMINUS + 12 10 '\n' + 13 61 '=' + 14 40 '(' + 15 41 ')' + 16 260 $accept + 17 261 list + 18 262 stat + 19 263 expr + 20 264 number diff --git a/test/btyacc/calc_code_imports.tab.c b/test/btyacc/calc_code_imports.tab.c new file mode 100644 index 00000000000..4e1c27edfee --- /dev/null +++ b/test/btyacc/calc_code_imports.tab.c @@ -0,0 +1,1489 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_imports_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_imports_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_imports_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_imports_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_imports_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_imports_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_imports_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_imports_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_imports_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_imports_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_imports_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_imports_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_imports_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_imports_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_imports_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_imports_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_imports_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_imports_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_imports_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_imports_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_imports_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_imports_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_imports_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_imports_" + +#define YYPURE 0 + +#line 5 "calc_code_imports.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 131 "calc_code_imports.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_imports_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_imports_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_imports_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT calc_code_imports_stos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT calc_code_imports_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_imports_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_imports_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT calc_code_imports_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT calc_code_imports_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_imports_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_imports_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT calc_code_imports_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_imports_name[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const calc_code_imports_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 69 "calc_code_imports.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 511 "calc_code_imports.tab.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_imports.y" + { yyerrok ; } +#line 1184 "calc_code_imports.tab.c" +break; +case 4: +#line 35 "calc_code_imports.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1189 "calc_code_imports.tab.c" +break; +case 5: +#line 37 "calc_code_imports.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1194 "calc_code_imports.tab.c" +break; +case 6: +#line 41 "calc_code_imports.y" + { yyval = yystack.l_mark[-1]; } +#line 1199 "calc_code_imports.tab.c" +break; +case 7: +#line 43 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1204 "calc_code_imports.tab.c" +break; +case 8: +#line 45 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1209 "calc_code_imports.tab.c" +break; +case 9: +#line 47 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1214 "calc_code_imports.tab.c" +break; +case 10: +#line 49 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1219 "calc_code_imports.tab.c" +break; +case 11: +#line 51 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1224 "calc_code_imports.tab.c" +break; +case 12: +#line 53 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1229 "calc_code_imports.tab.c" +break; +case 13: +#line 55 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1234 "calc_code_imports.tab.c" +break; +case 14: +#line 57 "calc_code_imports.y" + { yyval = - yystack.l_mark[0]; } +#line 1239 "calc_code_imports.tab.c" +break; +case 15: +#line 59 "calc_code_imports.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1244 "calc_code_imports.tab.c" +break; +case 17: +#line 64 "calc_code_imports.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1249 "calc_code_imports.tab.c" +break; +case 18: +#line 66 "calc_code_imports.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1254 "calc_code_imports.tab.c" +break; +#line 1256 "calc_code_imports.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc_code_imports.tab.h b/test/btyacc/calc_code_imports.tab.h new file mode 100644 index 00000000000..eb8e7bc7339 --- /dev/null +++ b/test/btyacc/calc_code_imports.tab.h @@ -0,0 +1,8 @@ +#ifndef _calc_code_imports__defines_h_ +#define _calc_code_imports__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _calc_code_imports__defines_h_ */ diff --git a/test/btyacc/calc_code_provides.error b/test/btyacc/calc_code_provides.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/calc_code_provides.output b/test/btyacc/calc_code_provides.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/test/btyacc/calc_code_provides.output @@ -0,0 +1,485 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 DIGIT + 3 258 LETTER + 4 124 '|' + 5 38 '&' + 6 43 '+' + 7 45 '-' + 8 42 '*' + 9 47 '/' + 10 37 '%' + 11 259 UMINUS + 12 10 '\n' + 13 61 '=' + 14 40 '(' + 15 41 ')' + 16 260 $accept + 17 261 list + 18 262 stat + 19 263 expr + 20 264 number diff --git a/test/btyacc/calc_code_provides.tab.c b/test/btyacc/calc_code_provides.tab.c new file mode 100644 index 00000000000..d4895a6dda7 --- /dev/null +++ b/test/btyacc/calc_code_provides.tab.c @@ -0,0 +1,1497 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_provides_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_provides_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_provides_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_provides_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_provides_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_provides_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_provides_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_provides_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_provides_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_provides_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_provides_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_provides_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_provides_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_provides_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_provides_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_provides_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_provides_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_provides_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_provides_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_provides_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_provides_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_provides_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_provides_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_provides_" + +#define YYPURE 0 + +#line 5 "calc_code_provides.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 131 "calc_code_provides.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_provides_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_provides_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_provides_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT calc_code_provides_stos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT calc_code_provides_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_provides_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_provides_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT calc_code_provides_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT calc_code_provides_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_provides_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_provides_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT calc_code_provides_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_provides_name[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const calc_code_provides_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ + +/* %code "provides" block start */ +#line 1 "calc_code_provides.y" +/* CODE-PROVIDES */ +#line 2 "calc_code_provides.y" +/* CODE-PROVIDES2 */ +/* %code "provides" block end */ +#line 476 "calc_code_provides.tab.c" +#line 69 "calc_code_provides.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 519 "calc_code_provides.tab.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_provides.y" + { yyerrok ; } +#line 1192 "calc_code_provides.tab.c" +break; +case 4: +#line 35 "calc_code_provides.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1197 "calc_code_provides.tab.c" +break; +case 5: +#line 37 "calc_code_provides.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1202 "calc_code_provides.tab.c" +break; +case 6: +#line 41 "calc_code_provides.y" + { yyval = yystack.l_mark[-1]; } +#line 1207 "calc_code_provides.tab.c" +break; +case 7: +#line 43 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1212 "calc_code_provides.tab.c" +break; +case 8: +#line 45 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1217 "calc_code_provides.tab.c" +break; +case 9: +#line 47 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1222 "calc_code_provides.tab.c" +break; +case 10: +#line 49 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1227 "calc_code_provides.tab.c" +break; +case 11: +#line 51 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1232 "calc_code_provides.tab.c" +break; +case 12: +#line 53 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1237 "calc_code_provides.tab.c" +break; +case 13: +#line 55 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1242 "calc_code_provides.tab.c" +break; +case 14: +#line 57 "calc_code_provides.y" + { yyval = - yystack.l_mark[0]; } +#line 1247 "calc_code_provides.tab.c" +break; +case 15: +#line 59 "calc_code_provides.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1252 "calc_code_provides.tab.c" +break; +case 17: +#line 64 "calc_code_provides.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1257 "calc_code_provides.tab.c" +break; +case 18: +#line 66 "calc_code_provides.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1262 "calc_code_provides.tab.c" +break; +#line 1264 "calc_code_provides.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc_code_provides.tab.h b/test/btyacc/calc_code_provides.tab.h new file mode 100644 index 00000000000..1ca968af458 --- /dev/null +++ b/test/btyacc/calc_code_provides.tab.h @@ -0,0 +1,14 @@ +#ifndef _calc_code_provides__defines_h_ +#define _calc_code_provides__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +/* %code "provides" block start */ +#line 1 "calc_code_provides.y" +/* CODE-PROVIDES */ +#line 2 "calc_code_provides.y" +/* CODE-PROVIDES2 */ +/* %code "provides" block end */ + +#endif /* _calc_code_provides__defines_h_ */ diff --git a/test/btyacc/calc_code_requires.error b/test/btyacc/calc_code_requires.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/calc_code_requires.output b/test/btyacc/calc_code_requires.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/test/btyacc/calc_code_requires.output @@ -0,0 +1,485 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 DIGIT + 3 258 LETTER + 4 124 '|' + 5 38 '&' + 6 43 '+' + 7 45 '-' + 8 42 '*' + 9 47 '/' + 10 37 '%' + 11 259 UMINUS + 12 10 '\n' + 13 61 '=' + 14 40 '(' + 15 41 ')' + 16 260 $accept + 17 261 list + 18 262 stat + 19 263 expr + 20 264 number diff --git a/test/btyacc/calc_code_requires.tab.c b/test/btyacc/calc_code_requires.tab.c new file mode 100644 index 00000000000..f35103d30c4 --- /dev/null +++ b/test/btyacc/calc_code_requires.tab.c @@ -0,0 +1,1497 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_requires_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_requires_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_requires_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_requires_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_requires_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_requires_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_requires_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_requires_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_requires_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_requires_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_requires_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_requires_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_requires_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_requires_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_requires_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_requires_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_requires_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_requires_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_requires_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_requires_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_requires_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_requires_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_requires_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_requires_" + +#define YYPURE 0 + +#line 5 "calc_code_requires.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 131 "calc_code_requires.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_requires_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_requires_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_requires_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT calc_code_requires_stos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT calc_code_requires_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_requires_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_requires_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT calc_code_requires_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT calc_code_requires_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_requires_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_requires_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT calc_code_requires_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_requires_name[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const calc_code_requires_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +/* %code "requires" block start */ +#line 1 "calc_code_requires.y" +/* CODE-REQUIRES */ +#line 2 "calc_code_requires.y" +/* CODE-REQUIRES2 */ +/* %code "requires" block end */ +#line 363 "calc_code_requires.tab.c" + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 69 "calc_code_requires.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 519 "calc_code_requires.tab.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_requires.y" + { yyerrok ; } +#line 1192 "calc_code_requires.tab.c" +break; +case 4: +#line 35 "calc_code_requires.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1197 "calc_code_requires.tab.c" +break; +case 5: +#line 37 "calc_code_requires.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1202 "calc_code_requires.tab.c" +break; +case 6: +#line 41 "calc_code_requires.y" + { yyval = yystack.l_mark[-1]; } +#line 1207 "calc_code_requires.tab.c" +break; +case 7: +#line 43 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1212 "calc_code_requires.tab.c" +break; +case 8: +#line 45 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1217 "calc_code_requires.tab.c" +break; +case 9: +#line 47 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1222 "calc_code_requires.tab.c" +break; +case 10: +#line 49 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1227 "calc_code_requires.tab.c" +break; +case 11: +#line 51 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1232 "calc_code_requires.tab.c" +break; +case 12: +#line 53 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1237 "calc_code_requires.tab.c" +break; +case 13: +#line 55 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1242 "calc_code_requires.tab.c" +break; +case 14: +#line 57 "calc_code_requires.y" + { yyval = - yystack.l_mark[0]; } +#line 1247 "calc_code_requires.tab.c" +break; +case 15: +#line 59 "calc_code_requires.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1252 "calc_code_requires.tab.c" +break; +case 17: +#line 64 "calc_code_requires.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1257 "calc_code_requires.tab.c" +break; +case 18: +#line 66 "calc_code_requires.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1262 "calc_code_requires.tab.c" +break; +#line 1264 "calc_code_requires.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc_code_requires.tab.h b/test/btyacc/calc_code_requires.tab.h new file mode 100644 index 00000000000..d5b711b534a --- /dev/null +++ b/test/btyacc/calc_code_requires.tab.h @@ -0,0 +1,14 @@ +#ifndef _calc_code_requires__defines_h_ +#define _calc_code_requires__defines_h_ + +/* %code "requires" block start */ +#line 1 "calc_code_requires.y" +/* CODE-REQUIRES */ +#line 2 "calc_code_requires.y" +/* CODE-REQUIRES2 */ +/* %code "requires" block end */ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _calc_code_requires__defines_h_ */ diff --git a/test/btyacc/calc_code_top.error b/test/btyacc/calc_code_top.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/calc_code_top.output b/test/btyacc/calc_code_top.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/test/btyacc/calc_code_top.output @@ -0,0 +1,485 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 DIGIT + 3 258 LETTER + 4 124 '|' + 5 38 '&' + 6 43 '+' + 7 45 '-' + 8 42 '*' + 9 47 '/' + 10 37 '%' + 11 259 UMINUS + 12 10 '\n' + 13 61 '=' + 14 40 '(' + 15 41 ')' + 16 260 $accept + 17 261 list + 18 262 stat + 19 263 expr + 20 264 number diff --git a/test/btyacc/calc_code_top.tab.c b/test/btyacc/calc_code_top.tab.c new file mode 100644 index 00000000000..5875015a729 --- /dev/null +++ b/test/btyacc/calc_code_top.tab.c @@ -0,0 +1,1497 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +/* %code "top" block start */ +#line 1 "calc_code_top.y" +/* CODE-TOP */ +#line 2 "calc_code_top.y" +/* CODE-TOP2 */ +/* %code "top" block end */ +#line 24 "calc_code_top.tab.c" +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_top_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_top_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_top_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_top_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_top_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_top_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_top_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_top_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_top_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_top_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_top_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_top_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_top_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_top_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_top_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_top_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_top_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_top_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_top_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_top_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_top_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_top_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_top_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_top_" + +#define YYPURE 0 + +#line 5 "calc_code_top.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 139 "calc_code_top.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_top_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_top_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_top_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT calc_code_top_stos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT calc_code_top_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_top_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_top_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT calc_code_top_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT calc_code_top_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_top_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_top_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT calc_code_top_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_top_name[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const calc_code_top_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 69 "calc_code_top.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 519 "calc_code_top.tab.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_top.y" + { yyerrok ; } +#line 1192 "calc_code_top.tab.c" +break; +case 4: +#line 35 "calc_code_top.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1197 "calc_code_top.tab.c" +break; +case 5: +#line 37 "calc_code_top.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1202 "calc_code_top.tab.c" +break; +case 6: +#line 41 "calc_code_top.y" + { yyval = yystack.l_mark[-1]; } +#line 1207 "calc_code_top.tab.c" +break; +case 7: +#line 43 "calc_code_top.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1212 "calc_code_top.tab.c" +break; +case 8: +#line 45 "calc_code_top.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1217 "calc_code_top.tab.c" +break; +case 9: +#line 47 "calc_code_top.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1222 "calc_code_top.tab.c" +break; +case 10: +#line 49 "calc_code_top.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1227 "calc_code_top.tab.c" +break; +case 11: +#line 51 "calc_code_top.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1232 "calc_code_top.tab.c" +break; +case 12: +#line 53 "calc_code_top.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1237 "calc_code_top.tab.c" +break; +case 13: +#line 55 "calc_code_top.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1242 "calc_code_top.tab.c" +break; +case 14: +#line 57 "calc_code_top.y" + { yyval = - yystack.l_mark[0]; } +#line 1247 "calc_code_top.tab.c" +break; +case 15: +#line 59 "calc_code_top.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1252 "calc_code_top.tab.c" +break; +case 17: +#line 64 "calc_code_top.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1257 "calc_code_top.tab.c" +break; +case 18: +#line 66 "calc_code_top.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1262 "calc_code_top.tab.c" +break; +#line 1264 "calc_code_top.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/calc_code_top.tab.h b/test/btyacc/calc_code_top.tab.h new file mode 100644 index 00000000000..8be78b276e3 --- /dev/null +++ b/test/btyacc/calc_code_top.tab.h @@ -0,0 +1,8 @@ +#ifndef _calc_code_top__defines_h_ +#define _calc_code_top__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _calc_code_top__defines_h_ */ diff --git a/test/btyacc/code_calc.code.c b/test/btyacc/code_calc.code.c new file mode 100644 index 00000000000..d3d72a53977 --- /dev/null +++ b/test/btyacc/code_calc.code.c @@ -0,0 +1,1362 @@ +/* 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 2 +#define YYMINOR 0 +#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 4 "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 +#undef yytname +#define yytname yyname +#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 int 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 || defined(yytname) +extern const char *const yyname[]; +#endif +#if YYDEBUG +extern const char *const yyrule[]; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 70 "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 384 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 32 "code_calc.y" + { yyerrok ; } +#line 1057 "code_calc.code.c" +break; +case 4: +#line 36 "code_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1062 "code_calc.code.c" +break; +case 5: +#line 38 "code_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1067 "code_calc.code.c" +break; +case 6: +#line 42 "code_calc.y" + { yyval = yystack.l_mark[-1]; } +#line 1072 "code_calc.code.c" +break; +case 7: +#line 44 "code_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1077 "code_calc.code.c" +break; +case 8: +#line 46 "code_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1082 "code_calc.code.c" +break; +case 9: +#line 48 "code_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1087 "code_calc.code.c" +break; +case 10: +#line 50 "code_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1092 "code_calc.code.c" +break; +case 11: +#line 52 "code_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1097 "code_calc.code.c" +break; +case 12: +#line 54 "code_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1102 "code_calc.code.c" +break; +case 13: +#line 56 "code_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1107 "code_calc.code.c" +break; +case 14: +#line 58 "code_calc.y" + { yyval = - yystack.l_mark[0]; } +#line 1112 "code_calc.code.c" +break; +case 15: +#line 60 "code_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1117 "code_calc.code.c" +break; +case 17: +#line 65 "code_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1122 "code_calc.code.c" +break; +case 18: +#line 67 "code_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1127 "code_calc.code.c" +break; +#line 1129 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/code_calc.error b/test/btyacc/code_calc.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/code_calc.output b/test/btyacc/code_calc.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/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/test/btyacc/code_calc.tab.c b/test/btyacc/code_calc.tab.c new file mode 100644 index 00000000000..c6c5048a40d --- /dev/null +++ b/test/btyacc/code_calc.tab.c @@ -0,0 +1,165 @@ +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +typedef int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +const YYINT calc_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +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", +}; +#if YYDEBUG +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/test/btyacc/code_calc.tab.h b/test/btyacc/code_calc.tab.h new file mode 100644 index 00000000000..0b129daa6a2 --- /dev/null +++ b/test/btyacc/code_calc.tab.h @@ -0,0 +1,10 @@ +#ifndef _calc__defines_h_ +#define _calc__defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#undef yytname +#define yytname yyname + +#endif /* _calc__defines_h_ */ diff --git a/test/btyacc/code_error.code.c b/test/btyacc/code_error.code.c new file mode 100644 index 00000000000..ac48dbb523b --- /dev/null +++ b/test/btyacc/code_error.code.c @@ -0,0 +1,1256 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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 || defined(yytname) +extern const char *const yyname[]; +#endif +#if YYDEBUG +extern const char *const yyrule[]; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 354 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/code_error.error b/test/btyacc/code_error.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/code_error.output b/test/btyacc/code_error.output new file mode 100644 index 00000000000..1e56c214a6c --- /dev/null +++ b/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/test/btyacc/code_error.tab.c b/test/btyacc/code_error.tab.c new file mode 100644 index 00000000000..1037951653e --- /dev/null +++ b/test/btyacc/code_error.tab.c @@ -0,0 +1,61 @@ +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +typedef int YYINT; +const YYINT error_lhs[] = { -1, + 0, +}; +const YYINT error_len[] = { 2, + 1, +}; +const YYINT error_defred[] = { 0, + 1, 0, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +const YYINT error_stos[] = { 0, + 256, 258, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +const YYINT error_ctable[] = { -1, +}; +#endif +#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/test/btyacc/code_error.tab.h b/test/btyacc/code_error.tab.h new file mode 100644 index 00000000000..f9e5ad278cc --- /dev/null +++ b/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/test/btyacc/defines1.calc.c b/test/btyacc/defines1.calc.c new file mode 100644 index 00000000000..66ea979d0ce --- /dev/null +++ b/test/btyacc/defines1.calc.c @@ -0,0 +1,1396 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 34 "y.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT yystos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT yycindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT yyctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 418 "y.tab.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 1091 "y.tab.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1096 "y.tab.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1101 "y.tab.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 1106 "y.tab.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1111 "y.tab.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1116 "y.tab.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1121 "y.tab.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1126 "y.tab.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1131 "y.tab.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1136 "y.tab.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1141 "y.tab.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 1146 "y.tab.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1151 "y.tab.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1156 "y.tab.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1161 "y.tab.c" +break; +#line 1163 "y.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/defines1.calc.h b/test/btyacc/defines1.calc.h new file mode 100644 index 00000000000..64c392589c0 --- /dev/null +++ b/test/btyacc/defines1.calc.h @@ -0,0 +1,8 @@ +#ifndef _yy_defines_h_ +#define _yy_defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _yy_defines_h_ */ diff --git a/test/btyacc/defines1.error b/test/btyacc/defines1.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/defines1.output b/test/btyacc/defines1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/defines2.calc.c b/test/btyacc/defines2.calc.c new file mode 100644 index 00000000000..66ea979d0ce --- /dev/null +++ b/test/btyacc/defines2.calc.c @@ -0,0 +1,1396 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 34 "y.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT yystos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT yycindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT yyctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 418 "y.tab.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 1091 "y.tab.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1096 "y.tab.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1101 "y.tab.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 1106 "y.tab.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1111 "y.tab.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1116 "y.tab.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1121 "y.tab.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1126 "y.tab.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1131 "y.tab.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1136 "y.tab.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1141 "y.tab.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 1146 "y.tab.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1151 "y.tab.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1156 "y.tab.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1161 "y.tab.c" +break; +#line 1163 "y.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/defines2.calc.h b/test/btyacc/defines2.calc.h new file mode 100644 index 00000000000..64c392589c0 --- /dev/null +++ b/test/btyacc/defines2.calc.h @@ -0,0 +1,8 @@ +#ifndef _yy_defines_h_ +#define _yy_defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _yy_defines_h_ */ diff --git a/test/btyacc/defines2.error b/test/btyacc/defines2.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/defines2.output b/test/btyacc/defines2.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/defines3.calc.c b/test/btyacc/defines3.calc.c new file mode 100644 index 00000000000..5902efe905f --- /dev/null +++ b/test/btyacc/defines3.calc.c @@ -0,0 +1,1396 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 34 "prefix.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT yystos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT yycindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT yyctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 418 "prefix.tab.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 1091 "prefix.tab.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1096 "prefix.tab.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1101 "prefix.tab.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 1106 "prefix.tab.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1111 "prefix.tab.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1116 "prefix.tab.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1121 "prefix.tab.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1126 "prefix.tab.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1131 "prefix.tab.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1136 "prefix.tab.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1141 "prefix.tab.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 1146 "prefix.tab.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1151 "prefix.tab.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1156 "prefix.tab.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1161 "prefix.tab.c" +break; +#line 1163 "prefix.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/defines3.calc.h b/test/btyacc/defines3.calc.h new file mode 100644 index 00000000000..64c392589c0 --- /dev/null +++ b/test/btyacc/defines3.calc.h @@ -0,0 +1,8 @@ +#ifndef _yy_defines_h_ +#define _yy_defines_h_ + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 + +#endif /* _yy_defines_h_ */ diff --git a/test/btyacc/defines3.error b/test/btyacc/defines3.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/defines3.output b/test/btyacc/defines3.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/empty.error b/test/btyacc/empty.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/empty.output b/test/btyacc/empty.output new file mode 100644 index 00000000000..bb2b6a9e348 --- /dev/null +++ b/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/test/btyacc/empty.tab.c b/test/btyacc/empty.tab.c new file mode 100644 index 00000000000..d42eb64eb79 --- /dev/null +++ b/test/btyacc/empty.tab.c @@ -0,0 +1,1275 @@ +/* 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 2 +#define YYMINOR 0 +#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 int YYINT; +static const YYINT empty_lhs[] = { -1, + 0, +}; +static const YYINT empty_len[] = { 2, + 0, +}; +static const YYINT empty_defred[] = { 1, + 0, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT empty_stos[] = { 0, + 258, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT empty_ctable[] = { -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 13 "empty.y" + +#include + +static int +YYLEX_DECL() { + return -1; +} + +static void +YYERROR_DECL() { + printf("%s\n",s); +} +#line 373 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/empty.tab.h b/test/btyacc/empty.tab.h new file mode 100644 index 00000000000..14683cfeab2 --- /dev/null +++ b/test/btyacc/empty.tab.h @@ -0,0 +1,5 @@ +#ifndef _empty__defines_h_ +#define _empty__defines_h_ + + +#endif /* _empty__defines_h_ */ diff --git a/test/btyacc/err_inherit1.error b/test/btyacc/err_inherit1.error new file mode 100644 index 00000000000..203b9063e90 --- /dev/null +++ b/test/btyacc/err_inherit1.error @@ -0,0 +1,3 @@ +YACC: e - line 64 of "./err_inherit1.y", unterminated argument list +namelist($c, $t + ^ diff --git a/test/btyacc/err_inherit1.output b/test/btyacc/err_inherit1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_inherit1.tab.c b/test/btyacc/err_inherit1.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_inherit1.tab.h b/test/btyacc/err_inherit1.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_inherit2.error b/test/btyacc/err_inherit2.error new file mode 100644 index 00000000000..c016b63f179 --- /dev/null +++ b/test/btyacc/err_inherit2.error @@ -0,0 +1,5 @@ +YACC: w - line 64 of "./err_inherit2.y", number of arguments of namelist doesn't agree with previous declaration +YACC: w - line 64 of "./err_inherit2.y", type of argument 1 to namelist doesn't agree with previous declaration +YACC: e - line 64 of "./err_inherit2.y", bad formal argument list +namelist($c, $t, extra): namelist NAME + ^ diff --git a/test/btyacc/err_inherit2.output b/test/btyacc/err_inherit2.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_inherit2.tab.c b/test/btyacc/err_inherit2.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_inherit2.tab.h b/test/btyacc/err_inherit2.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_inherit3.error b/test/btyacc/err_inherit3.error new file mode 100644 index 00000000000..e0ab28a9179 --- /dev/null +++ b/test/btyacc/err_inherit3.error @@ -0,0 +1,23 @@ +YACC: w - line 64 of "./err_inherit3.y", number of arguments of namelist doesn't agree with previous declaration +YACC: w - line 64 of "./err_inherit3.y", wrong number of arguments for namelist +namelist: namelist($c) NAME + ^ +YACC: w - line 64 of "./err_inherit3.y", unknown argument $c +YACC: w - line 64 of "./err_inherit3.y", untyped argument $c +YACC: w - line 65 of "./err_inherit3.y", unknown argument $t + { $$->s = mksymbol($t, $c, $2); + ^ +YACC: w - line 65 of "./err_inherit3.y", unknown argument $c + { $$->s = mksymbol($t, $c, $2); + ^ +YACC: w - line 69 of "./err_inherit3.y", unknown argument $t + { $$->s = mksymbol($t, $c, $1); + ^ +YACC: w - line 69 of "./err_inherit3.y", untyped argument $t +YACC: w - line 69 of "./err_inherit3.y", unknown argument $c + { $$->s = mksymbol($t, $c, $1); + ^ +YACC: w - line 69 of "./err_inherit3.y", untyped argument $c +YACC: w - line 0 of "./err_inherit3.y", start symbol declaration requires arguments +YACC: 1 rule never reduced +YACC: 3 shift/reduce conflicts. diff --git a/test/btyacc/err_inherit3.output b/test/btyacc/err_inherit3.output new file mode 100644 index 00000000000..3a362a96c40 --- /dev/null +++ b/test/btyacc/err_inherit3.output @@ -0,0 +1,216 @@ + 0 $accept : declaration $end + + 1 $$1 : + + 2 $$2 : + + 3 declaration : class type $$1 $$2 namelist + 4 | type locnamelist + + 5 class : GLOBAL + 6 | LOCAL + + 7 type : REAL + 8 | INTEGER + + 9 $$3 : + + 10 namelist : $$3 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 . (5) + + . reduce 5 + + +state 2 + class : LOCAL . (6) + + . reduce 6 + + +state 3 + type : REAL . (7) + + . reduce 7 + + +state 4 + type : INTEGER . (8) + + . reduce 8 + + +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 . locnamelist (4) + $$4 : . (12) + + . reduce 12 + + locnamelist goto 9 + $$4 goto 10 + + +state 8 + declaration : class type . $$1 $$2 namelist (3) + $$1 : . (1) + + . reduce 1 + + $$1 goto 11 + + +state 9 + declaration : type locnamelist . (4) + + . reduce 4 + + +state 10 + locnamelist : $$4 . $$2 namelist (13) + $$2 : . (2) + + . reduce 2 + + $$2 goto 12 + + +state 11 + declaration : class type $$1 . $$2 namelist (3) + $$2 : . (2) + + . reduce 2 + + $$2 goto 13 + + +12: shift/reduce conflict (shift 14, reduce 9) on NAME +state 12 + locnamelist : $$4 $$2 . namelist (13) + $$3 : . (9) + + NAME shift 14 + + namelist goto 15 + $$3 goto 16 + + +13: shift/reduce conflict (shift 14, reduce 9) on NAME +state 13 + declaration : class type $$1 $$2 . namelist (3) + $$3 : . (9) + + NAME shift 14 + + namelist goto 17 + $$3 goto 16 + + +state 14 + namelist : NAME . (11) + + . reduce 11 + + +state 15 + locnamelist : $$4 $$2 namelist . (13) + + . reduce 13 + + +16: shift/reduce conflict (shift 14, reduce 9) on NAME +state 16 + namelist : $$3 . namelist NAME (10) + $$3 : . (9) + + NAME shift 14 + + namelist goto 18 + $$3 goto 16 + + +state 17 + declaration : class type $$1 $$2 namelist . (3) + + . reduce 3 + + +state 18 + namelist : $$3 namelist . NAME (10) + + NAME shift 19 + . error + + +state 19 + namelist : $$3 namelist NAME . (10) + + . reduce 10 + + +Rules never reduced: + $$3 : (9) + + +State 12 contains 1 shift/reduce conflict. +State 13 contains 1 shift/reduce conflict. +State 16 contains 1 shift/reduce conflict. + + +7 terminals, 10 nonterminals +14 grammar rules, 20 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/test/btyacc/err_inherit3.tab.c b/test/btyacc/err_inherit3.tab.c new file mode 100644 index 00000000000..d0ca88d9005 --- /dev/null +++ b/test/btyacc/err_inherit3.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 2 +#define YYMINOR 0 +#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 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 39 "err_inherit3.y" +typedef union YYSTYPE +{ + 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 int YYINT; +static const YYINT err_inherit3_lhs[] = { -1, + 5, 6, 0, 0, 3, 3, 4, 4, 7, 1, + 1, 8, 2, +}; +static const YYINT err_inherit3_len[] = { 2, + 0, 0, 5, 2, 1, 1, 1, 1, 0, 3, + 1, 0, 3, +}; +static const YYINT err_inherit3_defred[] = { 0, + 5, 6, 7, 8, 0, 0, 12, 1, 4, 2, + 2, 0, 0, 11, 13, 0, 3, 0, 10, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT err_inherit3_stos[] = { 0, + 257, 258, 259, 260, 263, 266, 267, 267, 265, 271, + 268, 269, 269, 261, 264, 270, 264, 264, 261, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT err_inherit3_dgoto[] = { 5, + 15, 9, 6, 7, 11, 12, 16, 10, +}; +static const YYINT err_inherit3_sindex[] = { -257, + 0, 0, 0, 0, 0, -254, 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, +}; +#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, +}; +#endif +static const YYINT err_inherit3_gindex[] = { 0, + -9, 0, 0, 4, 0, 1, 0, 0, +}; +#define YYTABLESIZE 12 +static const YYINT err_inherit3_table[] = { 1, + 2, 3, 4, 17, 3, 4, 18, 14, 19, 8, + 0, 13, +}; +static const YYINT err_inherit3_check[] = { 257, + 258, 259, 260, 13, 259, 260, 16, 261, 261, 6, + -1, 11, +}; +#if YYBTYACC +static const YYINT err_inherit3_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, +}; +#endif +#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 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","illegal-symbol", +}; +static const char *const err_inherit3_rule[] = { +"$accept : declaration", +"$$1 :", +"$$2 :", +"declaration : class type $$1 $$2 namelist", +"declaration : type locnamelist", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"$$3 :", +"namelist : $$3 namelist NAME", +"namelist : NAME", +"$$4 :", +"locnamelist : $$4 $$2 namelist", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 78 "err_inherit3.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 425 "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); + } + } +#line 444 "err_inherit3.tab.c" + break; + 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); + } + } +#line 456 "err_inherit3.tab.c" + break; + 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); + } + } +#line 468 "err_inherit3.tab.c" + break; + } +} +#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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: +#line 50 "err_inherit3.y" +yyval.cval = yystack.l_mark[-1].cval; +#line 1146 "err_inherit3.tab.c" +break; +case 2: +#line 50 "err_inherit3.y" +yyval.tval = yystack.l_mark[-1].tval; +#line 1151 "err_inherit3.tab.c" +break; +case 3: +#line 51 "err_inherit3.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +#line 1156 "err_inherit3.tab.c" +break; +case 4: +#line 53 "err_inherit3.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +#line 1161 "err_inherit3.tab.c" +break; +case 5: +#line 56 "err_inherit3.y" + { yyval.cval = cGLOBAL; } +#line 1166 "err_inherit3.tab.c" +break; +case 6: +#line 57 "err_inherit3.y" + { yyval.cval = cLOCAL; } +#line 1171 "err_inherit3.tab.c" +break; +case 7: +#line 60 "err_inherit3.y" + { yyval.tval = tREAL; } +#line 1176 "err_inherit3.tab.c" +break; +case 8: +#line 61 "err_inherit3.y" + { yyval.tval = tINTEGER; } +#line 1181 "err_inherit3.tab.c" +break; +case 9: +#line 64 "err_inherit3.y" +yyval.cval = yystack.l_mark[-2]; +#line 1186 "err_inherit3.tab.c" +break; +case 10: +#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; + } +#line 1193 "err_inherit3.tab.c" +break; +case 11: +#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; + } +#line 1200 "err_inherit3.tab.c" +break; +case 12: +#line 74 "err_inherit3.y" +yyval.cval = cLOCAL; +#line 1205 "err_inherit3.tab.c" +break; +case 13: +#line 75 "err_inherit3.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +#line 1210 "err_inherit3.tab.c" +break; +#line 1212 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/err_inherit3.tab.h b/test/btyacc/err_inherit3.tab.h new file mode 100644 index 00000000000..1018167b685 --- /dev/null +++ b/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 YYSTYPE +{ + 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/test/btyacc/err_inherit4.error b/test/btyacc/err_inherit4.error new file mode 100644 index 00000000000..20aa216ba23 --- /dev/null +++ b/test/btyacc/err_inherit4.error @@ -0,0 +1,13 @@ +YACC: w - line 32 of "./err_inherit4.y", destructor redeclared +%destructor { + ^ +YACC: w - line 77 of "./err_inherit4.y", wrong number of default arguments for namelist + { $$ = $1; @$ = @2; } + ^ +YACC: w - line 77 of "./err_inherit4.y", wrong type for default argument 2 to namelist + { $$ = $1; @$ = @2; } + ^ +YACC: w - line 77 of "./err_inherit4.y", wrong type for default argument 1 to namelist + { $$ = $1; @$ = @2; } + ^ +YACC: w - line 77 of "./err_inherit4.y", @2 references beyond the end of the current rule diff --git a/test/btyacc/err_inherit4.output b/test/btyacc/err_inherit4.output new file mode 100644 index 00000000000..ef7ccb88d50 --- /dev/null +++ b/test/btyacc/err_inherit4.output @@ -0,0 +1,165 @@ + 0 $accept : declaration $end + + 1 $$1 : + + 2 $$2 : + + 3 declaration : class type $$1 $$2 namelist + 4 | type locnamelist + + 5 class : GLOBAL + 6 | LOCAL + + 7 type : REAL + 8 | INTEGER + + 9 namelist : namelist NAME + 10 | NAME + + 11 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 . (5) + + . reduce 5 + + +state 2 + class : LOCAL . (6) + + . reduce 6 + + +state 3 + type : REAL . (7) + + . reduce 7 + + +state 4 + type : INTEGER . (8) + + . reduce 8 + + +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 . locnamelist (4) + + NAME shift 9 + . error + + namelist goto 10 + locnamelist goto 11 + + +state 8 + declaration : class type . $$1 $$2 namelist (3) + $$1 : . (1) + + . reduce 1 + + $$1 goto 12 + + +state 9 + namelist : NAME . (10) + + . reduce 10 + + +state 10 + namelist : namelist . NAME (9) + locnamelist : namelist . (11) + + NAME shift 13 + $end reduce 11 + + +state 11 + declaration : type locnamelist . (4) + + . reduce 4 + + +state 12 + declaration : class type $$1 . $$2 namelist (3) + $$2 : . (2) + + . reduce 2 + + $$2 goto 14 + + +state 13 + namelist : namelist NAME . (9) + + . reduce 9 + + +state 14 + declaration : class type $$1 $$2 . namelist (3) + + NAME shift 9 + . error + + namelist goto 15 + + +state 15 + declaration : class type $$1 $$2 namelist . (3) + namelist : namelist . NAME (9) + + NAME shift 13 + $end reduce 3 + + +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/test/btyacc/err_inherit4.tab.c b/test/btyacc/err_inherit4.tab.c new file mode 100644 index 00000000000..3fd7e55b6aa --- /dev/null +++ b/test/btyacc/err_inherit4.tab.c @@ -0,0 +1,1433 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 41 "err_inherit4.y" +typedef union YYSTYPE +{ + 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; + unsigned source; +} YYLTYPE; +#define YYLTYPE_IS_DECLARED 1 +#endif +#define YYRHSLOC(rhs, k) ((rhs)[k]) + +/* 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 int YYINT; +static const YYINT err_inherit4_lhs[] = { -1, + 5, 6, 0, 0, 3, 3, 4, 4, 1, 1, + 2, +}; +static const YYINT err_inherit4_len[] = { 2, + 0, 0, 5, 2, 1, 1, 1, 1, 2, 1, + 1, +}; +static const YYINT err_inherit4_defred[] = { 0, + 5, 6, 7, 8, 0, 0, 0, 1, 10, 0, + 4, 2, 9, 0, 0, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT err_inherit4_stos[] = { 0, + 257, 258, 259, 260, 263, 266, 267, 267, 261, 264, + 265, 268, 261, 269, 264, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT err_inherit4_dgoto[] = { 5, + 10, 11, 6, 7, 12, 14, +}; +static const YYINT err_inherit4_sindex[] = { -257, + 0, 0, 0, 0, 0, -255, -254, 0, 0, -253, + 0, 0, 0, -254, -253, +}; +static const YYINT err_inherit4_rindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, + 0, 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, +}; +#endif +static const YYINT err_inherit4_gindex[] = { 0, + -4, 0, 0, 5, 0, 0, +}; +#define YYTABLESIZE 11 +static const YYINT err_inherit4_table[] = { 1, + 2, 3, 4, 3, 4, 11, 9, 13, 3, 15, + 8, +}; +static const YYINT err_inherit4_check[] = { 257, + 258, 259, 260, 259, 260, 0, 261, 261, 0, 14, + 6, +}; +#if YYBTYACC +static const YYINT err_inherit4_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#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 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","illegal-symbol", +}; +static const char *const err_inherit4_rule[] = { +"$accept : declaration", +"$$1 :", +"$$2 :", +"declaration : class type $$1 $$2 namelist", +"declaration : type locnamelist", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"namelist : namelist NAME", +"namelist : NAME", +"locnamelist : namelist", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 80 "err_inherit4.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 444 "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" + { } +#line 456 "err_inherit4.tab.c" + break; + case 264: +#line 28 "err_inherit4.y" + { } +#line 461 "err_inherit4.tab.c" + break; + case 265: +#line 28 "err_inherit4.y" + { } +#line 466 "err_inherit4.tab.c" + break; + } +} +#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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: +#line 52 "err_inherit4.y" +yyval.cval = yystack.l_mark[-1].cval; +#line 1144 "err_inherit4.tab.c" +break; +case 2: +#line 52 "err_inherit4.y" +yyval.tval = yystack.l_mark[-1].tval; +#line 1149 "err_inherit4.tab.c" +break; +case 3: +#line 53 "err_inherit4.y" + { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[0]; } +#line 1154 "err_inherit4.tab.c" +break; +case 4: +#line 55 "err_inherit4.y" + { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[-3]; } +#line 1159 "err_inherit4.tab.c" +break; +case 5: +#line 58 "err_inherit4.y" + { yyval.cval = cGLOBAL; } +#line 1164 "err_inherit4.tab.c" +break; +case 6: +#line 59 "err_inherit4.y" + { yyval.cval = cLOCAL; } +#line 1169 "err_inherit4.tab.c" +break; +case 7: +#line 62 "err_inherit4.y" + { yyval.tval = tREAL; } +#line 1174 "err_inherit4.tab.c" +break; +case 8: +#line 63 "err_inherit4.y" + { yyval.tval = tINTEGER; } +#line 1179 "err_inherit4.tab.c" +break; +case 9: +#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; + } +#line 1186 "err_inherit4.tab.c" +break; +case 10: +#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; + } +#line 1193 "err_inherit4.tab.c" +break; +case 11: +#line 77 "err_inherit4.y" + { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[1]; } +#line 1198 "err_inherit4.tab.c" +break; +#line 1200 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/err_inherit4.tab.h b/test/btyacc/err_inherit4.tab.h new file mode 100644 index 00000000000..b8c5c281761 --- /dev/null +++ b/test/btyacc/err_inherit4.tab.h @@ -0,0 +1,40 @@ +#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 YYSTYPE +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE err_inherit4_lval; + +#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; + unsigned source; +} YYLTYPE; +#define YYLTYPE_IS_DECLARED 1 +#endif +#define YYRHSLOC(rhs, k) ((rhs)[k]) +extern YYLTYPE err_inherit4_lloc; + +#endif /* _err_inherit4__defines_h_ */ diff --git a/test/btyacc/err_inherit5.error b/test/btyacc/err_inherit5.error new file mode 100644 index 00000000000..ceabc34591b --- /dev/null +++ b/test/btyacc/err_inherit5.error @@ -0,0 +1 @@ +YACC: e - line 74 of "./err_inherit5.y", illegal @$ or @N reference diff --git a/test/btyacc/err_inherit5.output b/test/btyacc/err_inherit5.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_inherit5.tab.c b/test/btyacc/err_inherit5.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_inherit5.tab.h b/test/btyacc/err_inherit5.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax1.error b/test/btyacc/err_syntax1.error new file mode 100644 index 00000000000..5df5c22ef17 --- /dev/null +++ b/test/btyacc/err_syntax1.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./err_syntax1.y", syntax error + ?% { + ^ diff --git a/test/btyacc/err_syntax1.output b/test/btyacc/err_syntax1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax1.tab.c b/test/btyacc/err_syntax1.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax1.tab.h b/test/btyacc/err_syntax1.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax10.error b/test/btyacc/err_syntax10.error new file mode 100644 index 00000000000..61a72c0408a --- /dev/null +++ b/test/btyacc/err_syntax10.error @@ -0,0 +1,3 @@ +YACC: w - line 7 of "./err_syntax10.y", the type of '(' has been redeclared +YACC: w - line 7 of "./err_syntax10.y", the type of '*' has been redeclared +YACC: w - line 7 of "./err_syntax10.y", the type of '&' has been redeclared diff --git a/test/btyacc/err_syntax10.output b/test/btyacc/err_syntax10.output new file mode 100644 index 00000000000..3d9210a70ed --- /dev/null +++ b/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/test/btyacc/err_syntax10.tab.c b/test/btyacc/err_syntax10.tab.c new file mode 100644 index 00000000000..f025eadecd6 --- /dev/null +++ b/test/btyacc/err_syntax10.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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT err_syntax10_stos[] = { 0, + 256, 258, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT err_syntax10_ctable[] = { -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 372 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/err_syntax10.tab.h b/test/btyacc/err_syntax10.tab.h new file mode 100644 index 00000000000..b9f412593fd --- /dev/null +++ b/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/test/btyacc/err_syntax11.error b/test/btyacc/err_syntax11.error new file mode 100644 index 00000000000..b2dd79c5050 --- /dev/null +++ b/test/btyacc/err_syntax11.error @@ -0,0 +1 @@ +YACC: w - line 7 of "./err_syntax11.y", the precedence of '|' has been redeclared diff --git a/test/btyacc/err_syntax11.output b/test/btyacc/err_syntax11.output new file mode 100644 index 00000000000..bc5e66d9886 --- /dev/null +++ b/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/test/btyacc/err_syntax11.tab.c b/test/btyacc/err_syntax11.tab.c new file mode 100644 index 00000000000..41f794fd7cd --- /dev/null +++ b/test/btyacc/err_syntax11.tab.c @@ -0,0 +1,1280 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT err_syntax11_stos[] = { 0, + 256, 258, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT err_syntax11_ctable[] = { -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 378 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/err_syntax11.tab.h b/test/btyacc/err_syntax11.tab.h new file mode 100644 index 00000000000..bfe5d07a7df --- /dev/null +++ b/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/test/btyacc/err_syntax12.error b/test/btyacc/err_syntax12.error new file mode 100644 index 00000000000..358960bdb9e --- /dev/null +++ b/test/btyacc/err_syntax12.error @@ -0,0 +1 @@ +YACC: w - line 7 of "./err_syntax12.y", the value of text has been redeclared diff --git a/test/btyacc/err_syntax12.output b/test/btyacc/err_syntax12.output new file mode 100644 index 00000000000..6e792d6dfde --- /dev/null +++ b/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/test/btyacc/err_syntax12.tab.c b/test/btyacc/err_syntax12.tab.c new file mode 100644 index 00000000000..fe194ce2a0e --- /dev/null +++ b/test/btyacc/err_syntax12.tab.c @@ -0,0 +1,1286 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT err_syntax12_stos[] = { 0, + 256, 458, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT err_syntax12_ctable[] = { -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 384 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/err_syntax12.tab.h b/test/btyacc/err_syntax12.tab.h new file mode 100644 index 00000000000..6fda3d1e968 --- /dev/null +++ b/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/test/btyacc/err_syntax13.error b/test/btyacc/err_syntax13.error new file mode 100644 index 00000000000..9ffa8b40c27 --- /dev/null +++ b/test/btyacc/err_syntax13.error @@ -0,0 +1 @@ +YACC: e - line 7 of "./err_syntax13.y", the start symbol text is a token diff --git a/test/btyacc/err_syntax13.output b/test/btyacc/err_syntax13.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax13.tab.c b/test/btyacc/err_syntax13.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax13.tab.h b/test/btyacc/err_syntax13.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax14.error b/test/btyacc/err_syntax14.error new file mode 100644 index 00000000000..73e9f7c8319 --- /dev/null +++ b/test/btyacc/err_syntax14.error @@ -0,0 +1,2 @@ +YACC: w - line 7 of "./err_syntax14.y", the start symbol has been redeclared +YACC: e - the start symbol text2 is undefined diff --git a/test/btyacc/err_syntax14.output b/test/btyacc/err_syntax14.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax14.tab.c b/test/btyacc/err_syntax14.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax14.tab.h b/test/btyacc/err_syntax14.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax15.error b/test/btyacc/err_syntax15.error new file mode 100644 index 00000000000..36dc03fef8b --- /dev/null +++ b/test/btyacc/err_syntax15.error @@ -0,0 +1 @@ +YACC: e - line 9 of "./err_syntax15.y", no grammar has been specified diff --git a/test/btyacc/err_syntax15.output b/test/btyacc/err_syntax15.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax15.tab.c b/test/btyacc/err_syntax15.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax15.tab.h b/test/btyacc/err_syntax15.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax16.error b/test/btyacc/err_syntax16.error new file mode 100644 index 00000000000..6ff15897045 --- /dev/null +++ b/test/btyacc/err_syntax16.error @@ -0,0 +1 @@ +YACC: e - line 14 of "./err_syntax16.y", a token appears on the lhs of a production diff --git a/test/btyacc/err_syntax16.output b/test/btyacc/err_syntax16.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax16.tab.c b/test/btyacc/err_syntax16.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax16.tab.h b/test/btyacc/err_syntax16.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax17.error b/test/btyacc/err_syntax17.error new file mode 100644 index 00000000000..8a8b64b0712 --- /dev/null +++ b/test/btyacc/err_syntax17.error @@ -0,0 +1,3 @@ +YACC: e - line 8 of "./err_syntax17.y", unterminated action +S: { error + ^ diff --git a/test/btyacc/err_syntax17.output b/test/btyacc/err_syntax17.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax17.tab.c b/test/btyacc/err_syntax17.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax17.tab.h b/test/btyacc/err_syntax17.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax18.error b/test/btyacc/err_syntax18.error new file mode 100644 index 00000000000..c52fd71a1ec --- /dev/null +++ b/test/btyacc/err_syntax18.error @@ -0,0 +1 @@ +YACC: w - line 9 of "./err_syntax18.y", $4 references beyond the end of the current rule diff --git a/test/btyacc/err_syntax18.output b/test/btyacc/err_syntax18.output new file mode 100644 index 00000000000..216fb71b6f9 --- /dev/null +++ b/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/test/btyacc/err_syntax18.tab.c b/test/btyacc/err_syntax18.tab.c new file mode 100644 index 00000000000..633a96c1958 --- /dev/null +++ b/test/btyacc/err_syntax18.tab.c @@ -0,0 +1,1289 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT err_syntax18_stos[] = { 0, + 40, 258, 258, 41, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT err_syntax18_ctable[] = { -1, + -1, -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 381 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: +#line 9 "err_syntax18.y" + { yyval = yystack.l_mark[1]; } +#line 1054 "err_syntax18.tab.c" +break; +#line 1056 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/err_syntax18.tab.h b/test/btyacc/err_syntax18.tab.h new file mode 100644 index 00000000000..f08352a9b17 --- /dev/null +++ b/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/test/btyacc/err_syntax19.error b/test/btyacc/err_syntax19.error new file mode 100644 index 00000000000..2499b7fc4f1 --- /dev/null +++ b/test/btyacc/err_syntax19.error @@ -0,0 +1,3 @@ +YACC: e - line 9 of "./err_syntax19.y", illegal $-name + { $$ = $; } + ^ diff --git a/test/btyacc/err_syntax19.output b/test/btyacc/err_syntax19.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax19.tab.c b/test/btyacc/err_syntax19.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax19.tab.h b/test/btyacc/err_syntax19.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax2.error b/test/btyacc/err_syntax2.error new file mode 100644 index 00000000000..29fe56c28b4 --- /dev/null +++ b/test/btyacc/err_syntax2.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./err_syntax2.y", unmatched /* +%{ /* + ^ diff --git a/test/btyacc/err_syntax2.output b/test/btyacc/err_syntax2.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax2.tab.c b/test/btyacc/err_syntax2.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax2.tab.h b/test/btyacc/err_syntax2.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax20.error b/test/btyacc/err_syntax20.error new file mode 100644 index 00000000000..76dac8152de --- /dev/null +++ b/test/btyacc/err_syntax20.error @@ -0,0 +1 @@ +YACC: w - the symbol recur is undefined diff --git a/test/btyacc/err_syntax20.output b/test/btyacc/err_syntax20.output new file mode 100644 index 00000000000..f0378d42e95 --- /dev/null +++ b/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/test/btyacc/err_syntax20.tab.c b/test/btyacc/err_syntax20.tab.c new file mode 100644 index 00000000000..2c249c4c252 --- /dev/null +++ b/test/btyacc/err_syntax20.tab.c @@ -0,0 +1,1284 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT err_syntax20_stos[] = { 0, + 40, 259, 257, 41, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT err_syntax20_ctable[] = { -1, + -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 376 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: +#line 12 "err_syntax20.y" + { yystack.l_mark[-1].rechk = 3; } +#line 1049 "err_syntax20.tab.c" +break; +#line 1051 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/err_syntax20.tab.h b/test/btyacc/err_syntax20.tab.h new file mode 100644 index 00000000000..fb019706fb2 --- /dev/null +++ b/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/test/btyacc/err_syntax21.error b/test/btyacc/err_syntax21.error new file mode 100644 index 00000000000..9b0dc17b662 --- /dev/null +++ b/test/btyacc/err_syntax21.error @@ -0,0 +1 @@ +YACC: e - line 12 of "./err_syntax21.y", $0 is untyped diff --git a/test/btyacc/err_syntax21.output b/test/btyacc/err_syntax21.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax21.tab.c b/test/btyacc/err_syntax21.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax21.tab.h b/test/btyacc/err_syntax21.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax22.error b/test/btyacc/err_syntax22.error new file mode 100644 index 00000000000..8622aa73f59 --- /dev/null +++ b/test/btyacc/err_syntax22.error @@ -0,0 +1 @@ +YACC: e - line 17 of "./err_syntax22.y", $2 (recur) is untyped diff --git a/test/btyacc/err_syntax22.output b/test/btyacc/err_syntax22.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax22.tab.c b/test/btyacc/err_syntax22.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax22.tab.h b/test/btyacc/err_syntax22.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax23.error b/test/btyacc/err_syntax23.error new file mode 100644 index 00000000000..3ccbbd1fee8 --- /dev/null +++ b/test/btyacc/err_syntax23.error @@ -0,0 +1 @@ +YACC: e - line 18 of "./err_syntax23.y", $$ is untyped diff --git a/test/btyacc/err_syntax23.output b/test/btyacc/err_syntax23.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax23.tab.c b/test/btyacc/err_syntax23.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax23.tab.h b/test/btyacc/err_syntax23.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax24.error b/test/btyacc/err_syntax24.error new file mode 100644 index 00000000000..e8bbfeca35f --- /dev/null +++ b/test/btyacc/err_syntax24.error @@ -0,0 +1,2 @@ +YACC: w - line 21 of "./err_syntax24.y", the default action for expr assigns an undefined value to $$ +YACC: e - line 22 of "./err_syntax24.y", $$ is untyped diff --git a/test/btyacc/err_syntax24.output b/test/btyacc/err_syntax24.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax24.tab.c b/test/btyacc/err_syntax24.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax24.tab.h b/test/btyacc/err_syntax24.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax25.error b/test/btyacc/err_syntax25.error new file mode 100644 index 00000000000..234a7b9fcd3 --- /dev/null +++ b/test/btyacc/err_syntax25.error @@ -0,0 +1,3 @@ +YACC: e - line 11 of "./err_syntax25.y", too many %union declarations +%union { +^ diff --git a/test/btyacc/err_syntax25.output b/test/btyacc/err_syntax25.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax25.tab.c b/test/btyacc/err_syntax25.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax25.tab.h b/test/btyacc/err_syntax25.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax26.error b/test/btyacc/err_syntax26.error new file mode 100644 index 00000000000..c9a09ad1992 --- /dev/null +++ b/test/btyacc/err_syntax26.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./err_syntax26.y", unexpected end-of-file diff --git a/test/btyacc/err_syntax26.output b/test/btyacc/err_syntax26.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax26.tab.c b/test/btyacc/err_syntax26.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax26.tab.h b/test/btyacc/err_syntax26.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax27.error b/test/btyacc/err_syntax27.error new file mode 100644 index 00000000000..2a277087c35 --- /dev/null +++ b/test/btyacc/err_syntax27.error @@ -0,0 +1 @@ +YACC: e - line 3 of "./err_syntax27.y", missing '}' diff --git a/test/btyacc/err_syntax27.output b/test/btyacc/err_syntax27.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax27.tab.c b/test/btyacc/err_syntax27.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax27.tab.h b/test/btyacc/err_syntax27.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax3.error b/test/btyacc/err_syntax3.error new file mode 100644 index 00000000000..7e4871b87ad --- /dev/null +++ b/test/btyacc/err_syntax3.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax3.y", unterminated string +%token '(' '*' '& + ^ diff --git a/test/btyacc/err_syntax3.output b/test/btyacc/err_syntax3.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax3.tab.c b/test/btyacc/err_syntax3.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax3.tab.h b/test/btyacc/err_syntax3.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax4.error b/test/btyacc/err_syntax4.error new file mode 100644 index 00000000000..6a10d4040eb --- /dev/null +++ b/test/btyacc/err_syntax4.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./err_syntax4.y", unmatched %{ +%{ +^ diff --git a/test/btyacc/err_syntax4.output b/test/btyacc/err_syntax4.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax4.tab.c b/test/btyacc/err_syntax4.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax4.tab.h b/test/btyacc/err_syntax4.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax5.error b/test/btyacc/err_syntax5.error new file mode 100644 index 00000000000..37a8500b053 --- /dev/null +++ b/test/btyacc/err_syntax5.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax5.y", unterminated %union declaration +%union { +^ diff --git a/test/btyacc/err_syntax5.output b/test/btyacc/err_syntax5.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax5.tab.c b/test/btyacc/err_syntax5.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax5.tab.h b/test/btyacc/err_syntax5.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax6.error b/test/btyacc/err_syntax6.error new file mode 100644 index 00000000000..bde624a7159 --- /dev/null +++ b/test/btyacc/err_syntax6.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax6.y", illegal tag +%token '\777' + ^ diff --git a/test/btyacc/err_syntax7.output b/test/btyacc/err_syntax7.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax7.tab.c b/test/btyacc/err_syntax7.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax7.tab.h b/test/btyacc/err_syntax7.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax7a.error b/test/btyacc/err_syntax7a.error new file mode 100644 index 00000000000..213711e11ff --- /dev/null +++ b/test/btyacc/err_syntax7a.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax7a.y", illegal character +%token '\xfff' + ^ diff --git a/test/btyacc/err_syntax7a.output b/test/btyacc/err_syntax7a.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax7a.tab.c b/test/btyacc/err_syntax7a.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax7a.tab.h b/test/btyacc/err_syntax7a.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax7b.error b/test/btyacc/err_syntax7b.error new file mode 100644 index 00000000000..19b617ccca1 --- /dev/null +++ b/test/btyacc/err_syntax7b.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax7b.y", illegal character +%token '\x.' + ^ diff --git a/test/btyacc/err_syntax7b.output b/test/btyacc/err_syntax7b.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax7b.tab.c b/test/btyacc/err_syntax7b.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax7b.tab.h b/test/btyacc/err_syntax7b.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax8.error b/test/btyacc/err_syntax8.error new file mode 100644 index 00000000000..c6a4cc943fa --- /dev/null +++ b/test/btyacc/err_syntax8.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./err_syntax8.y", illegal use of reserved symbol . diff --git a/test/btyacc/err_syntax8.output b/test/btyacc/err_syntax8.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax8.tab.c b/test/btyacc/err_syntax8.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax8.tab.h b/test/btyacc/err_syntax8.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax8a.error b/test/btyacc/err_syntax8a.error new file mode 100644 index 00000000000..ed503e90451 --- /dev/null +++ b/test/btyacc/err_syntax8a.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./err_syntax8a.y", illegal use of reserved symbol $$123 diff --git a/test/btyacc/err_syntax8a.output b/test/btyacc/err_syntax8a.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax8a.tab.c b/test/btyacc/err_syntax8a.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax8a.tab.h b/test/btyacc/err_syntax8a.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax9.error b/test/btyacc/err_syntax9.error new file mode 100644 index 00000000000..1f74b7ea0a2 --- /dev/null +++ b/test/btyacc/err_syntax9.error @@ -0,0 +1 @@ +YACC: e - line 7 of "./err_syntax9.y", the start symbol text cannot be declared to be a token diff --git a/test/btyacc/err_syntax9.output b/test/btyacc/err_syntax9.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/err_syntax9.tab.c b/test/btyacc/err_syntax9.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/btyacc/err_syntax9.tab.h b/test/btyacc/err_syntax9.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/error.error b/test/btyacc/error.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/error.output b/test/btyacc/error.output new file mode 100644 index 00000000000..1e56c214a6c --- /dev/null +++ b/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/test/btyacc/error.tab.c b/test/btyacc/error.tab.c new file mode 100644 index 00000000000..cfd6fc01026 --- /dev/null +++ b/test/btyacc/error.tab.c @@ -0,0 +1,1279 @@ +/* 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 2 +#define YYMINOR 0 +#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 int YYINT; +static const YYINT error_lhs[] = { -1, + 0, +}; +static const YYINT error_len[] = { 2, + 1, +}; +static const YYINT error_defred[] = { 0, + 1, 0, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT error_stos[] = { 0, + 256, 258, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT error_ctable[] = { -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 377 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/error.tab.h b/test/btyacc/error.tab.h new file mode 100644 index 00000000000..f9e5ad278cc --- /dev/null +++ b/test/btyacc/error.tab.h @@ -0,0 +1,5 @@ +#ifndef _error__defines_h_ +#define _error__defines_h_ + + +#endif /* _error__defines_h_ */ diff --git a/test/btyacc/expr.oxout.error b/test/btyacc/expr.oxout.error new file mode 100644 index 00000000000..58fdb1c267f --- /dev/null +++ b/test/btyacc/expr.oxout.error @@ -0,0 +1 @@ +YACC: w - line 6 of "expr.Y", the precedence of '*' has been redeclared diff --git a/test/btyacc/expr.oxout.output b/test/btyacc/expr.oxout.output new file mode 100644 index 00000000000..e5021d2de45 --- /dev/null +++ b/test/btyacc/expr.oxout.output @@ -0,0 +1,227 @@ + 0 $accept : yyyAugNonterm $end + + 1 $$1 : + + 2 yyyAugNonterm : $$1 s + + 3 s : expr + + 4 expr : expr '*' expr + 5 | expr '+' expr + 6 | expr '/' expr + 7 | expr '-' expr + 8 | '(' expr ')' + 9 | ID + 10 | CONST + +state 0 + $accept : . yyyAugNonterm $end (0) + $$1 : . (1) + + . reduce 1 + + yyyAugNonterm goto 1 + $$1 goto 2 + + +state 1 + $accept : yyyAugNonterm . $end (0) + + $end accept + + +state 2 + yyyAugNonterm : $$1 . s (2) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + s goto 6 + expr goto 7 + + +state 3 + expr : ID . (9) + + . reduce 9 + + +state 4 + expr : CONST . (10) + + . reduce 10 + + +state 5 + expr : '(' . expr ')' (8) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 8 + + +state 6 + yyyAugNonterm : $$1 s . (2) + + . reduce 2 + + +state 7 + s : expr . (3) + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + + '+' shift 9 + '-' shift 10 + '*' shift 11 + '/' shift 12 + $end reduce 3 + + +state 8 + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + expr : '(' expr . ')' (8) + + '+' shift 9 + '-' shift 10 + '*' shift 11 + '/' shift 12 + ')' shift 13 + . error + + +state 9 + expr : expr '+' . expr (5) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 14 + + +state 10 + expr : expr '-' . expr (7) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 15 + + +state 11 + expr : expr '*' . expr (4) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 16 + + +state 12 + expr : expr '/' . expr (6) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 17 + + +state 13 + expr : '(' expr ')' . (8) + + . reduce 8 + + +state 14 + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr '+' expr . (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + + '*' shift 11 + '/' shift 12 + $end reduce 5 + '+' reduce 5 + '-' reduce 5 + ')' reduce 5 + + +state 15 + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + expr : expr '-' expr . (7) + + '*' shift 11 + '/' shift 12 + $end reduce 7 + '+' reduce 7 + '-' reduce 7 + ')' reduce 7 + + +state 16 + expr : expr . '*' expr (4) + expr : expr '*' expr . (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + + . reduce 4 + + +state 17 + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr '/' expr . (6) + expr : expr . '-' expr (7) + + '*' shift 11 + $end reduce 6 + '+' reduce 6 + '-' reduce 6 + '/' reduce 6 + ')' reduce 6 + + +10 terminals, 5 nonterminals +11 grammar rules, 18 states + +grammar parser grammar +symbol# value# symbol + 0 0 $end + 1 256 error + 2 257 ID + 3 258 CONST + 4 43 '+' + 5 45 '-' + 6 42 '*' + 7 47 '/' + 8 40 '(' + 9 41 ')' + 10 259 $accept + 11 260 yyyAugNonterm + 12 261 s + 13 262 $$1 + 14 263 expr diff --git a/test/btyacc/expr.oxout.tab.c b/test/btyacc/expr.oxout.tab.c new file mode 100644 index 00000000000..92952b1092c --- /dev/null +++ b/test/btyacc/expr.oxout.tab.c @@ -0,0 +1,2768 @@ +/* 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 2 +#define YYMINOR 0 +#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 expr_oxout_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex expr_oxout_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror expr_oxout_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar expr_oxout_char +#endif /* yychar */ + +#ifndef yyval +#define yyval expr_oxout_val +#endif /* yyval */ + +#ifndef yylval +#define yylval expr_oxout_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug expr_oxout_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs expr_oxout_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag expr_oxout_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs expr_oxout_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen expr_oxout_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred expr_oxout_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos expr_oxout_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto expr_oxout_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex expr_oxout_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex expr_oxout_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex expr_oxout_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable expr_oxout_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck expr_oxout_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname expr_oxout_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule expr_oxout_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex expr_oxout_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable expr_oxout_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "expr_oxout_" + +#define YYPURE 0 + +#line 5 "expr.oxout.y" +#include +#include +#line 8 "expr.Y" + +#include "expr.oxout.h" +#include + +extern int yylex(void); +extern void yyerror(const char *); +#line 27 "expr.oxout.y" +#include +#define yyyR USHRT_MAX +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 31 "expr.oxout.y" +typedef union YYSTYPE { +struct yyyOxAttrbs { +struct yyyStackItem *yyyOxStackItem; +} yyyOxAttrbs; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 38 "expr.oxout.y" +#include +#include + +static int yyyYok = 1; + +extern yyyFT yyyRCIL[]; + +void yyyExecuteRRsection(yyyGNT *rootNode); +void yyyYoxInit(void); +void yyyDecorate(void); +struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ +void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); +void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); +void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); +void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); +void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); +void yyyabort(void); + +#line 166 "expr.oxout.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 ID 257 +#define CONST 258 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT expr_oxout_lhs[] = { -1, + 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, +}; +static const YYINT expr_oxout_len[] = { 2, + 0, 2, 1, 3, 3, 3, 3, 3, 1, 1, +}; +static const YYINT expr_oxout_defred[] = { 1, + 0, 0, 9, 10, 0, 2, 0, 0, 0, 0, + 0, 0, 8, 0, 0, 4, 0, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT expr_oxout_stos[] = { 0, + 260, 262, 257, 258, 40, 261, 263, 263, 43, 45, + 42, 47, 41, 263, 263, 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT expr_oxout_dgoto[] = { 1, + 6, 2, 7, +}; +static const YYINT expr_oxout_sindex[] = { 0, + 0, -40, 0, 0, -40, 0, -18, -24, -40, -40, + -40, -40, 0, -37, -37, 0, -39, +}; +static const YYINT expr_oxout_rindex[] = { 0, + 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, + 0, 0, 0, 2, 8, 0, 1, +}; +#if YYBTYACC +static const YYINT expr_oxout_cindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, +}; +#endif +static const YYINT expr_oxout_gindex[] = { 0, + 0, 0, 4, +}; +#define YYTABLESIZE 218 +static const YYINT expr_oxout_table[] = { 5, + 6, 5, 11, 0, 11, 3, 0, 7, 8, 12, + 0, 0, 14, 15, 16, 17, 13, 11, 9, 0, + 10, 0, 12, 11, 9, 0, 10, 0, 12, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 6, 5, 6, 5, 6, 5, 6, 7, 0, + 7, 0, 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, 4, +}; +static const YYINT expr_oxout_check[] = { 40, + 0, 0, 42, -1, 42, 0, -1, 0, 5, 47, + -1, -1, 9, 10, 11, 12, 41, 42, 43, -1, + 45, -1, 47, 42, 43, -1, 45, -1, 47, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 41, 41, 43, 43, 45, 45, 47, 41, -1, + 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 257, 258, +}; +#if YYBTYACC +static const YYINT expr_oxout_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 258 +#define YYUNDFTOKEN 264 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const expr_oxout_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,"error","ID", +"CONST","$accept","yyyAugNonterm","s","$$1","expr","illegal-symbol", +}; +static const char *const expr_oxout_rule[] = { +"$accept : yyyAugNonterm", +"$$1 :", +"yyyAugNonterm : $$1 s", +"s : expr", +"expr : expr '*' expr", +"expr : expr '+' expr", +"expr : expr '/' expr", +"expr : expr '-' expr", +"expr : '(' expr ')'", +"expr : ID", +"expr : CONST", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 53 "expr.Y" + + +int yyparse(void); + +int main() + {yyparse(); + } + + + +#line 138 "expr.oxout.y" +long yyySSALspaceSize = 20000; +long yyyRSmaxSize = 1000; +long yyyTravStackMaxSize = 2000; + +struct yyySolvedSAlistCell {yyyWAT attrbNum; + long next; + }; + +#define yyyLambdaSSAL 0 +long yyySSALCfreeList = yyyLambdaSSAL; +long yyyNewSSALC = 1; + +struct yyySolvedSAlistCell *yyySSALspace; + +long yyyNbytesStackStg; + + + +yyyFT yyyRCIL[1]; + +short yyyIIIEL[] = {0, +0,2,6,10,14,18,22,24, +}; + +long yyyIIEL[] = { +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,1, +}; + +long yyyIEL[] = { +0,0,0, +}; + +yyyFT yyyEntL[1]; + +void yyyfatal(char *msg) +{fputs(msg,stderr);exit(-1);} + + + +#define yyySSALof 'S' +#define yyyRSof 'q' +#define yyyTSof 't' + + + +void yyyHandleOverflow(char which) + {char *msg1 = "?", *msg2; + long oldSize = 0, newSize; + switch(which) + { + case yyySSALof : + msg1 = "SSAL overflow: "; + oldSize = yyySSALspaceSize; + break; + case yyyRSof : + msg1 = "ready set overflow: "; + oldSize = yyyRSmaxSize; + break; + case yyyTSof : + msg1 = "traversal stack overflow: "; + oldSize = yyyTravStackMaxSize; + break; + default :; + } + newSize = (3*oldSize)/2; + if (newSize < 100) newSize = 100; + fputs(msg1,stderr); + fprintf(stderr,"size was %ld.\n",oldSize); + msg2 = " Have to modify evaluator: -Y%c%ld.\n"; + fprintf(stderr,msg2,which,newSize); + exit(-1); + } + + + +void yyySignalEnts(yyyGNT *node,long startP,long stopP) + {yyyGNT *dumNode; + + while (startP < stopP) + { + if (!yyyEntL[startP]) dumNode = node; + else dumNode = (node->cL)[yyyEntL[startP]-1]; + if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] + ) + ) + ) + { + if (++yyyRSTop == yyyAfterRS) + {yyyHandleOverflow(yyyRSof); + break; + } + yyyRSTop->node = dumNode; + yyyRSTop->whichSym = yyyEntL[startP]; + yyyRSTop->wa = yyyEntL[startP+1]; + } + startP += 2; + } + } + + + + + + +void yyySolveAndSignal() { +long yyyiDum,*yyypL; +int yyyws,yyywa; +yyyGNT *yyyRSTopN,*yyyRefN; +yyyParent yyyRSTopNp; + + +yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; +yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; +yyywa = yyyRSTop->wa; +yyyRSTop--; +switch(yyyRefN->prodNum) { +case 1: /***yacc rule 1***/ + switch (yyyws) { + } +break; +case 2: /***yacc rule 2***/ + switch (yyyws) { + } +break; +case 3: /***yacc rule 3***/ + switch (yyyws) { + } +break; +case 4: /***yacc rule 4***/ + switch (yyyws) { + } +break; +case 5: /***yacc rule 5***/ + switch (yyyws) { + } +break; +case 6: /***yacc rule 6***/ + switch (yyyws) { + } +break; +case 7: /***yacc rule 7***/ + switch (yyyws) { + case 1: /**/ + switch (yyywa) { + } + break; + } +break; +case 8: /***yacc rule 8***/ + switch (yyyws) { + case 1: /**/ + switch (yyywa) { + } + break; + } +break; +} /* switch */ + +if (yyyws) /* the just-solved instance was inherited. */ + {if (yyyRSTopN->prodNum) + {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; + yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], + yyyIEL[yyyiDum+1] + ); + } + } + else /* the just-solved instance was synthesized. */ + {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ + {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + + yyyRSTopN->whichSym + ] + + yyywa; + yyySignalEnts(yyyRSTopNp.noderef, + yyyIEL[yyyiDum], + yyyIEL[yyyiDum+1] + ); + } + else /* node is still on the stack--it has no parent yet. */ + {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); + if (yyySSALCfreeList == yyyLambdaSSAL) + {yyySSALspace[yyyNewSSALC].next = *yyypL; + if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) + yyyHandleOverflow(yyySSALof); + } + else + {yyyiDum = yyySSALCfreeList; + yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; + yyySSALspace[yyyiDum].next = *yyypL; + *yyypL = yyyiDum; + } + yyySSALspace[*yyypL].attrbNum = yyywa; + } + } + +} /* yyySolveAndSignal */ + + + + + + +#define condStg unsigned int conds; +#define yyyClearConds {yyyTST->conds = 0;} +#define yyySetCond(n) {yyyTST->conds += (1<<(n));} +#define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) + + + +struct yyyTravStackItem {yyyGNT *node; + char isReady; + condStg + }; + + + +void yyyDoTraversals(yyyGNT *rootNode) +{struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; + yyyGNT *yyyTSTn,**yyyCLptr2; + int yyyi,yyyRL,yyyPass; + int i; + + if (!yyyYok) return; + if ((yyyTravStack = + ((struct yyyTravStackItem *) + calloc((size_t)yyyTravStackMaxSize, + (size_t)sizeof(struct yyyTravStackItem) + ) + ) + ) + == + (struct yyyTravStackItem *)NULL + ) + {fputs("malloc error in traversal stack allocation\n",stderr); + exit(-1); + } + +yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; +yyyTravStack++; + + +for (yyyi=0; yyyi<2; yyyi++) { +yyyTST = yyyTravStack; +yyyTST->node = rootNode; +yyyTST->isReady = 0; +yyyClearConds + +while(yyyTST >= yyyTravStack) + {yyyTSTn = yyyTST->node; + if (yyyTST->isReady) + {yyyPass = 1; + goto yyyTravSwitch; +yyyTpop: + yyyTST--; + } + else + {yyyPass = 0; + goto yyyTravSwitch; +yyyTpush: + yyyTST->isReady = 1; + if (yyyTSTn->prodNum) + {if (yyyRL) + {yyyCLptr2 = yyyTSTn->cL; + i = yyyTSTn->cLlen; + while (i--) + {if (++yyyTST == yyyAfterTravStack) + yyyHandleOverflow(yyyTSof); + else + {yyyTST->node = *yyyCLptr2; + yyyTST->isReady = 0; + yyyClearConds + } + yyyCLptr2++; + } + } /* right to left */ + else /* left to right */ + {i = yyyTSTn->cLlen; + yyyCLptr2 = yyyTSTn->cL + i; + while (i--) + {yyyCLptr2--; + if (++yyyTST == yyyAfterTravStack) + yyyHandleOverflow(yyyTSof); + else + {yyyTST->node = *yyyCLptr2; + yyyTST->isReady = 0; + yyyClearConds + } + } + } /* left to right */ + } + } /* else */ + continue; +yyyTravSwitch: + switch(yyyTSTn->prodNum) { +case 1: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + +if (! +#line 24 "expr.Y" + (1) +#line 444 "expr.oxout.y" +) yyySetCond(1) +yyySetCond(2) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 24 "expr.Y" + +#line 453 "expr.oxout.y" +} +if (yyyCond(1) != yyyPass) { +#line 24 "expr.Y" + printf("\n"); + +#line 459 "expr.oxout.y" +} +if (yyyCond(2) != yyyPass) { +#line 25 "expr.Y" + printf("prefix: "); + +#line 465 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; +if ( +#line 23 "expr.Y" + (1) +#line 477 "expr.oxout.y" +) yyySetCond(2) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 22 "expr.Y" + printf("\n"); + +#line 486 "expr.oxout.y" +} +if (yyyCond(1) != yyyPass) { +#line 23 "expr.Y" + +#line 491 "expr.oxout.y" +} +if (yyyCond(2) != yyyPass) { +#line 23 "expr.Y" + printf("postfix: "); + +#line 497 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 2: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 29 "expr.Y" + printf(" * "); + +#line 518 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 28 "expr.Y" + printf(" * "); + +#line 533 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 3: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 32 "expr.Y" + printf(" + "); + +#line 554 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 33 "expr.Y" + printf(" + "); + +#line 569 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 4: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 37 "expr.Y" + printf(" / "); + +#line 590 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 36 "expr.Y" + printf(" / "); + +#line 605 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 5: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 41 "expr.Y" + printf(" - "); + +#line 626 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 40 "expr.Y" + printf(" - "); + +#line 641 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 6: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + + break; + } + break; + } + +break; +case 7: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 46 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 685 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 45 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 700 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 8: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 50 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 721 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 49 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 736 "expr.oxout.y" +} + break; + } + break; + } + +break; + } /* switch */ + if (yyyPass) goto yyyTpop; else goto yyyTpush; + } /* while */ + } /* for */ +} /* yyyDoTraversals */ + +void yyyExecuteRRsection(yyyGNT *rootNode) { + int yyyi; + long cycleSum = 0; + long nNZrc = 0; + + if (!yyyYok) return; + yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); + if (nNZrc) + { + fputs("\n\n\n**********\n",stderr); + fputs("cycle detected in completed parse tree",stderr); + fputs(" after decoration.\n",stderr); +#if CYCLE_VERBOSE + fprintf(stderr, + "number of unsolved attribute instances == %ld.\n", + nNZrc + ); + fprintf(stderr, + "total number of remaining dependencies == %ld.\n", + cycleSum + ); + fputs("average number of remaining dependencies\n",stderr); + fprintf(stderr," per unsolved instance == %f.\n", + ((float)(cycleSum)/(float)(nNZrc)) + ); +#endif + fprintf(stderr, + "searching parse tree for %ld unsolved instances:\n", + nNZrc + ); + yyyUnsolvedInstSearchTravAux(rootNode); + } + yyyDoTraversals(rootNode); +} /* yyyExecuteRRsection */ + + + +yyyWAT yyyLRCIL[2] = {0,0, +}; + + + +void yyyYoxInit(void) + { + static int yyyInitDone = 0; + if (yyyInitDone) return; + + if ((yyyRS = (yyyRSitem *) + calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(yyyRSitem)) + ) + == + ((yyyRSitem *) NULL) + ) + yyyfatal("malloc error in ox ready set space allocation\n"); + yyyRS++; + yyyAfterRS = yyyRS + yyyRSmaxSize; + + + if ((yyySSALspace = (struct yyySolvedSAlistCell *) + calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) + ) + == + ((struct yyySolvedSAlistCell *) NULL) + ) + yyyfatal("malloc error in stack solved list space allocation\n"); + yyyInitDone = 1; + + yyyRSTop = yyyRS - 1; + } /* yyyYoxInit */ + + + +void yyyDecorate(void) + { + while (yyyRSTop >= yyyRS) + yyySolveAndSignal(); + } + + + +void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) + {yyyWST i; + yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; + yyyGNT *gnpDum; + va_list ap; + + *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); + if (*yyyOxStackItem == (yyySIT *) NULL) + yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); + (*yyyOxStackItem)->node = + (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); + if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) + yyyfatal("malloc error in ox node space allocation\n"); + (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; + (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; + (*yyyOxStackItem)->node->parentIsStack = 1; + (*yyyOxStackItem)->node->cLlen = yyyRHSlength; + (*yyyOxStackItem)->node->cL = + (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); + if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) + yyyfatal("malloc error in ox child list space allocation\n"); + (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; + (*yyyOxStackItem)->node->refCountList = + (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); + if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) + yyyfatal("malloc error in ox reference count list space allocation\n"); + (*yyyOxStackItem)->node->prodNum = (int) yyyProdNum; + va_start(ap, yyval_OxAttrbs); + for (i=1;i<=yyyRHSlength;i++) + {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; + gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; + gnpDum->whichSym = i; + gnpDum->parent.noderef = (*yyyOxStackItem)->node; + gnpDum->parentIsStack = 0; + } + va_end(ap); + } + + + +#define yyyDECORfREQ 50 + + + +void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) + {yyyWST i; + yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; + long SSALptr,SSALptrHead,*cPtrPtr; + long *pL; + yyyGNT *gnpDum; + long iTemp; + long nextP; + static unsigned short intNodeCount = yyyDECORfREQ; + va_list ap; + + nextP = startP; + while (nextP < stopP) + {if (yyyRCIL[nextP] == yyyR) + {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; + } + else + {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; + } + nextP += 3; + } + pL = yyyIIEL + yyyIIIEL[yyyProdNum]; + va_start(ap, yyval_OxAttrbs); + for (i=1;i<=yyyRHSlength;i++) + {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; + pL++; + SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); + if (SSALptr != yyyLambdaSSAL) + {*cPtrPtr = yyyLambdaSSAL; + do + { + iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); + yyySignalEnts(yyyOxStackItem->node, + yyyIEL[iTemp], + yyyIEL[iTemp+1] + ); + SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); + } + while (SSALptr != yyyLambdaSSAL); + *cPtrPtr = yyySSALCfreeList; + yyySSALCfreeList = SSALptrHead; + } + } + va_end(ap); + nextP = startP + 2; + while (nextP < stopP) + {if (!yyyRCIL[nextP]) + {if (yyyRCIL[nextP-2] == yyyR) + {pL = &(yyyOxStackItem->solvedSAlist); + if (yyySSALCfreeList == yyyLambdaSSAL) + {yyySSALspace[yyyNewSSALC].next = *pL; + if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) + yyyHandleOverflow(yyySSALof); + } + else + {iTemp = yyySSALCfreeList; + yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; + yyySSALspace[iTemp].next = *pL; + *pL = iTemp; + } + yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; + } + else + {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) + { + iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; + yyySignalEnts(gnpDum, + yyyIEL[iTemp], + yyyIEL[iTemp+1] + ); + } + } + } + nextP += 3; + } + if (!--intNodeCount) + {intNodeCount = yyyDECORfREQ; + yyyDecorate(); + } + } + + + +void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *mylval) + {yyyRCT *rcPdum; + yyySIT **yyyOxStackItem = &mylval->yyyOxAttrbs.yyyOxStackItem; + (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); + if ((*yyyOxStackItem) == (yyySIT *) NULL) + yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); + (*yyyOxStackItem)->node = + (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) + ; + if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) + yyyfatal("malloc error in ox node space allocation\n"); + (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; + (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; + (*yyyOxStackItem)->node->parentIsStack = 1; + (*yyyOxStackItem)->node->cLlen = 0; + (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; + (*yyyOxStackItem)->node->refCountListLen = nAttrbs; + rcPdum = (*yyyOxStackItem)->node->refCountList = + (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); + if (rcPdum == (yyyRCT *) NULL) + yyyfatal("malloc error in ox reference count list space allocation\n"); + while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; + (*yyyOxStackItem)->node->prodNum = 0; + (*yyyOxStackItem)->node->whichSym = 0; + } + + + +void yyyabort(void) + {yyyYok = 0; + } + + + + + +#define yyyLastProdNum 8 + + +#define yyyNsorts 1 + + +int yyyProdsInd[] = { + 0, + 0, 2, 6, 10, 14, 18, 22, 24, + 26, +}; + + +int yyyProds[][2] = { +{ 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, +{ 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, +{ 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, +{ 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, +{ 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, +{ 567, 1}, +}; + + +int yyySortsInd[] = { + 0, + 0, + 1, +}; + + +int yyySorts[] = { + 413, +}; + + + +char *yyyStringTab[] = { +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"s",0,0,0, +0,0,"y",0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"LRpre",0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"'('",0,0,0, +0,0,0,0,"')'", +0,0,0,0,0, +0,0,"'*'","lexeme",0, +0,0,0,0,0, +"'+'",0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"'-'",0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,"'/'",0,0, +0,0,0,0,0, +0,0,"expr",0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"printf",0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,"CONST","LRpost",0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,"ID", +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0, +}; + + + +#define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) + +#define yyyGSoccurStr(prodNum,symPos) \ + (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) + +#define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) + +#define yyySortOf(prodNum,symPos) \ + (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) + +#define yyyAttrbStr(prodNum,symPos,attrbNum) \ + (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ + (attrbNum) \ + ] \ + ] \ + ) + + + +void yyyShowProd(int i) + {int j,nSyms; + + nSyms = yyySizeofProd(i); + for (j=0; j\n",stderr); + else + putc('\n',stderr); + } + } + } + + + +void yyyCheckNodeInstancesSolved(yyyGNT *np) + {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; + int nUnsolvedInsts = 0; + + if (np->prodNum != 0) + {inTerminalNode = 0; + prodNum = np->prodNum; + symPos = 0; + } + else + {inTerminalNode = 1; + prodNum = np->parent.noderef->prodNum; + symPos = np->whichSym; + } + mysort = yyySortOf(prodNum,symPos); + sortSize = yyySizeofSort(mysort); + for (i=0; irefCountList)[i] != 0) nUnsolvedInsts += 1; + if (nUnsolvedInsts) + {fprintf(stderr, + "\nFound node that has %d unsolved attribute instance(s).\n", + nUnsolvedInsts + ); + fprintf(stderr,"Node is labeled \"%s\".\n", + yyyGSoccurStr(prodNum,symPos)); + if (inTerminalNode) + {fputs("Node is terminal. Its parent production is:\n ",stderr); + yyyShowProd(prodNum); + } + else + {fputs("Node is nonterminal. ",stderr); + if (!(np->parentIsStack)) + {fprintf(stderr, + "Node is %dth child in its parent production:\n ", + np->whichSym + ); + yyyShowProd(np->parent.noderef->prodNum); + } + fputs("Node is on left hand side of this production:\n ",stderr); + yyyShowProd(np->prodNum); + } + fputs("The following instances are unsolved:\n",stderr); + for (i=0; irefCountList)[i] != 0) + fprintf(stderr," %-16s still has %1d dependencies.\n", + yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); + } + } + + + +void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) + {yyyGNT **yyyCLpdum; + yyyRCT *rcp; + int i; + + /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ + rcp = pNode->refCountList; + i = pNode->refCountListLen; + while (i--) + if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} + yyyCLpdum = pNode->cL; + i = pNode->cLlen; + while (i--) + { + yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); + yyyCLpdum++; + } + } + + + +void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) + {yyyGNT **yyyCLpdum; + int i; + + yyyCheckNodeInstancesSolved(pNode); + yyyCLpdum = pNode->cL; + i = pNode->cLlen; + while (i--) + { + yyyUnsolvedInstSearchTravAux(*yyyCLpdum); + yyyCLpdum++; + } + } + + + +void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) + {yyyGNT **yyyCLpdum; + int i; + + yyyCLpdum = pNode->cL; + i = pNode->cLlen; + while (i--) + { + yyyUnsolvedInstSearchTravAux(*yyyCLpdum); + yyyCLpdum++; + } + } + + + +#line 1797 "expr.oxout.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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: +#line 64 "expr.oxout.y" + {yyyYoxInit();} +#line 2470 "expr.oxout.tab.c" +break; +case 2: +#line 66 "expr.oxout.y" + { + yyyDecorate(); yyyExecuteRRsection(yystack.l_mark[0].yyyOxAttrbs.yyyOxStackItem->node); + } +#line 2477 "expr.oxout.tab.c" +break; +case 3: +#line 73 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(1,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(1,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 2484 "expr.oxout.tab.c" +break; +case 4: +#line 80 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(2,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(2,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 2491 "expr.oxout.tab.c" +break; +case 5: +#line 87 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(3,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(3,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 2498 "expr.oxout.tab.c" +break; +case 6: +#line 94 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(4,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(4,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 2505 "expr.oxout.tab.c" +break; +case 7: +#line 101 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(5,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(5,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 2512 "expr.oxout.tab.c" +break; +case 8: +#line 108 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(6,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(6,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 2519 "expr.oxout.tab.c" +break; +case 9: +#line 114 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(7,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(7,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 2526 "expr.oxout.tab.c" +break; +case 10: +#line 121 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 2533 "expr.oxout.tab.c" +break; +#line 2535 "expr.oxout.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/expr.oxout.tab.h b/test/btyacc/expr.oxout.tab.h new file mode 100644 index 00000000000..cafc41cae56 --- /dev/null +++ b/test/btyacc/expr.oxout.tab.h @@ -0,0 +1,20 @@ +#ifndef _expr_oxout__defines_h_ +#define _expr_oxout__defines_h_ + +#define ID 257 +#define CONST 258 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union YYSTYPE { +struct yyyOxAttrbs { +struct yyyStackItem *yyyOxStackItem; +} yyyOxAttrbs; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE expr_oxout_lval; + +#endif /* _expr_oxout__defines_h_ */ diff --git a/test/btyacc/grammar.dot b/test/btyacc/grammar.dot new file mode 100644 index 00000000000..1988e12ddd6 --- /dev/null +++ b/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/test/btyacc/grammar.error b/test/btyacc/grammar.error new file mode 100644 index 00000000000..d442f8abaeb --- /dev/null +++ b/test/btyacc/grammar.error @@ -0,0 +1 @@ +YACC: 1 shift/reduce conflict, 29 reduce/reduce conflicts. diff --git a/test/btyacc/grammar.output b/test/btyacc/grammar.output new file mode 100644 index 00000000000..8000cca1ae2 --- /dev/null +++ b/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/test/btyacc/grammar.tab.c b/test/btyacc/grammar.tab.c new file mode 100644 index 00000000000..0dec5d6bcaf --- /dev/null +++ b/test/btyacc/grammar.tab.c @@ -0,0 +1,3010 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3) + +/* 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 409 "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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT grammar_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, +}; +#endif +#define YYFINAL 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 1015 "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 occurrences 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 1351 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 10: +#line 378 "grammar.y" + { + yyerrok; + } +#line 2026 "grammar.tab.c" +break; +case 11: +#line 382 "grammar.y" + { + yyerrok; + } +#line 2033 "grammar.tab.c" +break; +case 13: +#line 393 "grammar.y" + { + /* Provide an empty action here so bison will not complain about + * incompatible types in the default action it normally would + * have generated. + */ + } +#line 2043 "grammar.tab.c" +break; +case 14: +#line 400 "grammar.y" + { + /* empty */ + } +#line 2050 "grammar.tab.c" +break; +case 15: +#line 407 "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(); + } +#line 2064 "grammar.tab.c" +break; +case 16: +#line 418 "grammar.y" + { + if (func_params != NULL) { + set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); + } 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(); + } +#line 2081 "grammar.tab.c" +break; +case 17: +#line 432 "grammar.y" + { + cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags; + free_decl_spec(&yystack.l_mark[0].decl_spec); + } +#line 2089 "grammar.tab.c" +break; +case 18: +#line 437 "grammar.y" + { + end_typedef(); + } +#line 2096 "grammar.tab.c" +break; +case 19: +#line 444 "grammar.y" + { + begin_typedef(); + } +#line 2103 "grammar.tab.c" +break; +case 20: +#line 448 "grammar.y" + { + begin_typedef(); + } +#line 2110 "grammar.tab.c" +break; +case 23: +#line 460 "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); + } +#line 2125 "grammar.tab.c" +break; +case 24: +#line 472 "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); + } +#line 2137 "grammar.tab.c" +break; +case 25: +#line 484 "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; + } +#line 2151 "grammar.tab.c" +break; +case 26: +#line 495 "grammar.y" + { + /* If we're converting to K&R and we've got a nominally K&R + * function which has a parameter which is ANSI (i.e., a prototyped + * 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); + } +#line 2178 "grammar.tab.c" +break; +case 28: +#line 520 "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; + } +#line 2191 "grammar.tab.c" +break; +case 29: +#line 530 "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); + } +#line 2210 "grammar.tab.c" +break; +case 36: +#line 561 "grammar.y" + { + join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec); + free(yystack.l_mark[-1].decl_spec.text); + free(yystack.l_mark[0].decl_spec.text); + } +#line 2219 "grammar.tab.c" +break; +case 40: +#line 576 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2226 "grammar.tab.c" +break; +case 41: +#line 580 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN); + } +#line 2233 "grammar.tab.c" +break; +case 42: +#line 584 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2240 "grammar.tab.c" +break; +case 43: +#line 588 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC); + } +#line 2247 "grammar.tab.c" +break; +case 44: +#line 592 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE); + } +#line 2254 "grammar.tab.c" +break; +case 45: +#line 596 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK); + } +#line 2261 "grammar.tab.c" +break; +case 46: +#line 603 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); + } +#line 2268 "grammar.tab.c" +break; +case 47: +#line 607 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2275 "grammar.tab.c" +break; +case 48: +#line 611 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT); + } +#line 2282 "grammar.tab.c" +break; +case 49: +#line 615 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2289 "grammar.tab.c" +break; +case 50: +#line 619 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2296 "grammar.tab.c" +break; +case 51: +#line 623 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT); + } +#line 2303 "grammar.tab.c" +break; +case 52: +#line 627 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2310 "grammar.tab.c" +break; +case 53: +#line 631 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2317 "grammar.tab.c" +break; +case 54: +#line 635 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2324 "grammar.tab.c" +break; +case 55: +#line 639 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); + } +#line 2331 "grammar.tab.c" +break; +case 56: +#line 643 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2338 "grammar.tab.c" +break; +case 57: +#line 647 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2345 "grammar.tab.c" +break; +case 58: +#line 651 "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); + } +#line 2355 "grammar.tab.c" +break; +case 61: +#line 663 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 2362 "grammar.tab.c" +break; +case 62: +#line 667 "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); + } +#line 2375 "grammar.tab.c" +break; +case 63: +#line 680 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-2].text.text, TEXT_LEN, yystack.l_mark[-1].text.text); + new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); + } +#line 2385 "grammar.tab.c" +break; +case 64: +#line 687 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); + new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); + } +#line 2395 "grammar.tab.c" +break; +case 65: +#line 694 "grammar.y" + { + (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); + new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); + } +#line 2403 "grammar.tab.c" +break; +case 66: +#line 702 "grammar.y" + { + imply_typedef(yyval.text.text); + } +#line 2410 "grammar.tab.c" +break; +case 67: +#line 706 "grammar.y" + { + imply_typedef(yyval.text.text); + } +#line 2417 "grammar.tab.c" +break; +case 68: +#line 713 "grammar.y" + { + new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator); + } +#line 2424 "grammar.tab.c" +break; +case 69: +#line 717 "grammar.y" + { + add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator); + } +#line 2431 "grammar.tab.c" +break; +case 70: +#line 724 "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; + } +#line 2443 "grammar.tab.c" +break; +case 71: +#line 733 "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); + } + } +#line 2454 "grammar.tab.c" +break; +case 73: +#line 745 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, yystack.l_mark[-1].text.text); + new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); + } +#line 2464 "grammar.tab.c" +break; +case 74: +#line 752 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); + new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); + } +#line 2474 "grammar.tab.c" +break; +case 75: +#line 759 "grammar.y" + { + (void)sprintf(buf, "enum %.*s", TEXT_LEN, yystack.l_mark[0].text.text); + new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); + } +#line 2482 "grammar.tab.c" +break; +case 76: +#line 767 "grammar.y" + { + imply_typedef("enum"); + yyval.text = yystack.l_mark[0].text; + } +#line 2490 "grammar.tab.c" +break; +case 79: +#line 780 "grammar.y" + { + yyval.declarator = yystack.l_mark[0].declarator; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + yyval.declarator->begin = yystack.l_mark[-1].text.begin; + yyval.declarator->pointer = TRUE; + } +#line 2502 "grammar.tab.c" +break; +case 81: +#line 793 "grammar.y" + { + yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin); + } +#line 2509 "grammar.tab.c" +break; +case 82: +#line 797 "grammar.y" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + yyval.declarator->begin = yystack.l_mark[-2].text.begin; + } +#line 2520 "grammar.tab.c" +break; +case 83: +#line 805 "grammar.y" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + } +#line 2530 "grammar.tab.c" +break; +case 84: +#line 812 "grammar.y" + { + yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); + yyval.declarator->params = yystack.l_mark[-1].param_list; + 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; + } +#line 2541 "grammar.tab.c" +break; +case 85: +#line 820 "grammar.y" + { + yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); + yyval.declarator->params = yystack.l_mark[-1].param_list; + 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; + } +#line 2552 "grammar.tab.c" +break; +case 86: +#line 831 "grammar.y" + { + (void)sprintf(yyval.text.text, "*%.*s", TEXT_LEN, yystack.l_mark[0].text.text); + yyval.text.begin = yystack.l_mark[-1].text.begin; + } +#line 2560 "grammar.tab.c" +break; +case 87: +#line 836 "grammar.y" + { + (void)sprintf(yyval.text.text, "*%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); + yyval.text.begin = yystack.l_mark[-2].text.begin; + } +#line 2568 "grammar.tab.c" +break; +case 88: +#line 844 "grammar.y" + { + strcpy(yyval.text.text, ""); + yyval.text.begin = 0L; + } +#line 2576 "grammar.tab.c" +break; +case 90: +#line 853 "grammar.y" + { + (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text); + yyval.text.begin = yystack.l_mark[0].decl_spec.begin; + free(yystack.l_mark[0].decl_spec.text); + } +#line 2585 "grammar.tab.c" +break; +case 91: +#line 859 "grammar.y" + { + (void)sprintf(yyval.text.text, "%.*s%.*s ", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].decl_spec.text); + yyval.text.begin = yystack.l_mark[-1].text.begin; + free(yystack.l_mark[0].decl_spec.text); + } +#line 2594 "grammar.tab.c" +break; +case 93: +#line 869 "grammar.y" + { + add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "..."); + } +#line 2601 "grammar.tab.c" +break; +case 94: +#line 876 "grammar.y" + { + new_param_list(&yyval.param_list, yystack.l_mark[0].parameter); + } +#line 2608 "grammar.tab.c" +break; +case 95: +#line 880 "grammar.y" + { + add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter); + } +#line 2615 "grammar.tab.c" +break; +case 96: +#line 887 "grammar.y" + { + check_untagged(&yystack.l_mark[-1].decl_spec); + yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); + } +#line 2623 "grammar.tab.c" +break; +case 97: +#line 892 "grammar.y" + { + check_untagged(&yystack.l_mark[-1].decl_spec); + yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); + } +#line 2631 "grammar.tab.c" +break; +case 98: +#line 897 "grammar.y" + { + check_untagged(&yystack.l_mark[0].decl_spec); + yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0); + } +#line 2639 "grammar.tab.c" +break; +case 99: +#line 905 "grammar.y" + { + new_ident_list(&yyval.param_list); + } +#line 2646 "grammar.tab.c" +break; +case 101: +#line 913 "grammar.y" + { + new_ident_list(&yyval.param_list); + add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text); + } +#line 2654 "grammar.tab.c" +break; +case 102: +#line 918 "grammar.y" + { + add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text); + } +#line 2661 "grammar.tab.c" +break; +case 103: +#line 925 "grammar.y" + { + yyval.text = yystack.l_mark[0].text; + } +#line 2668 "grammar.tab.c" +break; +case 104: +#line 929 "grammar.y" + { +#if OPT_LINTLIBRARY + if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */ + yyval.text = yystack.l_mark[0].text; + } else +#endif + (void)sprintf(yyval.text.text, "&%.*s", TEXT_LEN, yystack.l_mark[0].text.text); + yyval.text.begin = yystack.l_mark[-1].text.begin; + } +#line 2681 "grammar.tab.c" +break; +case 105: +#line 942 "grammar.y" + { + yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); + } +#line 2688 "grammar.tab.c" +break; +case 106: +#line 946 "grammar.y" + { + yyval.declarator = yystack.l_mark[0].declarator; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + yyval.declarator->begin = yystack.l_mark[-1].text.begin; + } +#line 2699 "grammar.tab.c" +break; +case 108: +#line 958 "grammar.y" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + yyval.declarator->begin = yystack.l_mark[-2].text.begin; + } +#line 2710 "grammar.tab.c" +break; +case 109: +#line 966 "grammar.y" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + } +#line 2720 "grammar.tab.c" +break; +case 110: +#line 973 "grammar.y" + { + yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); + } +#line 2727 "grammar.tab.c" +break; +case 111: +#line 977 "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; + } +#line 2738 "grammar.tab.c" +break; +case 112: +#line 985 "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; + } +#line 2748 "grammar.tab.c" +break; +case 113: +#line 992 "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; + } +#line 2762 "grammar.tab.c" +break; +case 114: +#line 1003 "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; + } +#line 2775 "grammar.tab.c" +break; +#line 2777 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/grammar.tab.h b/test/btyacc/grammar.tab.h new file mode 100644 index 00000000000..f82e0d3f410 --- /dev/null +++ b/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/test/btyacc/help.error b/test/btyacc/help.error new file mode 100644 index 00000000000..c4d890b024c --- /dev/null +++ b/test/btyacc/help.error @@ -0,0 +1,31 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/btyacc/help.output b/test/btyacc/help.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/inherit0.error b/test/btyacc/inherit0.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/inherit0.output b/test/btyacc/inherit0.output new file mode 100644 index 00000000000..ee5ca2e500b --- /dev/null +++ b/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/test/btyacc/inherit0.tab.c b/test/btyacc/inherit0.tab.c new file mode 100644 index 00000000000..5ea73cbcfdd --- /dev/null +++ b/test/btyacc/inherit0.tab.c @@ -0,0 +1,1354 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT inherit0_stos[] = { 0, + 257, 258, 259, 260, 263, 264, 265, 265, 267, 268, + 261, 266, 269, 261, 266, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT inherit0_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 46 "inherit0.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 396 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: +#line 20 "inherit0.y" + { yyval = yystack.l_mark[0]; } +#line 1069 "inherit0.tab.c" +break; +case 2: +#line 22 "inherit0.y" + { yyval = yystack.l_mark[0]; } +#line 1074 "inherit0.tab.c" +break; +case 3: +#line 25 "inherit0.y" + { yyval = 1; } +#line 1079 "inherit0.tab.c" +break; +case 4: +#line 26 "inherit0.y" + { yyval = 2; } +#line 1084 "inherit0.tab.c" +break; +case 5: +#line 29 "inherit0.y" + { yyval = 1; } +#line 1089 "inherit0.tab.c" +break; +case 6: +#line 30 "inherit0.y" + { yyval = 2; } +#line 1094 "inherit0.tab.c" +break; +case 7: +#line 34 "inherit0.y" + { mksymbol(yystack.l_mark[-2], yystack.l_mark[-3], yystack.l_mark[0]); } +#line 1099 "inherit0.tab.c" +break; +case 8: +#line 36 "inherit0.y" + { mksymbol(yystack.l_mark[-1], yystack.l_mark[-2], yystack.l_mark[0]); } +#line 1104 "inherit0.tab.c" +break; +case 9: +#line 40 "inherit0.y" + { yyval = 2; } +#line 1109 "inherit0.tab.c" +break; +case 10: +#line 41 "inherit0.y" + { yyval = yystack.l_mark[-2]; } +#line 1114 "inherit0.tab.c" +break; +case 11: +#line 43 "inherit0.y" + { yyval = yystack.l_mark[0]; } +#line 1119 "inherit0.tab.c" +break; +#line 1121 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/inherit0.tab.h b/test/btyacc/inherit0.tab.h new file mode 100644 index 00000000000..50ecd392f8b --- /dev/null +++ b/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/test/btyacc/inherit1.error b/test/btyacc/inherit1.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/inherit1.output b/test/btyacc/inherit1.output new file mode 100644 index 00000000000..349f1657d94 --- /dev/null +++ b/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/test/btyacc/inherit1.tab.c b/test/btyacc/inherit1.tab.c new file mode 100644 index 00000000000..17bd7ffbee8 --- /dev/null +++ b/test/btyacc/inherit1.tab.c @@ -0,0 +1,1379 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 32 "inherit1.y" +typedef union YYSTYPE +{ + 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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT inherit1_stos[] = { 0, + 257, 258, 259, 260, 263, 266, 267, 267, 265, 268, + 261, 264, 269, 261, 264, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT inherit1_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 74 "inherit1.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 417 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: +#line 44 "inherit1.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +#line 1090 "inherit1.tab.c" +break; +case 2: +#line 46 "inherit1.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +#line 1095 "inherit1.tab.c" +break; +case 3: +#line 49 "inherit1.y" + { yyval.cval = cGLOBAL; } +#line 1100 "inherit1.tab.c" +break; +case 4: +#line 50 "inherit1.y" + { yyval.cval = cLOCAL; } +#line 1105 "inherit1.tab.c" +break; +case 5: +#line 53 "inherit1.y" + { yyval.tval = tREAL; } +#line 1110 "inherit1.tab.c" +break; +case 6: +#line 54 "inherit1.y" + { yyval.tval = tINTEGER; } +#line 1115 "inherit1.tab.c" +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; + } +#line 1122 "inherit1.tab.c" +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; + } +#line 1129 "inherit1.tab.c" +break; +case 9: +#line 68 "inherit1.y" + { yyval.cval = cLOCAL; } +#line 1134 "inherit1.tab.c" +break; +case 10: +#line 69 "inherit1.y" + { yyval.tval = yystack.l_mark[-2].tval; } +#line 1139 "inherit1.tab.c" +break; +case 11: +#line 71 "inherit1.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +#line 1144 "inherit1.tab.c" +break; +#line 1146 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/inherit1.tab.h b/test/btyacc/inherit1.tab.h new file mode 100644 index 00000000000..41b0e2937d3 --- /dev/null +++ b/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 YYSTYPE +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE inherit1_lval; + +#endif /* _inherit1__defines_h_ */ diff --git a/test/btyacc/inherit2.error b/test/btyacc/inherit2.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/inherit2.output b/test/btyacc/inherit2.output new file mode 100644 index 00000000000..b5df0008ddb --- /dev/null +++ b/test/btyacc/inherit2.output @@ -0,0 +1,186 @@ + 0 $accept : declaration $end + + 1 $$1 : + + 2 $$2 : + + 3 declaration : class type $$1 $$2 namelist + 4 | type locnamelist + + 5 class : GLOBAL + 6 | LOCAL + + 7 type : REAL + 8 | INTEGER + + 9 namelist : namelist NAME + 10 | NAME + + 11 $$3 : + + 12 locnamelist : $$3 $$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 . (5) + + . reduce 5 + + +state 2 + class : LOCAL . (6) + + . reduce 6 + + +state 3 + type : REAL . (7) + + . reduce 7 + + +state 4 + type : INTEGER . (8) + + . reduce 8 + + +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 . locnamelist (4) + $$3 : . (11) + + . reduce 11 + + locnamelist goto 9 + $$3 goto 10 + + +state 8 + declaration : class type . $$1 $$2 namelist (3) + $$1 : . (1) + + . reduce 1 + + $$1 goto 11 + + +state 9 + declaration : type locnamelist . (4) + + . reduce 4 + + +state 10 + locnamelist : $$3 . $$2 namelist (12) + $$2 : . (2) + + . reduce 2 + + $$2 goto 12 + + +state 11 + declaration : class type $$1 . $$2 namelist (3) + $$2 : . (2) + + . reduce 2 + + $$2 goto 13 + + +state 12 + locnamelist : $$3 $$2 . namelist (12) + + NAME shift 14 + . error + + namelist goto 15 + + +state 13 + declaration : class type $$1 $$2 . namelist (3) + + NAME shift 14 + . error + + namelist goto 16 + + +state 14 + namelist : NAME . (10) + + . reduce 10 + + +state 15 + namelist : namelist . NAME (9) + locnamelist : $$3 $$2 namelist . (12) + + NAME shift 17 + $end reduce 12 + + +state 16 + declaration : class type $$1 $$2 namelist . (3) + namelist : namelist . NAME (9) + + NAME shift 17 + $end reduce 3 + + +state 17 + namelist : namelist NAME . (9) + + . reduce 9 + + +7 terminals, 9 nonterminals +13 grammar rules, 18 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/test/btyacc/inherit2.tab.c b/test/btyacc/inherit2.tab.c new file mode 100644 index 00000000000..c6a542e3eb3 --- /dev/null +++ b/test/btyacc/inherit2.tab.c @@ -0,0 +1,1439 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 39 "inherit2.y" +typedef union YYSTYPE +{ + 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 int YYINT; +static const YYINT inherit2_lhs[] = { -1, + 5, 6, 0, 0, 3, 3, 4, 4, 1, 1, + 7, 2, +}; +static const YYINT inherit2_len[] = { 2, + 0, 0, 5, 2, 1, 1, 1, 1, 2, 1, + 0, 3, +}; +static const YYINT inherit2_defred[] = { 0, + 5, 6, 7, 8, 0, 0, 11, 1, 4, 2, + 2, 0, 0, 10, 0, 0, 9, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT inherit2_stos[] = { 0, + 257, 258, 259, 260, 263, 266, 267, 267, 265, 270, + 268, 269, 269, 261, 264, 264, 261, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT inherit2_dgoto[] = { 5, + 15, 9, 6, 7, 11, 12, 10, +}; +static const YYINT inherit2_sindex[] = { -257, + 0, 0, 0, 0, 0, -255, 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, 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, +}; +#endif +static const YYINT inherit2_gindex[] = { 0, + -3, 0, 0, 5, 0, 1, 0, +}; +#define YYTABLESIZE 12 +static const YYINT inherit2_table[] = { 1, + 2, 3, 4, 3, 4, 12, 14, 17, 3, 16, + 8, 13, +}; +static const YYINT inherit2_check[] = { 257, + 258, 259, 260, 259, 260, 0, 261, 261, 0, 13, + 6, 11, +}; +#if YYBTYACC +static const YYINT inherit2_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, +}; +#endif +#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 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","illegal-symbol", +}; +static const char *const inherit2_rule[] = { +"$accept : declaration", +"$$1 :", +"$$2 :", +"declaration : class type $$1 $$2 namelist", +"declaration : type locnamelist", +"class : GLOBAL", +"class : LOCAL", +"type : REAL", +"type : INTEGER", +"namelist : namelist NAME", +"namelist : NAME", +"$$3 :", +"locnamelist : $$3 $$2 namelist", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 78 "inherit2.y" + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); +#line 424 "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); + } + } +#line 443 "inherit2.tab.c" + break; + case 264: +#line 30 "inherit2.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } +#line 455 "inherit2.tab.c" + break; + case 265: +#line 30 "inherit2.y" + { + namelist *p = (*val).nlist; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } +#line 467 "inherit2.tab.c" + break; + } +} +#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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 1: +#line 50 "inherit2.y" +yyval.cval = yystack.l_mark[-1].cval; +#line 1145 "inherit2.tab.c" +break; +case 2: +#line 50 "inherit2.y" +yyval.tval = yystack.l_mark[-1].tval; +#line 1150 "inherit2.tab.c" +break; +case 3: +#line 51 "inherit2.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +#line 1155 "inherit2.tab.c" +break; +case 4: +#line 53 "inherit2.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +#line 1160 "inherit2.tab.c" +break; +case 5: +#line 56 "inherit2.y" + { yyval.cval = cGLOBAL; } +#line 1165 "inherit2.tab.c" +break; +case 6: +#line 57 "inherit2.y" + { yyval.cval = cLOCAL; } +#line 1170 "inherit2.tab.c" +break; +case 7: +#line 60 "inherit2.y" + { yyval.tval = tREAL; } +#line 1175 "inherit2.tab.c" +break; +case 8: +#line 61 "inherit2.y" + { yyval.tval = tINTEGER; } +#line 1180 "inherit2.tab.c" +break; +case 9: +#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; + } +#line 1187 "inherit2.tab.c" +break; +case 10: +#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; + } +#line 1194 "inherit2.tab.c" +break; +case 11: +#line 74 "inherit2.y" +yyval.cval = cLOCAL; +#line 1199 "inherit2.tab.c" +break; +case 12: +#line 75 "inherit2.y" + { yyval.nlist = yystack.l_mark[0].nlist; } +#line 1204 "inherit2.tab.c" +break; +#line 1206 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/inherit2.tab.h b/test/btyacc/inherit2.tab.h new file mode 100644 index 00000000000..333dab588b3 --- /dev/null +++ b/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 YYSTYPE +{ + class cval; + type tval; + namelist * nlist; + name id; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE inherit2_lval; + +#endif /* _inherit2__defines_h_ */ diff --git a/test/btyacc/no_b_opt.error b/test/btyacc/no_b_opt.error new file mode 100644 index 00000000000..c4d890b024c --- /dev/null +++ b/test/btyacc/no_b_opt.error @@ -0,0 +1,31 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/btyacc/no_b_opt.output b/test/btyacc/no_b_opt.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_b_opt1.error b/test/btyacc/no_b_opt1.error new file mode 100644 index 00000000000..87286c2661e --- /dev/null +++ b/test/btyacc/no_b_opt1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/test/btyacc/no_b_opt1.output b/test/btyacc/no_b_opt1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_code_c.error b/test/btyacc/no_code_c.error new file mode 100644 index 00000000000..87286c2661e --- /dev/null +++ b/test/btyacc/no_code_c.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/test/btyacc/no_code_c.output b/test/btyacc/no_code_c.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_defines.error b/test/btyacc/no_defines.error new file mode 100644 index 00000000000..773985d66f3 --- /dev/null +++ b/test/btyacc/no_defines.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.h" diff --git a/test/btyacc/no_defines.output b/test/btyacc/no_defines.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_graph.error b/test/btyacc/no_graph.error new file mode 100644 index 00000000000..d5575f40042 --- /dev/null +++ b/test/btyacc/no_graph.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.dot" diff --git a/test/btyacc/no_graph.output b/test/btyacc/no_graph.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_include.error b/test/btyacc/no_include.error new file mode 100644 index 00000000000..3ece4a454e3 --- /dev/null +++ b/test/btyacc/no_include.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.i" diff --git a/test/btyacc/no_include.output b/test/btyacc/no_include.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_opts.error b/test/btyacc/no_opts.error new file mode 100644 index 00000000000..ad3131a69ab --- /dev/null +++ b/test/btyacc/no_opts.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.y" diff --git a/test/btyacc/no_opts.output b/test/btyacc/no_opts.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_output.error b/test/btyacc/no_output.error new file mode 100644 index 00000000000..a2f142a9d53 --- /dev/null +++ b/test/btyacc/no_output.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/test/btyacc/no_output.output b/test/btyacc/no_output.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_output1.error b/test/btyacc/no_output1.error new file mode 100644 index 00000000000..a2f142a9d53 --- /dev/null +++ b/test/btyacc/no_output1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/test/btyacc/no_output1.output b/test/btyacc/no_output1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_output2.error b/test/btyacc/no_output2.error new file mode 100644 index 00000000000..c4d890b024c --- /dev/null +++ b/test/btyacc/no_output2.error @@ -0,0 +1,31 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/btyacc/no_output2.output b/test/btyacc/no_output2.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_p_opt.error b/test/btyacc/no_p_opt.error new file mode 100644 index 00000000000..c4d890b024c --- /dev/null +++ b/test/btyacc/no_p_opt.error @@ -0,0 +1,31 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/btyacc/no_p_opt.output b/test/btyacc/no_p_opt.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_p_opt1.error b/test/btyacc/no_p_opt1.error new file mode 100644 index 00000000000..87286c2661e --- /dev/null +++ b/test/btyacc/no_p_opt1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/test/btyacc/no_p_opt1.output b/test/btyacc/no_p_opt1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/no_verbose.error b/test/btyacc/no_verbose.error new file mode 100644 index 00000000000..a2f142a9d53 --- /dev/null +++ b/test/btyacc/no_verbose.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/test/btyacc/no_verbose.output b/test/btyacc/no_verbose.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/nostdin.error b/test/btyacc/nostdin.error new file mode 100644 index 00000000000..7f74f49a89b --- /dev/null +++ b/test/btyacc/nostdin.error @@ -0,0 +1,30 @@ +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/btyacc/nostdin.output b/test/btyacc/nostdin.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/ok_syntax1.error b/test/btyacc/ok_syntax1.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/ok_syntax1.output b/test/btyacc/ok_syntax1.output new file mode 100644 index 00000000000..61935519b0c --- /dev/null +++ b/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/test/btyacc/ok_syntax1.tab.c b/test/btyacc/ok_syntax1.tab.c new file mode 100644 index 00000000000..b27e6116856 --- /dev/null +++ b/test/btyacc/ok_syntax1.tab.c @@ -0,0 +1,1539 @@ +/* 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 2 +#define YYMINOR 0 +#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 + +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 43 "ok_syntax1.y" +union CalcData +{ + char * cval; + int ival; + double dval; +}; typedef union CalcData 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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT ok_syntax1_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +#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 500 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; + int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* 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 YYINT *yylexp = 0; + + static YYINT *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[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + + yyerrflag = 0; + yychar = 0; + memset(&yyval, 0, sizeof(yyval)); + memset(&yylval, 0, sizeof(yylval)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(&yyloc, 0, sizeof(yyloc)); + memset(&yylloc, 0, sizeof(yylloc)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 66 "ok_syntax1.y" + { yyerrok ; } +#line 1234 "ok_syntax1.tab.c" +break; +case 4: +#line 70 "ok_syntax1.y" + { printf("%d\n",yystack.l_mark[0].ival);} +#line 1239 "ok_syntax1.tab.c" +break; +case 5: +#line 72 "ok_syntax1.y" + { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; } +#line 1244 "ok_syntax1.tab.c" +break; +case 6: +#line 76 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-1].ival; } +#line 1249 "ok_syntax1.tab.c" +break; +case 7: +#line 78 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; } +#line 1254 "ok_syntax1.tab.c" +break; +case 8: +#line 80 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; } +#line 1259 "ok_syntax1.tab.c" +break; +case 9: +#line 82 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; } +#line 1264 "ok_syntax1.tab.c" +break; +case 10: +#line 84 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; } +#line 1269 "ok_syntax1.tab.c" +break; +case 11: +#line 86 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; } +#line 1274 "ok_syntax1.tab.c" +break; +case 12: +#line 88 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; } +#line 1279 "ok_syntax1.tab.c" +break; +case 13: +#line 90 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; } +#line 1284 "ok_syntax1.tab.c" +break; +case 14: +#line 92 "ok_syntax1.y" + { yyval.ival = - yystack.l_mark[0].ival; } +#line 1289 "ok_syntax1.tab.c" +break; +case 15: +#line 94 "ok_syntax1.y" + { yyval.ival = regs[yystack.l_mark[0].ival]; } +#line 1294 "ok_syntax1.tab.c" +break; +case 17: +#line 99 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; } +#line 1299 "ok_syntax1.tab.c" +break; +case 18: +#line 101 "ok_syntax1.y" + { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } +#line 1304 "ok_syntax1.tab.c" +break; +#line 1306 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/ok_syntax1.tab.h b/test/btyacc/ok_syntax1.tab.h new file mode 100644 index 00000000000..bb0a20f1913 --- /dev/null +++ b/test/btyacc/ok_syntax1.tab.h @@ -0,0 +1,34 @@ +#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 +union CalcData +{ + char * cval; + int ival; + double dval; +}; typedef union CalcData YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ + +#endif /* _ok_syntax1__defines_h_ */ diff --git a/test/btyacc/pure_calc.error b/test/btyacc/pure_calc.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/pure_calc.output b/test/btyacc/pure_calc.output new file mode 100644 index 00000000000..c689eec0535 --- /dev/null +++ b/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/test/btyacc/pure_calc.tab.c b/test/btyacc/pure_calc.tab.c new file mode 100644 index 00000000000..15a14b6c3f2 --- /dev/null +++ b/test/btyacc/pure_calc.tab.c @@ -0,0 +1,1512 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT calc_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_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 + +#if YYDEBUG +int yydebug; +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +#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 473 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; + int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* 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 YYINT *yylexp = 0; + + static YYINT *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[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + + yyerrflag = 0; + yychar = 0; + memset(&yyval, 0, sizeof(yyval)); + memset(&yylval, 0, sizeof(yylval)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(&yyloc, 0, sizeof(yyloc)); + memset(&yylloc, 0, sizeof(yylloc)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 34 "pure_calc.y" + { yyerrok ; } +#line 1207 "pure_calc.tab.c" +break; +case 4: +#line 38 "pure_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1212 "pure_calc.tab.c" +break; +case 5: +#line 40 "pure_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1217 "pure_calc.tab.c" +break; +case 6: +#line 44 "pure_calc.y" + { yyval = yystack.l_mark[-1]; } +#line 1222 "pure_calc.tab.c" +break; +case 7: +#line 46 "pure_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1227 "pure_calc.tab.c" +break; +case 8: +#line 48 "pure_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1232 "pure_calc.tab.c" +break; +case 9: +#line 50 "pure_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1237 "pure_calc.tab.c" +break; +case 10: +#line 52 "pure_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1242 "pure_calc.tab.c" +break; +case 11: +#line 54 "pure_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1247 "pure_calc.tab.c" +break; +case 12: +#line 56 "pure_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1252 "pure_calc.tab.c" +break; +case 13: +#line 58 "pure_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1257 "pure_calc.tab.c" +break; +case 14: +#line 60 "pure_calc.y" + { yyval = - yystack.l_mark[0]; } +#line 1262 "pure_calc.tab.c" +break; +case 15: +#line 62 "pure_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1267 "pure_calc.tab.c" +break; +case 17: +#line 67 "pure_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1272 "pure_calc.tab.c" +break; +case 18: +#line 69 "pure_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1277 "pure_calc.tab.c" +break; +#line 1279 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/pure_calc.tab.h b/test/btyacc/pure_calc.tab.h new file mode 100644 index 00000000000..48f8993b83f --- /dev/null +++ b/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/test/btyacc/pure_error.error b/test/btyacc/pure_error.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/pure_error.output b/test/btyacc/pure_error.output new file mode 100644 index 00000000000..1e56c214a6c --- /dev/null +++ b/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/test/btyacc/pure_error.tab.c b/test/btyacc/pure_error.tab.c new file mode 100644 index 00000000000..70a160e4353 --- /dev/null +++ b/test/btyacc/pure_error.tab.c @@ -0,0 +1,1304 @@ +/* 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 2 +#define YYMINOR 0 +#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 int YYINT; +static const YYINT error_lhs[] = { -1, + 0, +}; +static const YYINT error_len[] = { 2, + 1, +}; +static const YYINT error_defred[] = { 0, + 1, 0, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT error_stos[] = { 0, + 256, 258, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT error_ctable[] = { -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +#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 341 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yyerrflag; + int yychar; + YYSTYPE yyval; + YYSTYPE yylval; + int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyloc; /* position returned by actions */ + YYLTYPE yylloc; /* position from the lexer */ +#endif + + /* 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 YYINT *yylexp = 0; + + static YYINT *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[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + + yyerrflag = 0; + yychar = 0; + memset(&yyval, 0, sizeof(yyval)); + memset(&yylval, 0, sizeof(yylval)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(&yyloc, 0, sizeof(yyloc)); + memset(&yylloc, 0, sizeof(yylloc)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/pure_error.tab.h b/test/btyacc/pure_error.tab.h new file mode 100644 index 00000000000..f9e5ad278cc --- /dev/null +++ b/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/test/btyacc/quote_calc-s.error b/test/btyacc/quote_calc-s.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/btyacc/quote_calc-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc-s.output b/test/btyacc/quote_calc-s.output new file mode 100644 index 00000000000..6c25d091109 --- /dev/null +++ b/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/test/btyacc/quote_calc-s.tab.c b/test/btyacc/quote_calc-s.tab.c new file mode 100644 index 00000000000..ae472304b9e --- /dev/null +++ b/test/btyacc/quote_calc-s.tab.c @@ -0,0 +1,1507 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT quote_calc_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 529 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc.y" + { yyerrok ; } +#line 1202 "quote_calc-s.tab.c" +break; +case 4: +#line 39 "quote_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1207 "quote_calc-s.tab.c" +break; +case 5: +#line 41 "quote_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1212 "quote_calc-s.tab.c" +break; +case 6: +#line 45 "quote_calc.y" + { yyval = yystack.l_mark[-1]; } +#line 1217 "quote_calc-s.tab.c" +break; +case 7: +#line 47 "quote_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1222 "quote_calc-s.tab.c" +break; +case 8: +#line 49 "quote_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1227 "quote_calc-s.tab.c" +break; +case 9: +#line 51 "quote_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1232 "quote_calc-s.tab.c" +break; +case 10: +#line 53 "quote_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1237 "quote_calc-s.tab.c" +break; +case 11: +#line 55 "quote_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1242 "quote_calc-s.tab.c" +break; +case 12: +#line 57 "quote_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1247 "quote_calc-s.tab.c" +break; +case 13: +#line 59 "quote_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1252 "quote_calc-s.tab.c" +break; +case 14: +#line 61 "quote_calc.y" + { yyval = - yystack.l_mark[0]; } +#line 1257 "quote_calc-s.tab.c" +break; +case 15: +#line 63 "quote_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1262 "quote_calc-s.tab.c" +break; +case 17: +#line 68 "quote_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1267 "quote_calc-s.tab.c" +break; +case 18: +#line 70 "quote_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1272 "quote_calc-s.tab.c" +break; +#line 1274 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/quote_calc-s.tab.h b/test/btyacc/quote_calc-s.tab.h new file mode 100644 index 00000000000..827bd8d11b2 --- /dev/null +++ b/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/test/btyacc/quote_calc.error b/test/btyacc/quote_calc.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/btyacc/quote_calc.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc.output b/test/btyacc/quote_calc.output new file mode 100644 index 00000000000..6c25d091109 --- /dev/null +++ b/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/test/btyacc/quote_calc.tab.c b/test/btyacc/quote_calc.tab.c new file mode 100644 index 00000000000..cee23e65d92 --- /dev/null +++ b/test/btyacc/quote_calc.tab.c @@ -0,0 +1,1513 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT quote_calc_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 535 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc.y" + { yyerrok ; } +#line 1208 "quote_calc.tab.c" +break; +case 4: +#line 39 "quote_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1213 "quote_calc.tab.c" +break; +case 5: +#line 41 "quote_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1218 "quote_calc.tab.c" +break; +case 6: +#line 45 "quote_calc.y" + { yyval = yystack.l_mark[-1]; } +#line 1223 "quote_calc.tab.c" +break; +case 7: +#line 47 "quote_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1228 "quote_calc.tab.c" +break; +case 8: +#line 49 "quote_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1233 "quote_calc.tab.c" +break; +case 9: +#line 51 "quote_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1238 "quote_calc.tab.c" +break; +case 10: +#line 53 "quote_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1243 "quote_calc.tab.c" +break; +case 11: +#line 55 "quote_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1248 "quote_calc.tab.c" +break; +case 12: +#line 57 "quote_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1253 "quote_calc.tab.c" +break; +case 13: +#line 59 "quote_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1258 "quote_calc.tab.c" +break; +case 14: +#line 61 "quote_calc.y" + { yyval = - yystack.l_mark[0]; } +#line 1263 "quote_calc.tab.c" +break; +case 15: +#line 63 "quote_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1268 "quote_calc.tab.c" +break; +case 17: +#line 68 "quote_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1273 "quote_calc.tab.c" +break; +case 18: +#line 70 "quote_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1278 "quote_calc.tab.c" +break; +#line 1280 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/quote_calc.tab.h b/test/btyacc/quote_calc.tab.h new file mode 100644 index 00000000000..2067aeea909 --- /dev/null +++ b/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/test/btyacc/quote_calc2-s.error b/test/btyacc/quote_calc2-s.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/btyacc/quote_calc2-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc2-s.output b/test/btyacc/quote_calc2-s.output new file mode 100644 index 00000000000..ce0b8f1baf5 --- /dev/null +++ b/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/test/btyacc/quote_calc2-s.tab.c b/test/btyacc/quote_calc2-s.tab.c new file mode 100644 index 00000000000..a9f939fa062 --- /dev/null +++ b/test/btyacc/quote_calc2-s.tab.c @@ -0,0 +1,1507 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT quote_calc2_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 529 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc2.y" + { yyerrok ; } +#line 1202 "quote_calc2-s.tab.c" +break; +case 4: +#line 39 "quote_calc2.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1207 "quote_calc2-s.tab.c" +break; +case 5: +#line 41 "quote_calc2.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1212 "quote_calc2-s.tab.c" +break; +case 6: +#line 45 "quote_calc2.y" + { yyval = yystack.l_mark[-1]; } +#line 1217 "quote_calc2-s.tab.c" +break; +case 7: +#line 47 "quote_calc2.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1222 "quote_calc2-s.tab.c" +break; +case 8: +#line 49 "quote_calc2.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1227 "quote_calc2-s.tab.c" +break; +case 9: +#line 51 "quote_calc2.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1232 "quote_calc2-s.tab.c" +break; +case 10: +#line 53 "quote_calc2.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1237 "quote_calc2-s.tab.c" +break; +case 11: +#line 55 "quote_calc2.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1242 "quote_calc2-s.tab.c" +break; +case 12: +#line 57 "quote_calc2.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1247 "quote_calc2-s.tab.c" +break; +case 13: +#line 59 "quote_calc2.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1252 "quote_calc2-s.tab.c" +break; +case 14: +#line 61 "quote_calc2.y" + { yyval = - yystack.l_mark[0]; } +#line 1257 "quote_calc2-s.tab.c" +break; +case 15: +#line 63 "quote_calc2.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1262 "quote_calc2-s.tab.c" +break; +case 17: +#line 68 "quote_calc2.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1267 "quote_calc2-s.tab.c" +break; +case 18: +#line 70 "quote_calc2.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1272 "quote_calc2-s.tab.c" +break; +#line 1274 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/quote_calc2-s.tab.h b/test/btyacc/quote_calc2-s.tab.h new file mode 100644 index 00000000000..90c0c1a2d4c --- /dev/null +++ b/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/test/btyacc/quote_calc2.error b/test/btyacc/quote_calc2.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/btyacc/quote_calc2.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc2.output b/test/btyacc/quote_calc2.output new file mode 100644 index 00000000000..ce0b8f1baf5 --- /dev/null +++ b/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/test/btyacc/quote_calc2.tab.c b/test/btyacc/quote_calc2.tab.c new file mode 100644 index 00000000000..c414970b42b --- /dev/null +++ b/test/btyacc/quote_calc2.tab.c @@ -0,0 +1,1513 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT quote_calc2_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 535 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc2.y" + { yyerrok ; } +#line 1208 "quote_calc2.tab.c" +break; +case 4: +#line 39 "quote_calc2.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1213 "quote_calc2.tab.c" +break; +case 5: +#line 41 "quote_calc2.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1218 "quote_calc2.tab.c" +break; +case 6: +#line 45 "quote_calc2.y" + { yyval = yystack.l_mark[-1]; } +#line 1223 "quote_calc2.tab.c" +break; +case 7: +#line 47 "quote_calc2.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1228 "quote_calc2.tab.c" +break; +case 8: +#line 49 "quote_calc2.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1233 "quote_calc2.tab.c" +break; +case 9: +#line 51 "quote_calc2.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1238 "quote_calc2.tab.c" +break; +case 10: +#line 53 "quote_calc2.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1243 "quote_calc2.tab.c" +break; +case 11: +#line 55 "quote_calc2.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1248 "quote_calc2.tab.c" +break; +case 12: +#line 57 "quote_calc2.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1253 "quote_calc2.tab.c" +break; +case 13: +#line 59 "quote_calc2.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1258 "quote_calc2.tab.c" +break; +case 14: +#line 61 "quote_calc2.y" + { yyval = - yystack.l_mark[0]; } +#line 1263 "quote_calc2.tab.c" +break; +case 15: +#line 63 "quote_calc2.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1268 "quote_calc2.tab.c" +break; +case 17: +#line 68 "quote_calc2.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1273 "quote_calc2.tab.c" +break; +case 18: +#line 70 "quote_calc2.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1278 "quote_calc2.tab.c" +break; +#line 1280 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/quote_calc2.tab.h b/test/btyacc/quote_calc2.tab.h new file mode 100644 index 00000000000..0c9db245c3c --- /dev/null +++ b/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/test/btyacc/quote_calc3-s.error b/test/btyacc/quote_calc3-s.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/btyacc/quote_calc3-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc3-s.output b/test/btyacc/quote_calc3-s.output new file mode 100644 index 00000000000..4809ca4c810 --- /dev/null +++ b/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/test/btyacc/quote_calc3-s.tab.c b/test/btyacc/quote_calc3-s.tab.c new file mode 100644 index 00000000000..73c6357a182 --- /dev/null +++ b/test/btyacc/quote_calc3-s.tab.c @@ -0,0 +1,1508 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT quote_calc3_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 530 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc3.y" + { yyerrok ; } +#line 1203 "quote_calc3-s.tab.c" +break; +case 4: +#line 39 "quote_calc3.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1208 "quote_calc3-s.tab.c" +break; +case 5: +#line 41 "quote_calc3.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1213 "quote_calc3-s.tab.c" +break; +case 6: +#line 45 "quote_calc3.y" + { yyval = yystack.l_mark[-1]; } +#line 1218 "quote_calc3-s.tab.c" +break; +case 7: +#line 47 "quote_calc3.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1223 "quote_calc3-s.tab.c" +break; +case 8: +#line 49 "quote_calc3.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1228 "quote_calc3-s.tab.c" +break; +case 9: +#line 51 "quote_calc3.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1233 "quote_calc3-s.tab.c" +break; +case 10: +#line 53 "quote_calc3.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1238 "quote_calc3-s.tab.c" +break; +case 11: +#line 55 "quote_calc3.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1243 "quote_calc3-s.tab.c" +break; +case 12: +#line 57 "quote_calc3.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1248 "quote_calc3-s.tab.c" +break; +case 13: +#line 59 "quote_calc3.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1253 "quote_calc3-s.tab.c" +break; +case 14: +#line 61 "quote_calc3.y" + { yyval = - yystack.l_mark[0]; } +#line 1258 "quote_calc3-s.tab.c" +break; +case 15: +#line 63 "quote_calc3.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1263 "quote_calc3-s.tab.c" +break; +case 17: +#line 68 "quote_calc3.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1268 "quote_calc3-s.tab.c" +break; +case 18: +#line 70 "quote_calc3.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1273 "quote_calc3-s.tab.c" +break; +#line 1275 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/quote_calc3-s.tab.h b/test/btyacc/quote_calc3-s.tab.h new file mode 100644 index 00000000000..022d59c6782 --- /dev/null +++ b/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/test/btyacc/quote_calc3.error b/test/btyacc/quote_calc3.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/btyacc/quote_calc3.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc3.output b/test/btyacc/quote_calc3.output new file mode 100644 index 00000000000..4809ca4c810 --- /dev/null +++ b/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/test/btyacc/quote_calc3.tab.c b/test/btyacc/quote_calc3.tab.c new file mode 100644 index 00000000000..36bdc0d7e4a --- /dev/null +++ b/test/btyacc/quote_calc3.tab.c @@ -0,0 +1,1508 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT quote_calc3_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 530 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc3.y" + { yyerrok ; } +#line 1203 "quote_calc3.tab.c" +break; +case 4: +#line 39 "quote_calc3.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1208 "quote_calc3.tab.c" +break; +case 5: +#line 41 "quote_calc3.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1213 "quote_calc3.tab.c" +break; +case 6: +#line 45 "quote_calc3.y" + { yyval = yystack.l_mark[-1]; } +#line 1218 "quote_calc3.tab.c" +break; +case 7: +#line 47 "quote_calc3.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1223 "quote_calc3.tab.c" +break; +case 8: +#line 49 "quote_calc3.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1228 "quote_calc3.tab.c" +break; +case 9: +#line 51 "quote_calc3.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1233 "quote_calc3.tab.c" +break; +case 10: +#line 53 "quote_calc3.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1238 "quote_calc3.tab.c" +break; +case 11: +#line 55 "quote_calc3.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1243 "quote_calc3.tab.c" +break; +case 12: +#line 57 "quote_calc3.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1248 "quote_calc3.tab.c" +break; +case 13: +#line 59 "quote_calc3.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1253 "quote_calc3.tab.c" +break; +case 14: +#line 61 "quote_calc3.y" + { yyval = - yystack.l_mark[0]; } +#line 1258 "quote_calc3.tab.c" +break; +case 15: +#line 63 "quote_calc3.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1263 "quote_calc3.tab.c" +break; +case 17: +#line 68 "quote_calc3.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1268 "quote_calc3.tab.c" +break; +case 18: +#line 70 "quote_calc3.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1273 "quote_calc3.tab.c" +break; +#line 1275 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/quote_calc3.tab.h b/test/btyacc/quote_calc3.tab.h new file mode 100644 index 00000000000..022d59c6782 --- /dev/null +++ b/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/test/btyacc/quote_calc4-s.error b/test/btyacc/quote_calc4-s.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/btyacc/quote_calc4-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc4-s.output b/test/btyacc/quote_calc4-s.output new file mode 100644 index 00000000000..5f1f610d8cb --- /dev/null +++ b/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/test/btyacc/quote_calc4-s.tab.c b/test/btyacc/quote_calc4-s.tab.c new file mode 100644 index 00000000000..111d7473a6f --- /dev/null +++ b/test/btyacc/quote_calc4-s.tab.c @@ -0,0 +1,1508 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT quote_calc4_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 530 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc4.y" + { yyerrok ; } +#line 1203 "quote_calc4-s.tab.c" +break; +case 4: +#line 39 "quote_calc4.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1208 "quote_calc4-s.tab.c" +break; +case 5: +#line 41 "quote_calc4.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1213 "quote_calc4-s.tab.c" +break; +case 6: +#line 45 "quote_calc4.y" + { yyval = yystack.l_mark[-1]; } +#line 1218 "quote_calc4-s.tab.c" +break; +case 7: +#line 47 "quote_calc4.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1223 "quote_calc4-s.tab.c" +break; +case 8: +#line 49 "quote_calc4.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1228 "quote_calc4-s.tab.c" +break; +case 9: +#line 51 "quote_calc4.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1233 "quote_calc4-s.tab.c" +break; +case 10: +#line 53 "quote_calc4.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1238 "quote_calc4-s.tab.c" +break; +case 11: +#line 55 "quote_calc4.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1243 "quote_calc4-s.tab.c" +break; +case 12: +#line 57 "quote_calc4.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1248 "quote_calc4-s.tab.c" +break; +case 13: +#line 59 "quote_calc4.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1253 "quote_calc4-s.tab.c" +break; +case 14: +#line 61 "quote_calc4.y" + { yyval = - yystack.l_mark[0]; } +#line 1258 "quote_calc4-s.tab.c" +break; +case 15: +#line 63 "quote_calc4.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1263 "quote_calc4-s.tab.c" +break; +case 17: +#line 68 "quote_calc4.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1268 "quote_calc4-s.tab.c" +break; +case 18: +#line 70 "quote_calc4.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1273 "quote_calc4-s.tab.c" +break; +#line 1275 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/quote_calc4-s.tab.h b/test/btyacc/quote_calc4-s.tab.h new file mode 100644 index 00000000000..9279e7019ca --- /dev/null +++ b/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/test/btyacc/quote_calc4.error b/test/btyacc/quote_calc4.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/btyacc/quote_calc4.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/btyacc/quote_calc4.output b/test/btyacc/quote_calc4.output new file mode 100644 index 00000000000..5f1f610d8cb --- /dev/null +++ b/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/test/btyacc/quote_calc4.tab.c b/test/btyacc/quote_calc4.tab.c new file mode 100644 index 00000000000..c102d1bac67 --- /dev/null +++ b/test/btyacc/quote_calc4.tab.c @@ -0,0 +1,1508 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT quote_calc4_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 530 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "quote_calc4.y" + { yyerrok ; } +#line 1203 "quote_calc4.tab.c" +break; +case 4: +#line 39 "quote_calc4.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1208 "quote_calc4.tab.c" +break; +case 5: +#line 41 "quote_calc4.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1213 "quote_calc4.tab.c" +break; +case 6: +#line 45 "quote_calc4.y" + { yyval = yystack.l_mark[-1]; } +#line 1218 "quote_calc4.tab.c" +break; +case 7: +#line 47 "quote_calc4.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1223 "quote_calc4.tab.c" +break; +case 8: +#line 49 "quote_calc4.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1228 "quote_calc4.tab.c" +break; +case 9: +#line 51 "quote_calc4.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1233 "quote_calc4.tab.c" +break; +case 10: +#line 53 "quote_calc4.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1238 "quote_calc4.tab.c" +break; +case 11: +#line 55 "quote_calc4.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1243 "quote_calc4.tab.c" +break; +case 12: +#line 57 "quote_calc4.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1248 "quote_calc4.tab.c" +break; +case 13: +#line 59 "quote_calc4.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1253 "quote_calc4.tab.c" +break; +case 14: +#line 61 "quote_calc4.y" + { yyval = - yystack.l_mark[0]; } +#line 1258 "quote_calc4.tab.c" +break; +case 15: +#line 63 "quote_calc4.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1263 "quote_calc4.tab.c" +break; +case 17: +#line 68 "quote_calc4.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1268 "quote_calc4.tab.c" +break; +case 18: +#line 70 "quote_calc4.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1273 "quote_calc4.tab.c" +break; +#line 1275 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/quote_calc4.tab.h b/test/btyacc/quote_calc4.tab.h new file mode 100644 index 00000000000..9279e7019ca --- /dev/null +++ b/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/test/btyacc/rename_debug.c b/test/btyacc/rename_debug.c new file mode 100644 index 00000000000..958ae6a44c0 --- /dev/null +++ b/test/btyacc/rename_debug.c @@ -0,0 +1,1142 @@ +/* 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 2 +#define YYMINOR 0 +#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 int YYINT; +static const YYINT yylhs[] = { -1, + 0, +}; +static const YYINT yylen[] = { 2, + 1, +}; +static const YYINT yydefred[] = { 0, + 1, 0, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT yystos[] = { 0, + 256, 258, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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[] = { -1, +}; +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 241 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/rename_debug.error b/test/btyacc/rename_debug.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/rename_debug.h b/test/btyacc/rename_debug.h new file mode 100644 index 00000000000..ba44e7d75a7 --- /dev/null +++ b/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/test/btyacc/rename_debug.i b/test/btyacc/rename_debug.i new file mode 100644 index 00000000000..ce4871a0e68 --- /dev/null +++ b/test/btyacc/rename_debug.i @@ -0,0 +1,71 @@ +#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 + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif + +#if YYDEBUG +extern int yydebug; +#endif + +extern int yyerrflag; +extern int yychar; +extern YYSTYPE yyval; +extern YYSTYPE yylval; +extern int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +extern YYLTYPE yyloc; /* position returned by actions */ +extern YYLTYPE yylloc; /* position from the lexer */ +#endif diff --git a/test/btyacc/rename_debug.output b/test/btyacc/rename_debug.output new file mode 100644 index 00000000000..1e56c214a6c --- /dev/null +++ b/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/test/btyacc/stdin1.calc.c b/test/btyacc/stdin1.calc.c new file mode 100644 index 00000000000..6bfc240ef6d --- /dev/null +++ b/test/btyacc/stdin1.calc.c @@ -0,0 +1,1396 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "(null)" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 34 "stdin1.calc.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT yystos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT yycindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT yyctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 66 "(null)" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 418 "stdin1.calc.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "(null)" + { yyerrok ; } +#line 1091 "stdin1.calc.c" +break; +case 4: +#line 32 "(null)" + { printf("%d\n",yystack.l_mark[0]);} +#line 1096 "stdin1.calc.c" +break; +case 5: +#line 34 "(null)" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1101 "stdin1.calc.c" +break; +case 6: +#line 38 "(null)" + { yyval = yystack.l_mark[-1]; } +#line 1106 "stdin1.calc.c" +break; +case 7: +#line 40 "(null)" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1111 "stdin1.calc.c" +break; +case 8: +#line 42 "(null)" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1116 "stdin1.calc.c" +break; +case 9: +#line 44 "(null)" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1121 "stdin1.calc.c" +break; +case 10: +#line 46 "(null)" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1126 "stdin1.calc.c" +break; +case 11: +#line 48 "(null)" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1131 "stdin1.calc.c" +break; +case 12: +#line 50 "(null)" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1136 "stdin1.calc.c" +break; +case 13: +#line 52 "(null)" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1141 "stdin1.calc.c" +break; +case 14: +#line 54 "(null)" + { yyval = - yystack.l_mark[0]; } +#line 1146 "stdin1.calc.c" +break; +case 15: +#line 56 "(null)" + { yyval = regs[yystack.l_mark[0]]; } +#line 1151 "stdin1.calc.c" +break; +case 17: +#line 61 "(null)" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1156 "stdin1.calc.c" +break; +case 18: +#line 63 "(null)" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1161 "stdin1.calc.c" +break; +#line 1163 "stdin1.calc.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/stdin1.error b/test/btyacc/stdin1.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/stdin1.output b/test/btyacc/stdin1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/stdin2.calc.c b/test/btyacc/stdin2.calc.c new file mode 100644 index 00000000000..39f073974ea --- /dev/null +++ b/test/btyacc/stdin2.calc.c @@ -0,0 +1,1396 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 34 "stdin2.calc.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +static const YYINT yystos[] = { 0, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +#if YYBTYACC +static const YYINT yycindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; +#endif +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#if YYBTYACC +static const YYINT yyctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +#endif +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 418 "stdin2.calc.c" + +/* For use in generated program */ +#define yydepth (int)(yystack.s_mark - yystack.s_base) +#if YYBTYACC +#define yytrial (yyps->save) +#endif /* YYBTYACC */ + +#if YYDEBUG +#include /* 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 defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 1091 "stdin2.calc.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 1096 "stdin2.calc.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 1101 "stdin2.calc.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 1106 "stdin2.calc.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 1111 "stdin2.calc.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 1116 "stdin2.calc.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 1121 "stdin2.calc.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 1126 "stdin2.calc.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 1131 "stdin2.calc.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 1136 "stdin2.calc.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 1141 "stdin2.calc.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 1146 "stdin2.calc.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 1151 "stdin2.calc.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 1156 "stdin2.calc.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 1161 "stdin2.calc.c" +break; +#line 1163 "stdin2.calc.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/stdin2.error b/test/btyacc/stdin2.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/stdin2.output b/test/btyacc/stdin2.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/btyacc/varsyntax_calc1.error b/test/btyacc/varsyntax_calc1.error new file mode 100644 index 00000000000..9c1f7152c30 --- /dev/null +++ b/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/test/btyacc/varsyntax_calc1.output b/test/btyacc/varsyntax_calc1.output new file mode 100644 index 00000000000..d6a869f6d35 --- /dev/null +++ b/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/test/btyacc/varsyntax_calc1.tab.c b/test/btyacc/varsyntax_calc1.tab.c new file mode 100644 index 00000000000..27fa6a38c82 --- /dev/null +++ b/test/btyacc/varsyntax_calc1.tab.c @@ -0,0 +1,1747 @@ +/* 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 2 +#define YYMINOR 0 +#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]; + +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 32 "varsyntax_calc1.y" +typedef union YYSTYPE +{ + 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 int 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, +}; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) +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, +}; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +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, +}; +#if YYBTYACC +static const YYINT varsyntax_calc1_ctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, +}; +#endif +#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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +YYLTYPE yyloc; /* position returned by actions */ +YYLTYPE yylloc; /* position from the lexer */ +#endif + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +#ifndef YYLLOC_DEFAULT +#define YYLLOC_DEFAULT(loc, rhs, n) \ +do \ +{ \ + if (n == 0) \ + { \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ + } \ + else \ + { \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ + } \ +} while (0) +#endif /* YYLLOC_DEFAULT */ +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#if YYBTYACC + +#ifndef YYLVQUEUEGROWTH +#define YYLVQUEUEGROWTH 32 +#endif +#endif /* YYBTYACC */ + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#ifndef YYINITSTACKSIZE +#define YYINITSTACKSIZE 200 +#endif + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *p_base; + YYLTYPE *p_mark; +#endif +} YYSTACKDATA; +#if YYBTYACC + +struct YYParseState_s +{ + struct YYParseState_s *save; /* Previously saved parser state */ + YYSTACKDATA yystack; /* saved parser stack */ + int state; /* saved parser state */ + int errflag; /* saved error recovery status */ + int lexeme; /* saved index of the conflict lexeme in the lexical queue */ + YYINT ctry; /* saved index in yyctable[] for this conflict */ +}; +typedef struct YYParseState_s YYParseState; +#endif /* YYBTYACC */ +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#if YYBTYACC + +/* Current parser state */ +static YYParseState *yyps = 0; + +/* yypath != NULL: do the full parse, starting at *yypath parser state. */ +static YYParseState *yypath = 0; + +/* Base of the lexical value queue */ +static YYSTYPE *yylvals = 0; + +/* Current position at lexical value queue */ +static YYSTYPE *yylvp = 0; + +/* End position of lexical value queue */ +static YYSTYPE *yylve = 0; + +/* The last allocated position at the lexical value queue */ +static YYSTYPE *yylvlim = 0; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) +/* Base of the lexical position queue */ +static YYLTYPE *yylpsns = 0; + +/* Current position at lexical position queue */ +static YYLTYPE *yylpp = 0; + +/* End position of lexical position queue */ +static YYLTYPE *yylpe = 0; + +/* The last allocated position at the lexical position queue */ +static YYLTYPE *yylplim = 0; +#endif + +/* Current position at lexical token queue */ +static YYINT *yylexp = 0; + +static YYINT *yylexemes = 0; +#endif /* YYBTYACC */ +#line 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 656 "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; + YYINT *newss; + YYSTYPE *newvs; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *newps; +#endif + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return YYENOMEM; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return YYENOMEM; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return YYENOMEM; + + data->l_base = newvs; + data->l_mark = newvs + i; + +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); + if (newps == 0) + return YYENOMEM; + + data->p_base = newps; + data->p_mark = newps + i; +#endif + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); +#endif + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + free(data->p_base); +#endif + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif /* YYPURE || defined(YY_NO_LEAKS) */ +#if YYBTYACC + +static YYParseState * +yyNewState(unsigned size) +{ + YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); + if (p == NULL) return NULL; + + p->yystack.stacksize = size; + if (size == 0) + { + p->yystack.s_base = NULL; + p->yystack.l_base = NULL; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = NULL; +#endif + return p; + } + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); + if (p->yystack.s_base == NULL) return NULL; + p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); + if (p->yystack.l_base == NULL) return NULL; + memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); + if (p->yystack.p_base == NULL) return NULL; + memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); +#endif + + return p; +} + +static void +yyFreeState(YYParseState *p) +{ + yyfreestack(&p->yystack); + free(p); +} +#endif /* YYBTYACC */ + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +#if YYBTYACC +#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) +#define YYVALID_NESTED do { if (yyps->save && \ + yyps->save->save == 0) goto yyvalid; } while(0) +#endif /* YYBTYACC */ + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate, yyresult; +#if YYBTYACC + int yynewerrflag; + YYParseState *yyerrctx = NULL; +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ +#endif +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } + if (yydebug) + fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); +#endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif + +#if YYBTYACC + yyps = yyNewState(0); if (yyps == 0) goto yyenomem; + yyps->save = 0; +#endif /* YYBTYACC */ + yym = 0; + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 59 "varsyntax_calc1.y" + { + (void) printf("%15.8f\n", yystack.l_mark[-1].dval); + } +#line 1331 "varsyntax_calc1.tab.c" +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); + } +#line 1338 "varsyntax_calc1.tab.c" +break; +case 5: +#line 67 "varsyntax_calc1.y" + { + dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; + } +#line 1345 "varsyntax_calc1.tab.c" +break; +case 6: +#line 71 "varsyntax_calc1.y" + { + vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; + } +#line 1352 "varsyntax_calc1.tab.c" +break; +case 7: +#line 75 "varsyntax_calc1.y" + { + yyerrok; + } +#line 1359 "varsyntax_calc1.tab.c" +break; +case 9: +#line 82 "varsyntax_calc1.y" + { + yyval.dval = dreg[yystack.l_mark[0].ival]; /* $$ & $1 are sufficient here*/ + } +#line 1366 "varsyntax_calc1.tab.c" +break; +case 10: +#line 86 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; + } +#line 1373 "varsyntax_calc1.tab.c" +break; +case 11: +#line 90 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; + } +#line 1380 "varsyntax_calc1.tab.c" +break; +case 12: +#line 94 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; + } +#line 1387 "varsyntax_calc1.tab.c" +break; +case 13: +#line 98 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; + } +#line 1394 "varsyntax_calc1.tab.c" +break; +case 14: +#line 102 "varsyntax_calc1.y" + { + yyval.dval = -yystack.l_mark[0].dval; + } +#line 1401 "varsyntax_calc1.tab.c" +break; +case 15: +#line 106 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-1].dval; + } +#line 1408 "varsyntax_calc1.tab.c" +break; +case 16: +#line 112 "varsyntax_calc1.y" + { + yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; + } +#line 1415 "varsyntax_calc1.tab.c" +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; + } + } +#line 1428 "varsyntax_calc1.tab.c" +break; +case 18: +#line 126 "varsyntax_calc1.y" + { + yyval.vval = vreg[yystack.l_mark[0].ival]; + } +#line 1435 "varsyntax_calc1.tab.c" +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; + } +#line 1443 "varsyntax_calc1.tab.c" +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; + } +#line 1451 "varsyntax_calc1.tab.c" +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; + } +#line 1459 "varsyntax_calc1.tab.c" +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; + } +#line 1467 "varsyntax_calc1.tab.c" +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 ); + } +#line 1474 "varsyntax_calc1.tab.c" +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 ); + } +#line 1481 "varsyntax_calc1.tab.c" +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 ); + } +#line 1489 "varsyntax_calc1.tab.c" +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 ); + } +#line 1497 "varsyntax_calc1.tab.c" +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; + } +#line 1505 "varsyntax_calc1.tab.c" +break; +case 28: +#line 173 "varsyntax_calc1.y" + { + yyval.vval = yystack.l_mark[-1].vval; + } +#line 1512 "varsyntax_calc1.tab.c" +break; +#line 1514 "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 */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/test/btyacc/varsyntax_calc1.tab.h b/test/btyacc/varsyntax_calc1.tab.h new file mode 100644 index 00000000000..5c28ca8ef13 --- /dev/null +++ b/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 YYSTYPE +{ + 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/test/btyacc_calc1.y b/test/btyacc_calc1.y new file mode 100644 index 00000000000..0c6311c881b --- /dev/null +++ b/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/test/btyacc_demo.y b/test/btyacc_demo.y new file mode 100644 index 00000000000..892434c8b15 --- /dev/null +++ b/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/test/btyacc_destroy1.y b/test/btyacc_destroy1.y new file mode 100644 index 00000000000..413066ddb17 --- /dev/null +++ b/test/btyacc_destroy1.y @@ -0,0 +1,91 @@ +%parse-param { struct parser_param *param , int flag } + +%{ +#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; + +struct parser_param { + int *rtrn; + symbol ss; +}; + +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 +%type locnamelist +%type class +%type type +%type namelist + +%destructor { if (!param->rtrn) close($$); } + +%destructor { + namelist *p = $$; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } declaration + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration: class type namelist'(' class ',' type ')' + { $$ = $3; } + | type locnamelist '(' class ')' + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist: namelist NAME + { $$->s = mksymbol($0, $0, $2); + $$->next = $1; + } + | NAME + { $$->s = mksymbol(0, 0, $1); + $$->next = NULL; + } + ; + +locnamelist: namelist '(' LOCAL ',' type ')' + { $$ = $1; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/test/btyacc_destroy2.y b/test/btyacc_destroy2.y new file mode 100644 index 00000000000..883b9f5e955 --- /dev/null +++ b/test/btyacc_destroy2.y @@ -0,0 +1,91 @@ +%parse-param { struct parser_param *param } { int flag } + +%{ +#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; + +struct parser_param { + int *rtrn; + symbol ss; +}; + +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 +%type locnamelist +%type class +%type type +%type namelist + +%destructor { if (!param->rtrn) close($$); } + +%destructor { + namelist *p = $$; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } declaration + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration: class type namelist'(' class ',' type ')' + { $$ = $3; } + | type locnamelist '(' class ')' + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist: namelist NAME + { $$->s = mksymbol($0, $0, $2); + $$->next = $1; + } + | NAME + { $$->s = mksymbol(0, 0, $1); + $$->next = NULL; + } + ; + +locnamelist: namelist '(' LOCAL ',' type ')' + { $$ = $1; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/test/btyacc_destroy3.y b/test/btyacc_destroy3.y new file mode 100644 index 00000000000..c111273baca --- /dev/null +++ b/test/btyacc_destroy3.y @@ -0,0 +1,94 @@ +%parse-param { + struct parser_param *param, + int flag + } + +%{ +#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; + +struct parser_param { + int *rtrn; + symbol ss; +}; + +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 +%type locnamelist +%type class +%type type +%type namelist + +%destructor { if (!param->rtrn) close($$); } + +%destructor { + namelist *p = $$; + while (p != NULL) + { namelist *pp = p; + p = p->next; + free(pp->s); free(pp); + } + } declaration + +%union +{ + class cval; + type tval; + namelist * nlist; + name id; +} + +%start declaration + +%% +declaration: class type namelist'(' class ',' type ')' + { $$ = $3; } + | type locnamelist '(' class ')' + { $$ = $2; } + ; + +class : GLOBAL { $$ = cGLOBAL; } + | LOCAL { $$ = cLOCAL; } + ; + +type : REAL { $$ = tREAL; } + | INTEGER { $$ = tINTEGER; } + ; + +namelist: namelist NAME + { $$->s = mksymbol($0, $0, $2); + $$->next = $1; + } + | NAME + { $$->s = mksymbol(0, 0, $1); + $$->next = NULL; + } + ; + +locnamelist: namelist '(' LOCAL ',' type ')' + { $$ = $1; } + ; +%% + +extern int YYLEX_DECL(); +extern void YYERROR_DECL(); diff --git a/test/calc.y b/test/calc.y new file mode 100644 index 00000000000..c2e5a898c93 --- /dev/null +++ b/test/calc.y @@ -0,0 +1,106 @@ +%{ +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token DIGIT LETTER + +%left '|' +%left '&' +%left '+' '-' +%left '*' '/' '%' +%left UMINUS /* supplies precedence for unary minus */ + +%% /* beginning of rules section */ + +list : /* empty */ + | list stat '\n' + | list error '\n' + { yyerrok ; } + ; + +stat : expr + { printf("%d\n",$1);} + | LETTER '=' expr + { regs[$1] = $3; } + ; + +expr : '(' expr ')' + { $$ = $2; } + | expr '+' expr + { $$ = $1 + $3; } + | expr '-' expr + { $$ = $1 - $3; } + | expr '*' expr + { $$ = $1 * $3; } + | expr '/' expr + { $$ = $1 / $3; } + | expr '%' expr + { $$ = $1 % $3; } + | expr '&' expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | '-' expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/calc1.y b/test/calc1.y new file mode 100644 index 00000000000..1f42e1fce82 --- /dev/null +++ b/test/calc1.y @@ -0,0 +1,305 @@ +%{ + +/* 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; + 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 '*' '/' +%left UMINUS /* precedence for unary minus */ + +%% /* beginning of rules section */ + +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]; + } + | 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/test/calc2.y b/test/calc2.y new file mode 100644 index 00000000000..d9193d0872b --- /dev/null +++ b/test/calc2.y @@ -0,0 +1,124 @@ +%parse-param { int regs[26] } +%parse-param { int *base } + +%lex-param { int *base } + +%{ +# 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 + +%} + +%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/test/calc3.y b/test/calc3.y new file mode 100644 index 00000000000..2c9148e8010 --- /dev/null +++ b/test/calc3.y @@ -0,0 +1,127 @@ +%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 + +%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/test/calc_code_all.y b/test/calc_code_all.y new file mode 100644 index 00000000000..5924877f158 --- /dev/null +++ b/test/calc_code_all.y @@ -0,0 +1,113 @@ +%code { /* CODE-DEFAULT2 */ } +%code { /* CODE-DEFAULT */ } +%code requires { /* CODE-REQUIRES */ } +%code provides { /* CODE-PROVIDES */ } +%code top { /* CODE-TOP */ } +%code provides { /* CODE-PROVIDES2 */ } + +%{ +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token DIGIT LETTER + +%left '|' +%left '&' +%left '+' '-' +%left '*' '/' '%' +%left UMINUS /* supplies precedence for unary minus */ + +%% /* beginning of rules section */ + +list : /* empty */ + | list stat '\n' + | list error '\n' + { yyerrok ; } + ; + +stat : expr + { printf("%d\n",$1);} + | LETTER '=' expr + { regs[$1] = $3; } + ; + +expr : '(' expr ')' + { $$ = $2; } + | expr '+' expr + { $$ = $1 + $3; } + | expr '-' expr + { $$ = $1 - $3; } + | expr '*' expr + { $$ = $1 * $3; } + | expr '/' expr + { $$ = $1 / $3; } + | expr '%' expr + { $$ = $1 % $3; } + | expr '&' expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | '-' expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/calc_code_default.y b/test/calc_code_default.y new file mode 100644 index 00000000000..a0829affbe3 --- /dev/null +++ b/test/calc_code_default.y @@ -0,0 +1,109 @@ +%code { /* CODE-DEFAULT */ } +%code { /* CODE-DEFAULT2 */ } + +%{ +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token DIGIT LETTER + +%left '|' +%left '&' +%left '+' '-' +%left '*' '/' '%' +%left UMINUS /* supplies precedence for unary minus */ + +%% /* beginning of rules section */ + +list : /* empty */ + | list stat '\n' + | list error '\n' + { yyerrok ; } + ; + +stat : expr + { printf("%d\n",$1);} + | LETTER '=' expr + { regs[$1] = $3; } + ; + +expr : '(' expr ')' + { $$ = $2; } + | expr '+' expr + { $$ = $1 + $3; } + | expr '-' expr + { $$ = $1 - $3; } + | expr '*' expr + { $$ = $1 * $3; } + | expr '/' expr + { $$ = $1 / $3; } + | expr '%' expr + { $$ = $1 % $3; } + | expr '&' expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | '-' expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/calc_code_imports.y b/test/calc_code_imports.y new file mode 100644 index 00000000000..ded30926f7b --- /dev/null +++ b/test/calc_code_imports.y @@ -0,0 +1,109 @@ +%code imports { /* CODE-IMPORTS */ } +%code imports { /* CODE-IMPORTS2 */ } + +%{ +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token DIGIT LETTER + +%left '|' +%left '&' +%left '+' '-' +%left '*' '/' '%' +%left UMINUS /* supplies precedence for unary minus */ + +%% /* beginning of rules section */ + +list : /* empty */ + | list stat '\n' + | list error '\n' + { yyerrok ; } + ; + +stat : expr + { printf("%d\n",$1);} + | LETTER '=' expr + { regs[$1] = $3; } + ; + +expr : '(' expr ')' + { $$ = $2; } + | expr '+' expr + { $$ = $1 + $3; } + | expr '-' expr + { $$ = $1 - $3; } + | expr '*' expr + { $$ = $1 * $3; } + | expr '/' expr + { $$ = $1 / $3; } + | expr '%' expr + { $$ = $1 % $3; } + | expr '&' expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | '-' expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/calc_code_provides.y b/test/calc_code_provides.y new file mode 100644 index 00000000000..53776928dcd --- /dev/null +++ b/test/calc_code_provides.y @@ -0,0 +1,109 @@ +%code provides { /* CODE-PROVIDES */ } +%code provides { /* CODE-PROVIDES2 */ } + +%{ +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token DIGIT LETTER + +%left '|' +%left '&' +%left '+' '-' +%left '*' '/' '%' +%left UMINUS /* supplies precedence for unary minus */ + +%% /* beginning of rules section */ + +list : /* empty */ + | list stat '\n' + | list error '\n' + { yyerrok ; } + ; + +stat : expr + { printf("%d\n",$1);} + | LETTER '=' expr + { regs[$1] = $3; } + ; + +expr : '(' expr ')' + { $$ = $2; } + | expr '+' expr + { $$ = $1 + $3; } + | expr '-' expr + { $$ = $1 - $3; } + | expr '*' expr + { $$ = $1 * $3; } + | expr '/' expr + { $$ = $1 / $3; } + | expr '%' expr + { $$ = $1 % $3; } + | expr '&' expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | '-' expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/calc_code_requires.y b/test/calc_code_requires.y new file mode 100644 index 00000000000..5254bcbd6de --- /dev/null +++ b/test/calc_code_requires.y @@ -0,0 +1,109 @@ +%code requires { /* CODE-REQUIRES */ } +%code requires { /* CODE-REQUIRES2 */ } + +%{ +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token DIGIT LETTER + +%left '|' +%left '&' +%left '+' '-' +%left '*' '/' '%' +%left UMINUS /* supplies precedence for unary minus */ + +%% /* beginning of rules section */ + +list : /* empty */ + | list stat '\n' + | list error '\n' + { yyerrok ; } + ; + +stat : expr + { printf("%d\n",$1);} + | LETTER '=' expr + { regs[$1] = $3; } + ; + +expr : '(' expr ')' + { $$ = $2; } + | expr '+' expr + { $$ = $1 + $3; } + | expr '-' expr + { $$ = $1 - $3; } + | expr '*' expr + { $$ = $1 * $3; } + | expr '/' expr + { $$ = $1 / $3; } + | expr '%' expr + { $$ = $1 % $3; } + | expr '&' expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | '-' expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/calc_code_top.y b/test/calc_code_top.y new file mode 100644 index 00000000000..8520791e4de --- /dev/null +++ b/test/calc_code_top.y @@ -0,0 +1,109 @@ +%code top { /* CODE-TOP */ } +%code top { /* CODE-TOP2 */ } + +%{ +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token DIGIT LETTER + +%left '|' +%left '&' +%left '+' '-' +%left '*' '/' '%' +%left UMINUS /* supplies precedence for unary minus */ + +%% /* beginning of rules section */ + +list : /* empty */ + | list stat '\n' + | list error '\n' + { yyerrok ; } + ; + +stat : expr + { printf("%d\n",$1);} + | LETTER '=' expr + { regs[$1] = $3; } + ; + +expr : '(' expr ')' + { $$ = $2; } + | expr '+' expr + { $$ = $1 + $3; } + | expr '-' expr + { $$ = $1 - $3; } + | expr '*' expr + { $$ = $1 * $3; } + | expr '/' expr + { $$ = $1 / $3; } + | expr '%' expr + { $$ = $1 % $3; } + | expr '&' expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | '-' expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/code_calc.y b/test/code_calc.y new file mode 100644 index 00000000000..6947b74e175 --- /dev/null +++ b/test/code_calc.y @@ -0,0 +1,114 @@ +%token-table + +%{ +# include +# include + +int regs[26]; +int base; + +#ifdef YYBISON +int yylex(void); +static void yyerror(const char *s); +#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) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/code_debug.y b/test/code_debug.y new file mode 100644 index 00000000000..bb771567606 --- /dev/null +++ b/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/test/code_error.y b/test/code_error.y new file mode 100644 index 00000000000..bb771567606 --- /dev/null +++ b/test/code_error.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/test/empty.y b/test/empty.y new file mode 100644 index 00000000000..2e60a743cf0 --- /dev/null +++ b/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/test/err_inherit1.y b/test/err_inherit1.y new file mode 100644 index 00000000000..6c16e17cd8b --- /dev/null +++ b/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/test/err_inherit2.y b/test/err_inherit2.y new file mode 100644 index 00000000000..a39e2d0f1bf --- /dev/null +++ b/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/test/err_inherit3.y b/test/err_inherit3.y new file mode 100644 index 00000000000..f52a5f7b6e3 --- /dev/null +++ b/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/test/err_inherit4.y b/test/err_inherit4.y new file mode 100644 index 00000000000..8e9aeb9fe6e --- /dev/null +++ b/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; @$ = @3; } + | type locnamelist($1) + { $$ = $2; @$ = @-1; } + ; + +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/test/err_inherit5.y b/test/err_inherit5.y new file mode 100644 index 00000000000..56c5c7e4c07 --- /dev/null +++ b/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/test/err_syntax1.y b/test/err_syntax1.y new file mode 100644 index 00000000000..27355207a24 --- /dev/null +++ b/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/test/err_syntax10.y b/test/err_syntax10.y new file mode 100644 index 00000000000..581f8458df5 --- /dev/null +++ b/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/test/err_syntax11.y b/test/err_syntax11.y new file mode 100644 index 00000000000..81bdf6914cf --- /dev/null +++ b/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/test/err_syntax12.y b/test/err_syntax12.y new file mode 100644 index 00000000000..ae1a48c1762 --- /dev/null +++ b/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/test/err_syntax13.y b/test/err_syntax13.y new file mode 100644 index 00000000000..f28ed435eef --- /dev/null +++ b/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/test/err_syntax14.y b/test/err_syntax14.y new file mode 100644 index 00000000000..43e4fc07890 --- /dev/null +++ b/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/test/err_syntax15.y b/test/err_syntax15.y new file mode 100644 index 00000000000..88814c9143d --- /dev/null +++ b/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/test/err_syntax16.y b/test/err_syntax16.y new file mode 100644 index 00000000000..0479e821776 --- /dev/null +++ b/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/test/err_syntax17.y b/test/err_syntax17.y new file mode 100644 index 00000000000..a5551c2f7c7 --- /dev/null +++ b/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/test/err_syntax18.y b/test/err_syntax18.y new file mode 100644 index 00000000000..1407af802ae --- /dev/null +++ b/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/test/err_syntax19.y b/test/err_syntax19.y new file mode 100644 index 00000000000..e2ee5497a8e --- /dev/null +++ b/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/test/err_syntax2.y b/test/err_syntax2.y new file mode 100644 index 00000000000..247511ebd8e --- /dev/null +++ b/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/test/err_syntax20.y b/test/err_syntax20.y new file mode 100644 index 00000000000..880e0181704 --- /dev/null +++ b/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/test/err_syntax21.y b/test/err_syntax21.y new file mode 100644 index 00000000000..ba6ec7080f0 --- /dev/null +++ b/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/test/err_syntax22.y b/test/err_syntax22.y new file mode 100644 index 00000000000..e92decbf5e5 --- /dev/null +++ b/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/test/err_syntax23.y b/test/err_syntax23.y new file mode 100644 index 00000000000..4fe51c5c553 --- /dev/null +++ b/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/test/err_syntax24.y b/test/err_syntax24.y new file mode 100644 index 00000000000..3cc4f87a767 --- /dev/null +++ b/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/test/err_syntax25.y b/test/err_syntax25.y new file mode 100644 index 00000000000..9b5dfd13eb8 --- /dev/null +++ b/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/test/err_syntax26.y b/test/err_syntax26.y new file mode 100644 index 00000000000..748382ba2c0 --- /dev/null +++ b/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/test/err_syntax3.y b/test/err_syntax3.y new file mode 100644 index 00000000000..c10b227f2bf --- /dev/null +++ b/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/test/err_syntax4.y b/test/err_syntax4.y new file mode 100644 index 00000000000..2c6f22ff25f --- /dev/null +++ b/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/test/err_syntax5.y b/test/err_syntax5.y new file mode 100644 index 00000000000..ca9ce1a40e7 --- /dev/null +++ b/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/test/err_syntax6.y b/test/err_syntax6.y new file mode 100644 index 00000000000..5d87945cb1f --- /dev/null +++ b/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/test/err_syntax7.y b/test/err_syntax7.y new file mode 100644 index 00000000000..783d563f33d --- /dev/null +++ b/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/test/err_syntax7a.y b/test/err_syntax7a.y new file mode 100644 index 00000000000..ae105d0d0c9 --- /dev/null +++ b/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/test/err_syntax7b.y b/test/err_syntax7b.y new file mode 100644 index 00000000000..a3e5e216ffe --- /dev/null +++ b/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/test/err_syntax8.y b/test/err_syntax8.y new file mode 100644 index 00000000000..5ac0974dba4 --- /dev/null +++ b/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/test/err_syntax8a.y b/test/err_syntax8a.y new file mode 100644 index 00000000000..9a3a76cf42c --- /dev/null +++ b/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/test/err_syntax9.y b/test/err_syntax9.y new file mode 100644 index 00000000000..f3ec6fab319 --- /dev/null +++ b/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/test/error.y b/test/error.y new file mode 100644 index 00000000000..673c68d68e9 --- /dev/null +++ b/test/error.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/test/expr.oxout.h b/test/expr.oxout.h new file mode 100644 index 00000000000..9317098abb2 --- /dev/null +++ b/test/expr.oxout.h @@ -0,0 +1,90 @@ +/* testing only */ + +typedef int yyyWAT; +typedef int yyyWST; +typedef int yyyFT; + +typedef struct yyyLexemes { + char * lexeme; +} yyyLexemes; + +typedef struct yyyAttribs { + yyyLexemes yyyAttrb1; +} yyyAttribs; + +typedef struct yyyParent { + struct yyyGNT * noderef; + struct yyyStackItem * stackref; +} yyyParent; + +typedef struct yyyGNT { + int * refCountList; + int refCountListLen; + struct yyyParent parent; + int parentIsStack; + int prodNum; + int whichSym; + struct yyyGNT ** cL; + int cLlen; + yyyAttribs yyyAttrbs; +} yyyGNT; + +typedef int yyyRCT; + +typedef struct yyyStackItem { + int wa; + int whichSym; + yyyGNT * node; + long solvedSAlist; +} yyySIT; + +#define yyyRSitem yyySIT + +yyyRSitem *yyyRSTop; +yyyRSitem *yyyAfterRS; +yyyRSitem *yyyRS; + +#undef yyparse +#undef yylex +#undef yyerror +#undef yychar +#undef yyval +#undef yylval +#undef yydebug +#undef yynerrs +#undef yyerrflag +#undef yylhs +#undef yylen +#undef yydefred +#undef yystos +#undef yydgoto +#undef yysindex +#undef yyrindex +#undef yygindex +#undef yytable +#undef yycheck +#undef yyname +#undef yyrule +#undef yycindex +#undef yyctable + +struct { + int test_yycheck [256]; + int test_yydefred [256]; + int test_yydgoto [256]; + int test_yygindex [256]; + int test_yylen [256]; + int test_yylhs [256]; + int test_yyrindex [256]; + int test_yysindex [256]; + int test_yytable [256]; +#define yycheck test_expr.test_yycheck +#define yydefred test_expr.test_yydefred +#define yydgoto test_expr.test_yydgoto +#define yygindex test_expr.test_yygindex +#define yylen test_expr.test_yylen +#define yylhs test_expr.test_yylhs +#define yyrindex test_expr.test_yyrindex +#define yysindex test_expr.test_yysindex +#define yytable test_expr.test_yytable +} test_expr; diff --git a/test/expr.oxout.y b/test/expr.oxout.y new file mode 100644 index 00000000000..80f16bd9b3a --- /dev/null +++ b/test/expr.oxout.y @@ -0,0 +1,1446 @@ +/* output from Ox version G1.04 */ +#line 1 "expr.Y" +#line 4 "expr.oxout.y" +%{ +#include +#include +%} +#line 1 "expr.Y" +/* Y-file for translation of infix expressions to prefix and postfix */ +%token ID CONST +%start yyyAugNonterm +%left '+' '-' +%left '*' '/' +%nonassoc '*' + +%{ +#include "expr.oxout.h" +#include + +extern int yylex(void); +extern void yyerror(const char *); +%} + +#line 25 "expr.oxout.y" + +%{ +#include +#define yyyR USHRT_MAX +%} +%type yyyAugNonterm +%union { +struct yyyOxAttrbs { +struct yyyStackItem *yyyOxStackItem; +} yyyOxAttrbs; +} + +%{ +#include +#include + +static int yyyYok = 1; + +extern yyyFT yyyRCIL[]; + +void yyyExecuteRRsection(yyyGNT *rootNode); +void yyyYoxInit(void); +void yyyDecorate(void); +struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ +void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); +void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); +void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); +void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); +void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); +void yyyabort(void); + +%} + + +#line 20 "expr.Y" +%% + +#line 63 "expr.oxout.y" +yyyAugNonterm + : {yyyYoxInit();} + s + { + yyyDecorate(); yyyExecuteRRsection($2.yyyOxStackItem->node); + } + ; +#line 21 "expr.Y" +s : expr +#line 73 "expr.oxout.y" +{if(yyyYok){ +yyyGenIntNode(1,1,0,&$$,&$1); +yyyAdjustINRC(1,1,0,0,&$$,&$1);}} + +#line 27 "expr.Y" +expr : expr '*' expr +#line 80 "expr.oxout.y" +{if(yyyYok){ +yyyGenIntNode(2,3,0,&$$,&$1,&$2,&$3); +yyyAdjustINRC(2,3,0,0,&$$,&$1,&$2,&$3);}} + +#line 31 "expr.Y" + | expr '+' expr +#line 87 "expr.oxout.y" +{if(yyyYok){ +yyyGenIntNode(3,3,0,&$$,&$1,&$2,&$3); +yyyAdjustINRC(3,3,0,0,&$$,&$1,&$2,&$3);}} + +#line 35 "expr.Y" + | expr '/' expr +#line 94 "expr.oxout.y" +{if(yyyYok){ +yyyGenIntNode(4,3,0,&$$,&$1,&$2,&$3); +yyyAdjustINRC(4,3,0,0,&$$,&$1,&$2,&$3);}} + +#line 39 "expr.Y" + | expr '-' expr +#line 101 "expr.oxout.y" +{if(yyyYok){ +yyyGenIntNode(5,3,0,&$$,&$1,&$2,&$3); +yyyAdjustINRC(5,3,0,0,&$$,&$1,&$2,&$3);}} + +#line 43 "expr.Y" + | '(' expr ')' +#line 108 "expr.oxout.y" +{if(yyyYok){ +yyyGenIntNode(6,3,0,&$$,&$1,&$2,&$3); +yyyAdjustINRC(6,3,0,0,&$$,&$1,&$2,&$3);}} +#line 44 "expr.Y" + | ID +#line 114 "expr.oxout.y" +{if(yyyYok){ +yyyGenIntNode(7,1,0,&$$,&$1); +yyyAdjustINRC(7,1,0,0,&$$,&$1);}} + +#line 48 "expr.Y" + | CONST +#line 121 "expr.oxout.y" +{if(yyyYok){ +yyyGenIntNode(8,1,0,&$$,&$1); +yyyAdjustINRC(8,1,0,0,&$$,&$1);}} + +#line 52 "expr.Y" + ; +%% + +int yyparse(void); + +int main() + {yyparse(); + } + + + +#line 138 "expr.oxout.y" +long yyySSALspaceSize = 20000; +long yyyRSmaxSize = 1000; +long yyyTravStackMaxSize = 2000; + +struct yyySolvedSAlistCell {yyyWAT attrbNum; + long next; + }; + +#define yyyLambdaSSAL 0 +long yyySSALCfreeList = yyyLambdaSSAL; +long yyyNewSSALC = 1; + +struct yyySolvedSAlistCell *yyySSALspace; + +long yyyNbytesStackStg; + + + +yyyFT yyyRCIL[1]; + +short yyyIIIEL[] = {0, +0,2,6,10,14,18,22,24, +}; + +long yyyIIEL[] = { +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,1, +}; + +long yyyIEL[] = { +0,0,0, +}; + +yyyFT yyyEntL[1]; + +void yyyfatal(char *msg) +{fputs(msg,stderr);exit(-1);} + + + +#define yyySSALof 'S' +#define yyyRSof 'q' +#define yyyTSof 't' + + + +void yyyHandleOverflow(char which) + {char *msg1 = "?", *msg2; + long oldSize = 0, newSize; + switch(which) + { + case yyySSALof : + msg1 = "SSAL overflow: "; + oldSize = yyySSALspaceSize; + break; + case yyyRSof : + msg1 = "ready set overflow: "; + oldSize = yyyRSmaxSize; + break; + case yyyTSof : + msg1 = "traversal stack overflow: "; + oldSize = yyyTravStackMaxSize; + break; + default :; + } + newSize = (3*oldSize)/2; + if (newSize < 100) newSize = 100; + fputs(msg1,stderr); + fprintf(stderr,"size was %ld.\n",oldSize); + msg2 = " Have to modify evaluator: -Y%c%ld.\n"; + fprintf(stderr,msg2,which,newSize); + exit(-1); + } + + + +void yyySignalEnts(yyyGNT *node,long startP,long stopP) + {yyyGNT *dumNode; + + while (startP < stopP) + { + if (!yyyEntL[startP]) dumNode = node; + else dumNode = (node->cL)[yyyEntL[startP]-1]; + if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] + ) + ) + ) + { + if (++yyyRSTop == yyyAfterRS) + {yyyHandleOverflow(yyyRSof); + break; + } + yyyRSTop->node = dumNode; + yyyRSTop->whichSym = yyyEntL[startP]; + yyyRSTop->wa = yyyEntL[startP+1]; + } + startP += 2; + } + } + + + + + + +void yyySolveAndSignal() { +long yyyiDum,*yyypL; +int yyyws,yyywa; +yyyGNT *yyyRSTopN,*yyyRefN; +yyyParent yyyRSTopNp; + + +yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; +yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; +yyywa = yyyRSTop->wa; +yyyRSTop--; +switch(yyyRefN->prodNum) { +case 1: /***yacc rule 1***/ + switch (yyyws) { + } +break; +case 2: /***yacc rule 2***/ + switch (yyyws) { + } +break; +case 3: /***yacc rule 3***/ + switch (yyyws) { + } +break; +case 4: /***yacc rule 4***/ + switch (yyyws) { + } +break; +case 5: /***yacc rule 5***/ + switch (yyyws) { + } +break; +case 6: /***yacc rule 6***/ + switch (yyyws) { + } +break; +case 7: /***yacc rule 7***/ + switch (yyyws) { + case 1: /**/ + switch (yyywa) { + } + break; + } +break; +case 8: /***yacc rule 8***/ + switch (yyyws) { + case 1: /**/ + switch (yyywa) { + } + break; + } +break; +} /* switch */ + +if (yyyws) /* the just-solved instance was inherited. */ + {if (yyyRSTopN->prodNum) + {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; + yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], + yyyIEL[yyyiDum+1] + ); + } + } + else /* the just-solved instance was synthesized. */ + {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ + {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + + yyyRSTopN->whichSym + ] + + yyywa; + yyySignalEnts(yyyRSTopNp.noderef, + yyyIEL[yyyiDum], + yyyIEL[yyyiDum+1] + ); + } + else /* node is still on the stack--it has no parent yet. */ + {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); + if (yyySSALCfreeList == yyyLambdaSSAL) + {yyySSALspace[yyyNewSSALC].next = *yyypL; + if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) + yyyHandleOverflow(yyySSALof); + } + else + {yyyiDum = yyySSALCfreeList; + yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; + yyySSALspace[yyyiDum].next = *yyypL; + *yyypL = yyyiDum; + } + yyySSALspace[*yyypL].attrbNum = yyywa; + } + } + +} /* yyySolveAndSignal */ + + + + + + +#define condStg unsigned int conds; +#define yyyClearConds {yyyTST->conds = 0;} +#define yyySetCond(n) {yyyTST->conds += (1<<(n));} +#define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) + + + +struct yyyTravStackItem {yyyGNT *node; + char isReady; + condStg + }; + + + +void yyyDoTraversals(yyyGNT *rootNode) +{struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; + yyyGNT *yyyTSTn,**yyyCLptr2; + int yyyi,yyyRL,yyyPass; + int i; + + if (!yyyYok) return; + if ((yyyTravStack = + ((struct yyyTravStackItem *) + calloc((size_t)yyyTravStackMaxSize, + (size_t)sizeof(struct yyyTravStackItem) + ) + ) + ) + == + (struct yyyTravStackItem *)NULL + ) + {fputs("malloc error in traversal stack allocation\n",stderr); + exit(-1); + } + +yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; +yyyTravStack++; + + +for (yyyi=0; yyyi<2; yyyi++) { +yyyTST = yyyTravStack; +yyyTST->node = rootNode; +yyyTST->isReady = 0; +yyyClearConds + +while(yyyTST >= yyyTravStack) + {yyyTSTn = yyyTST->node; + if (yyyTST->isReady) + {yyyPass = 1; + goto yyyTravSwitch; +yyyTpop: + yyyTST--; + } + else + {yyyPass = 0; + goto yyyTravSwitch; +yyyTpush: + yyyTST->isReady = 1; + if (yyyTSTn->prodNum) + {if (yyyRL) + {yyyCLptr2 = yyyTSTn->cL; + i = yyyTSTn->cLlen; + while (i--) + {if (++yyyTST == yyyAfterTravStack) + yyyHandleOverflow(yyyTSof); + else + {yyyTST->node = *yyyCLptr2; + yyyTST->isReady = 0; + yyyClearConds + } + yyyCLptr2++; + } + } /* right to left */ + else /* left to right */ + {i = yyyTSTn->cLlen; + yyyCLptr2 = yyyTSTn->cL + i; + while (i--) + {yyyCLptr2--; + if (++yyyTST == yyyAfterTravStack) + yyyHandleOverflow(yyyTSof); + else + {yyyTST->node = *yyyCLptr2; + yyyTST->isReady = 0; + yyyClearConds + } + } + } /* left to right */ + } + } /* else */ + continue; +yyyTravSwitch: + switch(yyyTSTn->prodNum) { +case 1: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + +if (! +#line 24 "expr.Y" + (1) +#line 444 "expr.oxout.y" +) yyySetCond(1) +yyySetCond(2) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 24 "expr.Y" + +#line 453 "expr.oxout.y" +} +if (yyyCond(1) != yyyPass) { +#line 24 "expr.Y" + printf("\n"); + +#line 459 "expr.oxout.y" +} +if (yyyCond(2) != yyyPass) { +#line 25 "expr.Y" + printf("prefix: "); + +#line 465 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; +if ( +#line 23 "expr.Y" + (1) +#line 477 "expr.oxout.y" +) yyySetCond(2) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 22 "expr.Y" + printf("\n"); + +#line 486 "expr.oxout.y" +} +if (yyyCond(1) != yyyPass) { +#line 23 "expr.Y" + +#line 491 "expr.oxout.y" +} +if (yyyCond(2) != yyyPass) { +#line 23 "expr.Y" + printf("postfix: "); + +#line 497 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 2: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 29 "expr.Y" + printf(" * "); + +#line 518 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 28 "expr.Y" + printf(" * "); + +#line 533 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 3: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 32 "expr.Y" + printf(" + "); + +#line 554 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 33 "expr.Y" + printf(" + "); + +#line 569 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 4: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 37 "expr.Y" + printf(" / "); + +#line 590 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 36 "expr.Y" + printf(" / "); + +#line 605 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 5: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 41 "expr.Y" + printf(" - "); + +#line 626 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 40 "expr.Y" + printf(" - "); + +#line 641 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 6: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + + break; + } + break; + } + +break; +case 7: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 46 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 685 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 45 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 700 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 8: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 50 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 721 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 49 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 736 "expr.oxout.y" +} + break; + } + break; + } + +break; + } /* switch */ + if (yyyPass) goto yyyTpop; else goto yyyTpush; + } /* while */ + } /* for */ +} /* yyyDoTraversals */ + +void yyyExecuteRRsection(yyyGNT *rootNode) { + int yyyi; + long cycleSum = 0; + long nNZrc = 0; + + if (!yyyYok) return; + yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); + if (nNZrc) + { + fputs("\n\n\n**********\n",stderr); + fputs("cycle detected in completed parse tree",stderr); + fputs(" after decoration.\n",stderr); +#if CYCLE_VERBOSE + fprintf(stderr, + "number of unsolved attribute instances == %ld.\n", + nNZrc + ); + fprintf(stderr, + "total number of remaining dependencies == %ld.\n", + cycleSum + ); + fputs("average number of remaining dependencies\n",stderr); + fprintf(stderr," per unsolved instance == %f.\n", + ((float)(cycleSum)/(float)(nNZrc)) + ); +#endif + fprintf(stderr, + "searching parse tree for %ld unsolved instances:\n", + nNZrc + ); + yyyUnsolvedInstSearchTravAux(rootNode); + } + yyyDoTraversals(rootNode); +} /* yyyExecuteRRsection */ + + + +yyyWAT yyyLRCIL[2] = {0,0, +}; + + + +void yyyYoxInit(void) + { + static int yyyInitDone = 0; + if (yyyInitDone) return; + + if ((yyyRS = (yyyRSitem *) + calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(yyyRSitem)) + ) + == + ((yyyRSitem *) NULL) + ) + yyyfatal("malloc error in ox ready set space allocation\n"); + yyyRS++; + yyyAfterRS = yyyRS + yyyRSmaxSize; + + + if ((yyySSALspace = (struct yyySolvedSAlistCell *) + calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) + ) + == + ((struct yyySolvedSAlistCell *) NULL) + ) + yyyfatal("malloc error in stack solved list space allocation\n"); + yyyInitDone = 1; + + yyyRSTop = yyyRS - 1; + } /* yyyYoxInit */ + + + +void yyyDecorate(void) + { + while (yyyRSTop >= yyyRS) + yyySolveAndSignal(); + } + + + +void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) + {yyyWST i; + yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; + yyyGNT *gnpDum; + va_list ap; + + *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); + if (*yyyOxStackItem == (yyySIT *) NULL) + yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); + (*yyyOxStackItem)->node = + (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); + if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) + yyyfatal("malloc error in ox node space allocation\n"); + (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; + (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; + (*yyyOxStackItem)->node->parentIsStack = 1; + (*yyyOxStackItem)->node->cLlen = yyyRHSlength; + (*yyyOxStackItem)->node->cL = + (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); + if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) + yyyfatal("malloc error in ox child list space allocation\n"); + (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; + (*yyyOxStackItem)->node->refCountList = + (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); + if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) + yyyfatal("malloc error in ox reference count list space allocation\n"); + (*yyyOxStackItem)->node->prodNum = (int) yyyProdNum; + va_start(ap, yyval_OxAttrbs); + for (i=1;i<=yyyRHSlength;i++) + {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; + gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; + gnpDum->whichSym = i; + gnpDum->parent.noderef = (*yyyOxStackItem)->node; + gnpDum->parentIsStack = 0; + } + va_end(ap); + } + + + +#define yyyDECORfREQ 50 + + + +void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) + {yyyWST i; + yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; + long SSALptr,SSALptrHead,*cPtrPtr; + long *pL; + yyyGNT *gnpDum; + long iTemp; + long nextP; + static unsigned short intNodeCount = yyyDECORfREQ; + va_list ap; + + nextP = startP; + while (nextP < stopP) + {if (yyyRCIL[nextP] == yyyR) + {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; + } + else + {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; + } + nextP += 3; + } + pL = yyyIIEL + yyyIIIEL[yyyProdNum]; + va_start(ap, yyval_OxAttrbs); + for (i=1;i<=yyyRHSlength;i++) + {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; + pL++; + SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); + if (SSALptr != yyyLambdaSSAL) + {*cPtrPtr = yyyLambdaSSAL; + do + { + iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); + yyySignalEnts(yyyOxStackItem->node, + yyyIEL[iTemp], + yyyIEL[iTemp+1] + ); + SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); + } + while (SSALptr != yyyLambdaSSAL); + *cPtrPtr = yyySSALCfreeList; + yyySSALCfreeList = SSALptrHead; + } + } + va_end(ap); + nextP = startP + 2; + while (nextP < stopP) + {if (!yyyRCIL[nextP]) + {if (yyyRCIL[nextP-2] == yyyR) + {pL = &(yyyOxStackItem->solvedSAlist); + if (yyySSALCfreeList == yyyLambdaSSAL) + {yyySSALspace[yyyNewSSALC].next = *pL; + if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) + yyyHandleOverflow(yyySSALof); + } + else + {iTemp = yyySSALCfreeList; + yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; + yyySSALspace[iTemp].next = *pL; + *pL = iTemp; + } + yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; + } + else + {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) + { + iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; + yyySignalEnts(gnpDum, + yyyIEL[iTemp], + yyyIEL[iTemp+1] + ); + } + } + } + nextP += 3; + } + if (!--intNodeCount) + {intNodeCount = yyyDECORfREQ; + yyyDecorate(); + } + } + + + +void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *mylval) + {yyyRCT *rcPdum; + yyySIT **yyyOxStackItem = &mylval->yyyOxAttrbs.yyyOxStackItem; + (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); + if ((*yyyOxStackItem) == (yyySIT *) NULL) + yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); + (*yyyOxStackItem)->node = + (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) + ; + if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) + yyyfatal("malloc error in ox node space allocation\n"); + (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; + (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; + (*yyyOxStackItem)->node->parentIsStack = 1; + (*yyyOxStackItem)->node->cLlen = 0; + (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; + (*yyyOxStackItem)->node->refCountListLen = nAttrbs; + rcPdum = (*yyyOxStackItem)->node->refCountList = + (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); + if (rcPdum == (yyyRCT *) NULL) + yyyfatal("malloc error in ox reference count list space allocation\n"); + while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; + (*yyyOxStackItem)->node->prodNum = 0; + (*yyyOxStackItem)->node->whichSym = 0; + } + + + +void yyyabort(void) + {yyyYok = 0; + } + + + + + +#define yyyLastProdNum 8 + + +#define yyyNsorts 1 + + +int yyyProdsInd[] = { + 0, + 0, 2, 6, 10, 14, 18, 22, 24, + 26, +}; + + +int yyyProds[][2] = { +{ 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, +{ 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, +{ 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, +{ 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, +{ 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, +{ 567, 1}, +}; + + +int yyySortsInd[] = { + 0, + 0, + 1, +}; + + +int yyySorts[] = { + 413, +}; + + + +char *yyyStringTab[] = { +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"s",0,0,0, +0,0,"y",0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"LRpre",0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"'('",0,0,0, +0,0,0,0,"')'", +0,0,0,0,0, +0,0,"'*'","lexeme",0, +0,0,0,0,0, +"'+'",0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"'-'",0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,"'/'",0,0, +0,0,0,0,0, +0,0,"expr",0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"printf",0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,"CONST","LRpost",0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,"ID", +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0, +}; + + + +#define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) + +#define yyyGSoccurStr(prodNum,symPos) \ + (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) + +#define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) + +#define yyySortOf(prodNum,symPos) \ + (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) + +#define yyyAttrbStr(prodNum,symPos,attrbNum) \ + (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ + (attrbNum) \ + ] \ + ] \ + ) + + + +void yyyShowProd(int i) + {int j,nSyms; + + nSyms = yyySizeofProd(i); + for (j=0; j\n",stderr); + else + putc('\n',stderr); + } + } + } + + + +void yyyCheckNodeInstancesSolved(yyyGNT *np) + {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; + int nUnsolvedInsts = 0; + + if (np->prodNum != 0) + {inTerminalNode = 0; + prodNum = np->prodNum; + symPos = 0; + } + else + {inTerminalNode = 1; + prodNum = np->parent.noderef->prodNum; + symPos = np->whichSym; + } + mysort = yyySortOf(prodNum,symPos); + sortSize = yyySizeofSort(mysort); + for (i=0; irefCountList)[i] != 0) nUnsolvedInsts += 1; + if (nUnsolvedInsts) + {fprintf(stderr, + "\nFound node that has %d unsolved attribute instance(s).\n", + nUnsolvedInsts + ); + fprintf(stderr,"Node is labeled \"%s\".\n", + yyyGSoccurStr(prodNum,symPos)); + if (inTerminalNode) + {fputs("Node is terminal. Its parent production is:\n ",stderr); + yyyShowProd(prodNum); + } + else + {fputs("Node is nonterminal. ",stderr); + if (!(np->parentIsStack)) + {fprintf(stderr, + "Node is %dth child in its parent production:\n ", + np->whichSym + ); + yyyShowProd(np->parent.noderef->prodNum); + } + fputs("Node is on left hand side of this production:\n ",stderr); + yyyShowProd(np->prodNum); + } + fputs("The following instances are unsolved:\n",stderr); + for (i=0; irefCountList)[i] != 0) + fprintf(stderr," %-16s still has %1d dependencies.\n", + yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); + } + } + + + +void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) + {yyyGNT **yyyCLpdum; + yyyRCT *rcp; + int i; + + /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ + rcp = pNode->refCountList; + i = pNode->refCountListLen; + while (i--) + if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} + yyyCLpdum = pNode->cL; + i = pNode->cLlen; + while (i--) + { + yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); + yyyCLpdum++; + } + } + + + +void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) + {yyyGNT **yyyCLpdum; + int i; + + yyyCheckNodeInstancesSolved(pNode); + yyyCLpdum = pNode->cL; + i = pNode->cLlen; + while (i--) + { + yyyUnsolvedInstSearchTravAux(*yyyCLpdum); + yyyCLpdum++; + } + } + + + +void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) + {yyyGNT **yyyCLpdum; + int i; + + yyyCLpdum = pNode->cL; + i = pNode->cLlen; + while (i--) + { + yyyUnsolvedInstSearchTravAux(*yyyCLpdum); + yyyCLpdum++; + } + } + + + diff --git a/test/grammar.y b/test/grammar.y new file mode 100644 index 00000000000..c4c8fd58093 --- /dev/null +++ b/test/grammar.y @@ -0,0 +1,1184 @@ +/* $Id: grammar.y,v 1.7 2020/03/30 23:55:49 tom Exp $ + * + * yacc grammar for C function prototype generator + * This was derived from the grammar in Appendix A of + * "The C Programming Language" by Kernighan and Ritchie. + */ +%expect 1 +%{ +#ifdef YYBISON +#include +#define YYSTYPE_IS_DECLARED +#define yyerror yaccError +#endif + +#if defined(YYBISON) || !defined(YYBYACC) +static void yyerror(const char *s); +#endif +%} + +%token '(' '*' '&' + /* identifiers that are not reserved words */ + T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME + + /* storage class */ + T_AUTO T_EXTERN T_REGISTER T_STATIC T_TYPEDEF + /* This keyword included for compatibility with C++. */ + T_INLINE + /* This keyword included for compatibility with GCC */ + T_EXTENSION + + /* type specifiers */ + T_CHAR T_DOUBLE T_FLOAT T_INT T_VOID + T_LONG T_SHORT T_SIGNED T_UNSIGNED + T_ENUM T_STRUCT T_UNION + /* C9X new types */ + T_Bool T_Complex T_Imaginary + + /* type qualifiers */ + T_TYPE_QUALIFIER + + /* paired square brackets and everything between them: [ ... ] */ + T_BRACKETS + +%token + /* left brace */ + T_LBRACE + /* all input to the matching right brace */ + T_MATCHRBRACE + + /* three periods */ + T_ELLIPSIS + + /* constant expression or paired braces following an equal sign */ + T_INITIALIZER + + /* string literal */ + T_STRING_LITERAL + + /* asm */ + T_ASM + /* ( "string literal" ) following asm keyword */ + T_ASMARG + + /* va_dcl from */ + T_VA_DCL + +%type decl_specifiers decl_specifier +%type storage_class type_specifier type_qualifier +%type struct_or_union_specifier enum_specifier +%type init_declarator_list +%type init_declarator declarator direct_declarator +%type abs_declarator direct_abs_declarator +%type parameter_type_list parameter_list +%type parameter_declaration +%type opt_identifier_list identifier_list +%type struct_or_union pointer opt_type_qualifiers type_qualifier_list + any_id identifier_or_ref +%type enumeration + +%{ +#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 +#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3) + +/* 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; +} +%} +%% + +program + : /* empty */ + | translation_unit + ; + +translation_unit + : external_declaration + | translation_unit external_declaration + ; + +external_declaration + : declaration + | function_definition + | ';' + | linkage_specification + | T_ASM T_ASMARG ';' + | error T_MATCHRBRACE + { + yyerrok; + } + | error ';' + { + yyerrok; + } + ; + +braces + : T_LBRACE T_MATCHRBRACE + ; + +linkage_specification + : T_EXTERN T_STRING_LITERAL braces + { + /* Provide an empty action here so bison will not complain about + * incompatible types in the default action it normally would + * have generated. + */ + } + | T_EXTERN T_STRING_LITERAL declaration + { + /* empty */ + } + ; + +declaration + : decl_specifiers ';' + { +#if OPT_LINTLIBRARY + if (types_out && want_typedef()) { + gen_declarations(&$1, (DeclaratorList *)0); + flush_varargs(); + } +#endif + free_decl_spec(&$1); + end_typedef(); + } + | decl_specifiers init_declarator_list ';' + { + if (func_params != NULL) { + set_param_types(func_params, &$1, &$2); + } else { + gen_declarations(&$1, &$2); +#if OPT_LINTLIBRARY + flush_varargs(); +#endif + free_decl_list(&$2); + } + free_decl_spec(&$1); + end_typedef(); + } + | any_typedef decl_specifiers + { + cur_decl_spec_flags = $2.flags; + free_decl_spec(&$2); + } + opt_declarator_list ';' + { + end_typedef(); + } + ; + +any_typedef + : T_EXTENSION T_TYPEDEF + { + begin_typedef(); + } + | T_TYPEDEF + { + begin_typedef(); + } + ; + +opt_declarator_list + : /* empty */ + | declarator_list + ; + +declarator_list + : declarator + { + 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($1->text, $1->name) != 0) + flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT); + new_symbol(typedef_names, $1->name, NULL, flags); + free_declarator($1); + } + | declarator_list ',' declarator + { + int flags = cur_decl_spec_flags; + + if (strcmp($3->text, $3->name) != 0) + flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT); + new_symbol(typedef_names, $3->name, NULL, flags); + free_declarator($3); + } + ; + +function_definition + : decl_specifiers declarator + { + check_untagged(&$1); + if ($2->func_def == FUNC_NONE) { + yyerror("syntax error"); + YYERROR; + } + func_params = &($2->head->params); + func_params->begin_comment = cur_file->begin_comment; + func_params->end_comment = cur_file->end_comment; + } + opt_declaration_list T_LBRACE + { + /* 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() + && $2->head->func_def == func_style) { + $2->head->func_def = FUNC_BOTH; + } + + func_params = NULL; + + if (cur_file->convert) + gen_func_definition(&$1, $2); + gen_prototype(&$1, $2); +#if OPT_LINTLIBRARY + flush_varargs(); +#endif + free_decl_spec(&$1); + free_declarator($2); + } + T_MATCHRBRACE + | declarator + { + if ($1->func_def == FUNC_NONE) { + yyerror("syntax error"); + YYERROR; + } + func_params = &($1->head->params); + func_params->begin_comment = cur_file->begin_comment; + func_params->end_comment = cur_file->end_comment; + } + opt_declaration_list T_LBRACE T_MATCHRBRACE + { + DeclSpec decl_spec; + + func_params = NULL; + + new_decl_spec(&decl_spec, dft_decl_spec(), $1->begin, DS_NONE); + if (cur_file->convert) + gen_func_definition(&decl_spec, $1); + gen_prototype(&decl_spec, $1); +#if OPT_LINTLIBRARY + flush_varargs(); +#endif + free_decl_spec(&decl_spec); + free_declarator($1); + } + ; + +opt_declaration_list + : /* empty */ + | T_VA_DCL + | declaration_list + ; + +declaration_list + : declaration + | declaration_list declaration + ; + +decl_specifiers + : decl_specifier + | decl_specifiers decl_specifier + { + join_decl_specs(&$$, &$1, &$2); + free($1.text); + free($2.text); + } + ; + +decl_specifier + : storage_class + | type_specifier + | type_qualifier + ; + +storage_class + : T_AUTO + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_EXTERN + { + new_decl_spec(&$$, $1.text, $1.begin, DS_EXTERN); + } + | T_REGISTER + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_STATIC + { + new_decl_spec(&$$, $1.text, $1.begin, DS_STATIC); + } + | T_INLINE + { + new_decl_spec(&$$, $1.text, $1.begin, DS_INLINE); + } + | T_EXTENSION + { + new_decl_spec(&$$, $1.text, $1.begin, DS_JUNK); + } + ; + +type_specifier + : T_CHAR + { + new_decl_spec(&$$, $1.text, $1.begin, DS_CHAR); + } + | T_DOUBLE + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_FLOAT + { + new_decl_spec(&$$, $1.text, $1.begin, DS_FLOAT); + } + | T_INT + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_LONG + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_SHORT + { + new_decl_spec(&$$, $1.text, $1.begin, DS_SHORT); + } + | T_SIGNED + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_UNSIGNED + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_VOID + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_Bool + { + new_decl_spec(&$$, $1.text, $1.begin, DS_CHAR); + } + | T_Complex + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_Imaginary + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_TYPEDEF_NAME + { + Symbol *s; + s = find_symbol(typedef_names, $1.text); + if (s != NULL) + new_decl_spec(&$$, $1.text, $1.begin, s->flags); + } + | struct_or_union_specifier + | enum_specifier + ; + +type_qualifier + : T_TYPE_QUALIFIER + { + new_decl_spec(&$$, $1.text, $1.begin, DS_NONE); + } + | T_DEFINE_NAME + { + /* This rule allows the nonterminal to scan #define + * names as if they were type modifiers. + */ + Symbol *s; + s = find_symbol(define_names, $1.text); + if (s != NULL) + new_decl_spec(&$$, $1.text, $1.begin, s->flags); + } + ; + +struct_or_union_specifier + : struct_or_union any_id braces + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, $1.text, TEXT_LEN, $2.text); + new_decl_spec(&$$, s, $1.begin, DS_NONE); + } + | struct_or_union braces + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, $1.text); + new_decl_spec(&$$, s, $1.begin, DS_NONE); + } + | struct_or_union any_id + { + (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, $1.text, TEXT_LEN, $2.text); + new_decl_spec(&$$, buf, $1.begin, DS_NONE); + } + ; + +struct_or_union + : T_STRUCT + { + imply_typedef($$.text); + } + | T_UNION + { + imply_typedef($$.text); + } + ; + +init_declarator_list + : init_declarator + { + new_decl_list(&$$, $1); + } + | init_declarator_list ',' init_declarator + { + add_decl_list(&$$, &$1, $3); + } + ; + +init_declarator + : declarator + { + if ($1->func_def != FUNC_NONE && func_params == NULL && + func_style == FUNC_TRADITIONAL && cur_file->convert) { + gen_func_declarator($1); + fputs(cur_text(), cur_file->tmp_file); + } + cur_declarator = $$; + } + | declarator '=' + { + if ($1->func_def != FUNC_NONE && func_params == NULL && + func_style == FUNC_TRADITIONAL && cur_file->convert) { + gen_func_declarator($1); + fputs(" =", cur_file->tmp_file); + } + } + T_INITIALIZER + ; + +enum_specifier + : enumeration any_id braces + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, $2.text); + new_decl_spec(&$$, s, $1.begin, DS_NONE); + } + | enumeration braces + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, $1.text); + new_decl_spec(&$$, s, $1.begin, DS_NONE); + } + | enumeration any_id + { + (void)sprintf(buf, "enum %.*s", TEXT_LEN, $2.text); + new_decl_spec(&$$, buf, $1.begin, DS_NONE); + } + ; + +enumeration + : T_ENUM + { + imply_typedef("enum"); + $$ = $1; + } + ; + +any_id + : T_IDENTIFIER + | T_TYPEDEF_NAME + ; + +declarator + : pointer direct_declarator + { + $$ = $2; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $1.text, TEXT_LEN, $$->text); + free($$->text); + $$->text = xstrdup(buf); + $$->begin = $1.begin; + $$->pointer = TRUE; + } + | direct_declarator + ; + +direct_declarator + : identifier_or_ref + { + $$ = new_declarator($1.text, $1.text, $1.begin); + } + | '(' declarator ')' + { + $$ = $2; + (void)sprintf(buf, "(%.*s)", TEXT_LEN, $$->text); + free($$->text); + $$->text = xstrdup(buf); + $$->begin = $1.begin; + } + | direct_declarator T_BRACKETS + { + $$ = $1; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $$->text, TEXT_LEN, $2.text); + free($$->text); + $$->text = xstrdup(buf); + } + | direct_declarator '(' parameter_type_list ')' + { + $$ = new_declarator("%s()", $1->name, $1->begin); + $$->params = $3; + $$->func_stack = $1; + $$->head = ($1->func_stack == NULL) ? $$ : $1->head; + $$->func_def = FUNC_ANSI; + } + | direct_declarator '(' opt_identifier_list ')' + { + $$ = new_declarator("%s()", $1->name, $1->begin); + $$->params = $3; + $$->func_stack = $1; + $$->head = ($1->func_stack == NULL) ? $$ : $1->head; + $$->func_def = FUNC_TRADITIONAL; + } + ; + +pointer + : '*' opt_type_qualifiers + { + (void)sprintf($$.text, "*%.*s", TEXT_LEN, $2.text); + $$.begin = $1.begin; + } + | '*' opt_type_qualifiers pointer + { + (void)sprintf($$.text, "*%.*s%.*s", TEXT_LEN, $2.text, TEXT_LEN, $3.text); + $$.begin = $1.begin; + } + ; + +opt_type_qualifiers + : /* empty */ + { + strcpy($$.text, ""); + $$.begin = 0L; + } + | type_qualifier_list + ; + +type_qualifier_list + : type_qualifier + { + (void)sprintf($$.text, "%s ", $1.text); + $$.begin = $1.begin; + free($1.text); + } + | type_qualifier_list type_qualifier + { + (void)sprintf($$.text, "%.*s%.*s ", TEXT_LEN, $1.text, TEXT_LEN, $2.text); + $$.begin = $1.begin; + free($2.text); + } + ; + +parameter_type_list + : parameter_list + | parameter_list ',' T_ELLIPSIS + { + add_ident_list(&$$, &$1, "..."); + } + ; + +parameter_list + : parameter_declaration + { + new_param_list(&$$, $1); + } + | parameter_list ',' parameter_declaration + { + add_param_list(&$$, &$1, $3); + } + ; + +parameter_declaration + : decl_specifiers declarator + { + check_untagged(&$1); + $$ = new_parameter(&$1, $2); + } + | decl_specifiers abs_declarator + { + check_untagged(&$1); + $$ = new_parameter(&$1, $2); + } + | decl_specifiers + { + check_untagged(&$1); + $$ = new_parameter(&$1, (Declarator *)0); + } + ; + +opt_identifier_list + : /* empty */ + { + new_ident_list(&$$); + } + | identifier_list + ; + +identifier_list + : any_id + { + new_ident_list(&$$); + add_ident_list(&$$, &$$, $1.text); + } + | identifier_list ',' any_id + { + add_ident_list(&$$, &$1, $3.text); + } + ; + +identifier_or_ref + : any_id + { + $$ = $1; + } + | '&' any_id + { +#if OPT_LINTLIBRARY + if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */ + $$ = $2; + } else +#endif + (void)sprintf($$.text, "&%.*s", TEXT_LEN, $2.text); + $$.begin = $1.begin; + } + ; + +abs_declarator + : pointer + { + $$ = new_declarator($1.text, "", $1.begin); + } + | pointer direct_abs_declarator + { + $$ = $2; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $1.text, TEXT_LEN, $$->text); + free($$->text); + $$->text = xstrdup(buf); + $$->begin = $1.begin; + } + | direct_abs_declarator + ; + +direct_abs_declarator + : '(' abs_declarator ')' + { + $$ = $2; + (void)sprintf(buf, "(%.*s)", TEXT_LEN, $$->text); + free($$->text); + $$->text = xstrdup(buf); + $$->begin = $1.begin; + } + | direct_abs_declarator T_BRACKETS + { + $$ = $1; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $$->text, TEXT_LEN, $2.text); + free($$->text); + $$->text = xstrdup(buf); + } + | T_BRACKETS + { + $$ = new_declarator($1.text, "", $1.begin); + } + | direct_abs_declarator '(' parameter_type_list ')' + { + $$ = new_declarator("%s()", "", $1->begin); + $$->params = $3; + $$->func_stack = $1; + $$->head = ($1->func_stack == NULL) ? $$ : $1->head; + $$->func_def = FUNC_ANSI; + } + | direct_abs_declarator '(' ')' + { + $$ = new_declarator("%s()", "", $1->begin); + $$->func_stack = $1; + $$->head = ($1->func_stack == NULL) ? $$ : $1->head; + $$->func_def = FUNC_ANSI; + } + | '(' parameter_type_list ')' + { + Declarator *d; + + d = new_declarator("", "", $1.begin); + $$ = new_declarator("%s()", "", $1.begin); + $$->params = $2; + $$->func_stack = d; + $$->head = $$; + $$->func_def = FUNC_ANSI; + } + | '(' ')' + { + Declarator *d; + + d = new_declarator("", "", $1.begin); + $$ = new_declarator("%s()", "", $1.begin); + $$->func_stack = d; + $$->head = $$; + $$->func_def = FUNC_ANSI; + } + ; + +%% + +/* 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 occurrences 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 diff --git a/test/inherit0.y b/test/inherit0.y new file mode 100644 index 00000000000..3a90e45c867 --- /dev/null +++ b/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/test/inherit1.y b/test/inherit1.y new file mode 100644 index 00000000000..9c7e876f056 --- /dev/null +++ b/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/test/inherit2.y b/test/inherit2.y new file mode 100644 index 00000000000..e297d08cd85 --- /dev/null +++ b/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/test/ok_syntax1.y b/test/ok_syntax1.y new file mode 100644 index 00000000000..455a55aeb70 --- /dev/null +++ b/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 CalcData +{ + 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/test/pure_calc.y b/test/pure_calc.y new file mode 100644 index 00000000000..3cd04332dcd --- /dev/null +++ b/test/pure_calc.y @@ -0,0 +1,116 @@ +%{ +# 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 + +%} + +%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 +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 ); +} diff --git a/test/pure_error.y b/test/pure_error.y new file mode 100644 index 00000000000..fe7a3c3094f --- /dev/null +++ b/test/pure_error.y @@ -0,0 +1,41 @@ +%{ + +#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 + +%} + +%% +S: error +%% + +#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); +} diff --git a/test/quote_calc.y b/test/quote_calc.y new file mode 100644 index 00000000000..9304dd8a700 --- /dev/null +++ b/test/quote_calc.y @@ -0,0 +1,112 @@ +%{ +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token OP_ADD "ADD" +%token OP_SUB "SUB" +%token OP_MUL "MUL" +%token OP_DIV "DIV" +%token OP_MOD "MOD" +%token OP_AND "AND" + +%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 OP_ADD expr + { $$ = $1 + $3; } + | expr OP_SUB expr + { $$ = $1 - $3; } + | expr OP_MUL expr + { $$ = $1 * $3; } + | expr OP_DIV expr + { $$ = $1 / $3; } + | expr OP_MOD expr + { $$ = $1 % $3; } + | expr OP_AND expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | OP_SUB expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) { + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/quote_calc2.y b/test/quote_calc2.y new file mode 100644 index 00000000000..ab72a285fcb --- /dev/null +++ b/test/quote_calc2.y @@ -0,0 +1,112 @@ +%{ +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token OP_ADD "ADD" +%token OP_SUB "SUB" +%token OP_MUL "MUL" +%token OP_DIV "DIV" +%token OP_MOD "MOD" +%token OP_AND "AND" + +%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 "ADD" expr + { $$ = $1 + $3; } + | expr "SUB" expr + { $$ = $1 - $3; } + | expr "MUL" expr + { $$ = $1 * $3; } + | expr "DIV" expr + { $$ = $1 / $3; } + | expr "MOD" expr + { $$ = $1 % $3; } + | expr "AND" expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | "SUB" expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) { + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/quote_calc3.y b/test/quote_calc3.y new file mode 100644 index 00000000000..5feeb4a03ed --- /dev/null +++ b/test/quote_calc3.y @@ -0,0 +1,112 @@ +%{ +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token OP_ADD "ADD-operator" +%token OP_SUB "SUB-operator" +%token OP_MUL "MUL-operator" +%token OP_DIV "DIV-operator" +%token OP_MOD "MOD-operator" +%token OP_AND "AND-operator" + +%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 OP_ADD expr + { $$ = $1 + $3; } + | expr OP_SUB expr + { $$ = $1 - $3; } + | expr OP_MUL expr + { $$ = $1 * $3; } + | expr OP_DIV expr + { $$ = $1 / $3; } + | expr OP_MOD expr + { $$ = $1 % $3; } + | expr OP_AND expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | OP_SUB expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) { + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/quote_calc4.y b/test/quote_calc4.y new file mode 100644 index 00000000000..34b790e67f1 --- /dev/null +++ b/test/quote_calc4.y @@ -0,0 +1,112 @@ +%{ +# include +# include + +int regs[26]; +int base; + +int yylex(void); +static void yyerror(const char *s); + +%} + +%start list + +%token OP_ADD "ADD-operator" +%token OP_SUB "SUB-operator" +%token OP_MUL "MUL-operator" +%token OP_DIV "DIV-operator" +%token OP_MOD "MOD-operator" +%token OP_AND "AND-operator" + +%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 "ADD-operator" expr + { $$ = $1 + $3; } + | expr "SUB-operator" expr + { $$ = $1 - $3; } + | expr "MUL-operator" expr + { $$ = $1 * $3; } + | expr "DIV-operator" expr + { $$ = $1 / $3; } + | expr "MOD-operator" expr + { $$ = $1 % $3; } + | expr "AND-operator" expr + { $$ = $1 & $3; } + | expr '|' expr + { $$ = $1 | $3; } + | "SUB-operator" expr %prec UMINUS + { $$ = - $2; } + | LETTER + { $$ = regs[$1]; } + | number + ; + +number: DIGIT + { $$ = $1; base = ($1==0) ? 8 : 10; } + | number DIGIT + { $$ = base * $1 + $2; } + ; + +%% /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) { + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} diff --git a/test/run_lint.sh b/test/run_lint.sh new file mode 100755 index 00000000000..c6cedc23a01 --- /dev/null +++ b/test/run_lint.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# $Id: run_lint.sh,v 1.5 2022/11/06 20:56:42 tom Exp $ +# vi:ts=4 sw=4: + +# run lint on each of the ".c" files in the test directory + +if test $# = 1 +then + PROG_DIR=`pwd` + TEST_DIR=$1 +else + PROG_DIR=.. + TEST_DIR=. +fi + +: "${FGREP:=grep -F}" +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 ${REF_DIR}/*.c +do + make -f $PROG_DIR/makefile lint C_FILES="$i" srcdir="$PROG_DIR" +done diff --git a/test/run_make.sh b/test/run_make.sh new file mode 100755 index 00000000000..a09e6034b31 --- /dev/null +++ b/test/run_make.sh @@ -0,0 +1,196 @@ +#!/bin/sh +# $Id: run_make.sh,v 1.21 2022/11/06 20:57:33 tom Exp $ +# vi:ts=4 sw=4: + +# do a test-compile on each of the ".c" files in the test-directory + +BISON=`bison --version 2>/dev/null | head -n 1 | sed -e 's/^[^0-9.]*//' -e 's/[^0-9.]*$//'` + +if test $# = 1 +then + PROG_DIR=`pwd` + TEST_DIR=$1 +else + PROG_DIR=.. + TEST_DIR=. +fi +THIS_DIR=`pwd` + +: "${FGREP:=grep -F}" +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 + RETEST=`unset CDPATH; cd $TEST_DIR; pwd` + cd "$REF_DIR" + test -f "$I_FILE" && rm "$I_FILE" + make -f "$PROG_DIR/makefile" EXTRA_CFLAGS=-I$RETEST srcdir="$PROG_DIR" "$O_FILE" "$@" + test -f "$O_FILE" && rm "$O_FILE" + cd "$THIS_DIR" +} + +echo "** `date`" +echo "** program is in $PROG_DIR" +echo "** test-files in $REF_DIR" + +for input in ${REF_DIR}/*.c +do + case $input in #(vi + ${REF_DIR}/err_*|\ + ${REF_DIR}/test-err_*) + continue + ;; + esac + + test -f "$input" || continue + + run_make "$input" + + DEFS= + case $input in #(vi + ${REF_DIR}/pure_*) + # DEFS="-DYYLEX_PARAM=flag -DYYLEX_PARAM_TYPE=int" + ;; + esac + + if test "x$DEFS" != "x" + then + run_make "$input" DEFINES="$DEFS" + fi +done + +if test -n "$BISON" +then + echo "** compare with bison $BISON" + for input in ${TEST_DIR}/*.y + do + test -f "$input" || continue + case $input in + ${TEST_DIR}/err_*|\ + ${TEST_DIR}/test-err_*) + continue + ;; + ${TEST_DIR}/ok_syntax*|\ + ${TEST_DIR}/varsyntax*) + # Bison does not support all byacc legacy syntax + continue + ;; + ${TEST_DIR}/btyacc_*) + # Bison does not support the btyacc []-action & inherited attribute extensions. + continue + ;; + esac + + # Bison does not support pure-parser from command-line. + # Also, its support for %expect is generally broken. + # Work around these issues using a temporary file. + + echo "... testing $input" + rm -f run_make.[coy] + + case $input in + ${TEST_DIR}/pure_*) + if test -z "`$FGREP -i -l '%pure-parser' "$input"`" + then + echo "%pure-parser" >>run_make.y + fi + ;; + esac + + sed -e '/^%expect/s,%expect.*,,' "$input" >>run_make.y + + case $BISON in + [3-9].[0-9]*.[0-9]*) + bison -Wno-other -Wno-conflicts-sr -Wconflicts-rr -y -Wno-yacc run_make.y + ;; + *) + bison -y run_make.y + ;; + esac + if test -f "y.tab.c" + then + sed -e '/^#line/s,"run_make.y","'"$input"'",' y.tab.c >run_make.c + + 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" + fi + fi + rm -f run_make.[coy] + done +fi + +YACC= +for name in /usr/ccs/bin/yacc +do + if test -f $name + then + YACC=$name + fi +done + +if test -n "$YACC" +then + echo "** compare with $YACC" + for input in ${TEST_DIR}/*.y + do + test -f "$input" || continue + + echo "... testing $input" + rm -f run_make.[coy] + + case $input in + pure_*) + echo "... skipping $input" + continue; + ;; + *) + if $FGREP -i '%pure-parser' "$input" >/dev/null || + $FGREP -i '%parse-param' "$input" >/dev/null || + $FGREP -i '%lex-param' "$input" >/dev/null || + $FGREP -i '%token-table' "$input" >/dev/null || + $FGREP 'YYLEX_PARAM' "$input" >/dev/null + then + echo "... skipping $input" + continue; + fi + ;; + esac + + sed -e '/^%expect/s,%expect.*,,' "$input" >>run_make.y + + $YACC run_make.y + 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 + + 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 +fi diff --git a/test/run_test.sh b/test/run_test.sh new file mode 100755 index 00000000000..def26e3c6b7 --- /dev/null +++ b/test/run_test.sh @@ -0,0 +1,311 @@ +#!/bin/sh +# $Id: run_test.sh,v 1.37 2022/11/06 21:55:25 tom Exp $ +# vi:ts=4 sw=4: + +errors=0 + +# 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" + errors=1 + else + sed -e "s,$NEW,$REF," \ + -e "s%$YACC_escaped%YACC%" \ + -e "s%^yacc\>%YACC%" \ + -e "s%YACC:.*option.*$%YACC: error message%" \ + -e "s%yacc:.*option.*$%YACC: error message%" \ + -e "s%^Usage: yacc\>%Usage: YACC%" \ + -e '/YYPATCH/s/[0-9][0-9]*/"yyyymmdd"/' \ + -e '/#define YYPATCH/s/PATCH/CHECK/' \ + -e 's,#line \([1-9][0-9]*\) "'"$REF_DIR"'/,#line \1 ",' \ + -e 's,#line \([1-9][0-9]*\) "'"$TEST_DIR"'/,#line \1 ",' \ + -e 's/^typedef \(short\|long\) YYINT;$/typedef int YYINT;/' \ + -e 's,\(YACC:.* line [0-9][0-9]* of "\)'"$TEST_DIR/"',\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 -c "$REF" "$CMP" + errors=1 + fi + fi +} + +test_flags() { + echo "** testing flags $*" + root=$1 + ROOT=test-$root + shift 1 + $YACC "$@" >"$ROOT.output" 2>"$ROOT.error" + for type in .output .error + do + NEW=$ROOT$type + REF=$REF_DIR/$root$type + test_diffs + done +} + +test_stdin() { + echo "** testing stdin $*" + root=$1 + ROOT=test-$root + shift 1 + opts="$1" + shift 1 + code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"` + if test "x$opts" = "x-" + then + $YACC -o "$ROOT.$code" $opts <$1 >"$ROOT.output" 2>"$ROOT.error" + else + $YACC -o "$ROOT.$code" $opts $1 >"$ROOT.output" 2>"$ROOT.error" + fi + for type in .output .error .$code + do + NEW=$ROOT$type + REF=$REF_DIR/$root$type + test_diffs + done +} + +test_defines() { + echo "** testing defines $*" + root=$1 + ROOT=test-$root + shift 1 + opts= + while test $# != 1 + do + opts="$opts $1" + shift 1 + done + head=`echo "$1"|sed -e 's/y$/h/' -e "s,${TEST_DIR}/,,"` + code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"` + $YACC $opts -H "$ROOT.$head" $1 >"$ROOT.output" 2>"$ROOT.error" + for name in prefix.tab.c y.tab.c + do + if test -f $name + then + mv "$name" "$ROOT.$code" + break + fi + done + for name in .output .error .$head .$code + do + NEW=$ROOT$name + REF=$REF_DIR/$root$name + test_diffs + done +} + +if test $# = 1 +then + PROG_DIR=`pwd` + 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=. +fi + +YACC=$PROG_DIR/yacc +YACC_escaped=`echo "$PROG_DIR/yacc" | sed -e 's/\./\\\./g'` + +tmpfile=temp$$ + +: "${FGREP:=grep -F}" +ifBTYACC=`$FGREP -l 'define YYBTYACC' $PROG_DIR/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.* + +# Test special cases +test_stdin stdin1 - ${TEST_DIR}/calc.y +test_stdin stdin2 -- ${TEST_DIR}/calc.y + +test_defines defines1 ${TEST_DIR}/calc.y +test_defines defines2 -d ${TEST_DIR}/calc.y +test_defines defines3 -b prefix ${TEST_DIR}/calc.y + +for input in "${TEST_DIR}"/*.y +do + case $input in + test-*) + echo "?? ignored $input" + ;; + *) + root=`basename "$input" .y` + ROOT="test-$root" + prefix=`echo "${root}_" | sed -e 's/[.]/_/g'` + + OPTS= + OPT2= + 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" + prefix=`echo "$prefix" | sed -e 's/^code_//'` + ;; + ${TEST_DIR}/pure_*) + OPTS="$OPTS -P" + prefix=`echo "$prefix" | sed -e 's/^pure_//'` + ;; + ${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 + 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=${REF_DIR}/${root}${opt2}${type} + + # handle renaming due to "-o" option + if test -n "$OOPT" + then + 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 + NEW="${ROOT}${opt2}${type}" + fi + test_diffs + done + done + ;; + esac +done + +exit $errors diff --git a/test/varsyntax_calc1.y b/test/varsyntax_calc1.y new file mode 100644 index 00000000000..c9917e0b49f --- /dev/null +++ b/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/test/yacc/big_b.error b/test/yacc/big_b.error new file mode 100644 index 00000000000..6c3442bef99 --- /dev/null +++ b/test/yacc/big_b.error @@ -0,0 +1,31 @@ +YACC: w - -B flag unsupported, reconfigure with --enable-btyacc +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/yacc/big_b.output b/test/yacc/big_b.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/big_l.error b/test/yacc/big_l.error new file mode 100644 index 00000000000..8ca42217c68 --- /dev/null +++ b/test/yacc/big_l.error @@ -0,0 +1,31 @@ +YACC: w - -L flag unsupported, reconfigure with --enable-btyacc +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/yacc/big_l.output b/test/yacc/big_l.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc.error b/test/yacc/calc.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc.output b/test/yacc/calc.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/calc.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/calc.tab.c b/test/yacc/calc.tab.c new file mode 100644 index 00000000000..22f387c2f09 --- /dev/null +++ b/test/yacc/calc.tab.c @@ -0,0 +1,686 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_rule +#endif /* yyrule */ +#define YYPREFIX "calc_" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 111 "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 int 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_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, +}; +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-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const calc_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 356 "calc.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 558 "calc.tab.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 563 "calc.tab.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 568 "calc.tab.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 573 "calc.tab.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 578 "calc.tab.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 583 "calc.tab.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 588 "calc.tab.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 593 "calc.tab.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 598 "calc.tab.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 603 "calc.tab.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 608 "calc.tab.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 613 "calc.tab.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 618 "calc.tab.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 623 "calc.tab.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 628 "calc.tab.c" +break; +#line 630 "calc.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc.tab.h b/test/yacc/calc.tab.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/calc.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/calc1.error b/test/yacc/calc1.error new file mode 100644 index 00000000000..9c1f7152c30 --- /dev/null +++ b/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/test/yacc/calc1.output b/test/yacc/calc1.output new file mode 100644 index 00000000000..2b628d47ddb --- /dev/null +++ b/test/yacc/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/test/yacc/calc1.tab.c b/test/yacc/calc1.tab.c new file mode 100644 index 00000000000..3f704400d84 --- /dev/null +++ b/test/yacc/calc1.tab.c @@ -0,0 +1,936 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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]; + +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 31 "calc1.y" +typedef union YYSTYPE +{ + int ival; + double dval; + INTERVAL vval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 141 "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 int 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_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, +}; +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-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 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 493 "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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 57 "calc1.y" + { + (void) printf("%15.8f\n", yystack.l_mark[-1].dval); + } +#line 697 "calc1.tab.c" +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); + } +#line 704 "calc1.tab.c" +break; +case 5: +#line 65 "calc1.y" + { + dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; + } +#line 711 "calc1.tab.c" +break; +case 6: +#line 69 "calc1.y" + { + vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; + } +#line 718 "calc1.tab.c" +break; +case 7: +#line 73 "calc1.y" + { + yyerrok; + } +#line 725 "calc1.tab.c" +break; +case 9: +#line 80 "calc1.y" + { + yyval.dval = dreg[yystack.l_mark[0].ival]; + } +#line 732 "calc1.tab.c" +break; +case 10: +#line 84 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; + } +#line 739 "calc1.tab.c" +break; +case 11: +#line 88 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; + } +#line 746 "calc1.tab.c" +break; +case 12: +#line 92 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; + } +#line 753 "calc1.tab.c" +break; +case 13: +#line 96 "calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; + } +#line 760 "calc1.tab.c" +break; +case 14: +#line 100 "calc1.y" + { + yyval.dval = -yystack.l_mark[0].dval; + } +#line 767 "calc1.tab.c" +break; +case 15: +#line 104 "calc1.y" + { + yyval.dval = yystack.l_mark[-1].dval; + } +#line 774 "calc1.tab.c" +break; +case 16: +#line 110 "calc1.y" + { + yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; + } +#line 781 "calc1.tab.c" +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; + } + } +#line 794 "calc1.tab.c" +break; +case 18: +#line 124 "calc1.y" + { + yyval.vval = vreg[yystack.l_mark[0].ival]; + } +#line 801 "calc1.tab.c" +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; + } +#line 809 "calc1.tab.c" +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; + } +#line 817 "calc1.tab.c" +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; + } +#line 825 "calc1.tab.c" +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; + } +#line 833 "calc1.tab.c" +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 ); + } +#line 840 "calc1.tab.c" +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 ); + } +#line 847 "calc1.tab.c" +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 ); + } +#line 855 "calc1.tab.c" +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 ); + } +#line 863 "calc1.tab.c" +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; + } +#line 871 "calc1.tab.c" +break; +case 28: +#line 171 "calc1.y" + { + yyval.vval = yystack.l_mark[-1].vval; + } +#line 878 "calc1.tab.c" +break; +#line 880 "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) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc1.tab.h b/test/yacc/calc1.tab.h new file mode 100644 index 00000000000..dd493d013c2 --- /dev/null +++ b/test/yacc/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 YYSTYPE +{ + int ival; + double dval; + INTERVAL vval; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE calc1_lval; diff --git a/test/yacc/calc2.error b/test/yacc/calc2.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc2.output b/test/yacc/calc2.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/calc2.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/calc2.tab.c b/test/yacc/calc2.tab.c new file mode 100644 index 00000000000..62202c424b1 --- /dev/null +++ b/test/yacc/calc2.tab.c @@ -0,0 +1,699 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 113 "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 int 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_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, +}; +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-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 369 "calc2.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "calc2.y" + { yyerrok ; } +#line 571 "calc2.tab.c" +break; +case 4: +#line 39 "calc2.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 576 "calc2.tab.c" +break; +case 5: +#line 41 "calc2.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 581 "calc2.tab.c" +break; +case 6: +#line 45 "calc2.y" + { yyval = yystack.l_mark[-1]; } +#line 586 "calc2.tab.c" +break; +case 7: +#line 47 "calc2.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 591 "calc2.tab.c" +break; +case 8: +#line 49 "calc2.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 596 "calc2.tab.c" +break; +case 9: +#line 51 "calc2.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 601 "calc2.tab.c" +break; +case 10: +#line 53 "calc2.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 606 "calc2.tab.c" +break; +case 11: +#line 55 "calc2.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 611 "calc2.tab.c" +break; +case 12: +#line 57 "calc2.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 616 "calc2.tab.c" +break; +case 13: +#line 59 "calc2.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 621 "calc2.tab.c" +break; +case 14: +#line 61 "calc2.y" + { yyval = - yystack.l_mark[0]; } +#line 626 "calc2.tab.c" +break; +case 15: +#line 63 "calc2.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 631 "calc2.tab.c" +break; +case 17: +#line 68 "calc2.y" + { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 636 "calc2.tab.c" +break; +case 18: +#line 70 "calc2.y" + { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 641 "calc2.tab.c" +break; +#line 643 "calc2.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc2.tab.h b/test/yacc/calc2.tab.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/calc2.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/calc3.error b/test/yacc/calc3.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc3.output b/test/yacc/calc3.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/calc3.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/calc3.tab.c b/test/yacc/calc3.tab.c new file mode 100644 index 00000000000..eb487785e56 --- /dev/null +++ b/test/yacc/calc3.tab.c @@ -0,0 +1,707 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 114 "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 int 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_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, +}; +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-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const 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 + +#if YYDEBUG +int yydebug; +#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 + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +#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 366 "calc3.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; + int yynerrs; + + /* 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 + + memset(&yyval, 0, sizeof(yyval)); + memset(&yylval, 0, sizeof(yylval)); + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 38 "calc3.y" + { yyerrok ; } +#line 579 "calc3.tab.c" +break; +case 4: +#line 42 "calc3.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 584 "calc3.tab.c" +break; +case 5: +#line 44 "calc3.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 589 "calc3.tab.c" +break; +case 6: +#line 48 "calc3.y" + { yyval = yystack.l_mark[-1]; } +#line 594 "calc3.tab.c" +break; +case 7: +#line 50 "calc3.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 599 "calc3.tab.c" +break; +case 8: +#line 52 "calc3.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 604 "calc3.tab.c" +break; +case 9: +#line 54 "calc3.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 609 "calc3.tab.c" +break; +case 10: +#line 56 "calc3.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 614 "calc3.tab.c" +break; +case 11: +#line 58 "calc3.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 619 "calc3.tab.c" +break; +case 12: +#line 60 "calc3.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 624 "calc3.tab.c" +break; +case 13: +#line 62 "calc3.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 629 "calc3.tab.c" +break; +case 14: +#line 64 "calc3.y" + { yyval = - yystack.l_mark[0]; } +#line 634 "calc3.tab.c" +break; +case 15: +#line 66 "calc3.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 639 "calc3.tab.c" +break; +case 17: +#line 71 "calc3.y" + { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 644 "calc3.tab.c" +break; +case 18: +#line 73 "calc3.y" + { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 649 "calc3.tab.c" +break; +#line 651 "calc3.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc3.tab.h b/test/yacc/calc3.tab.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/calc3.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/calc_code_all.error b/test/yacc/calc_code_all.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc_code_all.output b/test/yacc/calc_code_all.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/calc_code_all.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/calc_code_all.tab.c b/test/yacc/calc_code_all.tab.c new file mode 100644 index 00000000000..423189b7025 --- /dev/null +++ b/test/yacc/calc_code_all.tab.c @@ -0,0 +1,714 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +/* %code "top" block start */ +#line 5 "calc_code_all.y" +/* CODE-TOP */ +/* %code "top" block end */ +#line 22 "calc_code_all.tab.c" + +#ifndef yyparse +#define yyparse calc_code_all_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_all_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_all_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_all_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_all_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_all_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_all_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_all_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_all_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_all_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_all_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_all_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_all_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_all_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_all_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_all_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_all_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_all_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_all_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_all_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_all_" + +#define YYPURE 0 + +#line 9 "calc_code_all.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 117 "calc_code_all.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_all_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_all_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_all_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT calc_code_all_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_all_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_all_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT calc_code_all_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_all_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_all_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_all_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const calc_code_all_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* %code "requires" block start */ +#line 3 "calc_code_all.y" +/* CODE-REQUIRES */ +/* %code "requires" block end */ +#line 299 "calc_code_all.tab.c" + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; + +/* %code "provides" block start */ +#line 4 "calc_code_all.y" +/* CODE-PROVIDES */ +#line 6 "calc_code_all.y" +/* CODE-PROVIDES2 */ +/* %code "provides" block end */ +#line 333 "calc_code_all.tab.c" + +/* %code "" block start */ +#line 1 "calc_code_all.y" +/* CODE-DEFAULT2 */ +#line 2 "calc_code_all.y" +/* CODE-DEFAULT */ +/* %code "" block end */ +#line 341 "calc_code_all.tab.c" +#line 73 "calc_code_all.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 384 "calc_code_all.tab.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "calc_code_all.y" + { yyerrok ; } +#line 586 "calc_code_all.tab.c" +break; +case 4: +#line 39 "calc_code_all.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 591 "calc_code_all.tab.c" +break; +case 5: +#line 41 "calc_code_all.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 596 "calc_code_all.tab.c" +break; +case 6: +#line 45 "calc_code_all.y" + { yyval = yystack.l_mark[-1]; } +#line 601 "calc_code_all.tab.c" +break; +case 7: +#line 47 "calc_code_all.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 606 "calc_code_all.tab.c" +break; +case 8: +#line 49 "calc_code_all.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 611 "calc_code_all.tab.c" +break; +case 9: +#line 51 "calc_code_all.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 616 "calc_code_all.tab.c" +break; +case 10: +#line 53 "calc_code_all.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 621 "calc_code_all.tab.c" +break; +case 11: +#line 55 "calc_code_all.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 626 "calc_code_all.tab.c" +break; +case 12: +#line 57 "calc_code_all.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 631 "calc_code_all.tab.c" +break; +case 13: +#line 59 "calc_code_all.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 636 "calc_code_all.tab.c" +break; +case 14: +#line 61 "calc_code_all.y" + { yyval = - yystack.l_mark[0]; } +#line 641 "calc_code_all.tab.c" +break; +case 15: +#line 63 "calc_code_all.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 646 "calc_code_all.tab.c" +break; +case 17: +#line 68 "calc_code_all.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 651 "calc_code_all.tab.c" +break; +case 18: +#line 70 "calc_code_all.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 656 "calc_code_all.tab.c" +break; +#line 658 "calc_code_all.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc_code_all.tab.h b/test/yacc/calc_code_all.tab.h new file mode 100644 index 00000000000..7edd87c3e6c --- /dev/null +++ b/test/yacc/calc_code_all.tab.h @@ -0,0 +1,13 @@ +/* %code "requires" block start */ +#line 3 "calc_code_all.y" +/* CODE-REQUIRES */ +/* %code "requires" block end */ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +/* %code "provides" block start */ +#line 4 "calc_code_all.y" +/* CODE-PROVIDES */ +#line 6 "calc_code_all.y" +/* CODE-PROVIDES2 */ +/* %code "provides" block end */ diff --git a/test/yacc/calc_code_default.error b/test/yacc/calc_code_default.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc_code_default.output b/test/yacc/calc_code_default.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/calc_code_default.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/calc_code_default.tab.c b/test/yacc/calc_code_default.tab.c new file mode 100644 index 00000000000..cf4e7e65261 --- /dev/null +++ b/test/yacc/calc_code_default.tab.c @@ -0,0 +1,694 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +#ifndef yyparse +#define yyparse calc_code_default_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_default_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_default_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_default_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_default_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_default_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_default_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_default_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_default_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_default_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_default_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_default_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_default_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_default_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_default_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_default_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_default_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_default_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_default_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_default_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_default_" + +#define YYPURE 0 + +#line 5 "calc_code_default.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 111 "calc_code_default.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_default_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_default_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_default_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT calc_code_default_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_default_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_default_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT calc_code_default_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_default_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_default_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_default_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const calc_code_default_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; + +/* %code "" block start */ +#line 1 "calc_code_default.y" +/* CODE-DEFAULT */ +#line 2 "calc_code_default.y" +/* CODE-DEFAULT2 */ +/* %code "" block end */ +#line 321 "calc_code_default.tab.c" +#line 69 "calc_code_default.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 364 "calc_code_default.tab.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_default.y" + { yyerrok ; } +#line 566 "calc_code_default.tab.c" +break; +case 4: +#line 35 "calc_code_default.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 571 "calc_code_default.tab.c" +break; +case 5: +#line 37 "calc_code_default.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 576 "calc_code_default.tab.c" +break; +case 6: +#line 41 "calc_code_default.y" + { yyval = yystack.l_mark[-1]; } +#line 581 "calc_code_default.tab.c" +break; +case 7: +#line 43 "calc_code_default.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 586 "calc_code_default.tab.c" +break; +case 8: +#line 45 "calc_code_default.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 591 "calc_code_default.tab.c" +break; +case 9: +#line 47 "calc_code_default.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 596 "calc_code_default.tab.c" +break; +case 10: +#line 49 "calc_code_default.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 601 "calc_code_default.tab.c" +break; +case 11: +#line 51 "calc_code_default.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 606 "calc_code_default.tab.c" +break; +case 12: +#line 53 "calc_code_default.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 611 "calc_code_default.tab.c" +break; +case 13: +#line 55 "calc_code_default.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 616 "calc_code_default.tab.c" +break; +case 14: +#line 57 "calc_code_default.y" + { yyval = - yystack.l_mark[0]; } +#line 621 "calc_code_default.tab.c" +break; +case 15: +#line 59 "calc_code_default.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 626 "calc_code_default.tab.c" +break; +case 17: +#line 64 "calc_code_default.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 631 "calc_code_default.tab.c" +break; +case 18: +#line 66 "calc_code_default.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 636 "calc_code_default.tab.c" +break; +#line 638 "calc_code_default.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc_code_default.tab.h b/test/yacc/calc_code_default.tab.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/calc_code_default.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/calc_code_imports.error b/test/yacc/calc_code_imports.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc_code_imports.output b/test/yacc/calc_code_imports.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/calc_code_imports.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/calc_code_imports.tab.c b/test/yacc/calc_code_imports.tab.c new file mode 100644 index 00000000000..ddd89c35969 --- /dev/null +++ b/test/yacc/calc_code_imports.tab.c @@ -0,0 +1,686 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +#ifndef yyparse +#define yyparse calc_code_imports_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_imports_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_imports_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_imports_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_imports_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_imports_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_imports_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_imports_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_imports_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_imports_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_imports_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_imports_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_imports_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_imports_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_imports_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_imports_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_imports_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_imports_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_imports_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_imports_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_imports_" + +#define YYPURE 0 + +#line 5 "calc_code_imports.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 111 "calc_code_imports.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_imports_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_imports_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_imports_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT calc_code_imports_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_imports_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_imports_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT calc_code_imports_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_imports_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_imports_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_imports_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const calc_code_imports_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 69 "calc_code_imports.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 356 "calc_code_imports.tab.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_imports.y" + { yyerrok ; } +#line 558 "calc_code_imports.tab.c" +break; +case 4: +#line 35 "calc_code_imports.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 563 "calc_code_imports.tab.c" +break; +case 5: +#line 37 "calc_code_imports.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 568 "calc_code_imports.tab.c" +break; +case 6: +#line 41 "calc_code_imports.y" + { yyval = yystack.l_mark[-1]; } +#line 573 "calc_code_imports.tab.c" +break; +case 7: +#line 43 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 578 "calc_code_imports.tab.c" +break; +case 8: +#line 45 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 583 "calc_code_imports.tab.c" +break; +case 9: +#line 47 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 588 "calc_code_imports.tab.c" +break; +case 10: +#line 49 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 593 "calc_code_imports.tab.c" +break; +case 11: +#line 51 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 598 "calc_code_imports.tab.c" +break; +case 12: +#line 53 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 603 "calc_code_imports.tab.c" +break; +case 13: +#line 55 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 608 "calc_code_imports.tab.c" +break; +case 14: +#line 57 "calc_code_imports.y" + { yyval = - yystack.l_mark[0]; } +#line 613 "calc_code_imports.tab.c" +break; +case 15: +#line 59 "calc_code_imports.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 618 "calc_code_imports.tab.c" +break; +case 17: +#line 64 "calc_code_imports.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 623 "calc_code_imports.tab.c" +break; +case 18: +#line 66 "calc_code_imports.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 628 "calc_code_imports.tab.c" +break; +#line 630 "calc_code_imports.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc_code_imports.tab.h b/test/yacc/calc_code_imports.tab.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/calc_code_imports.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/calc_code_provides.error b/test/yacc/calc_code_provides.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc_code_provides.output b/test/yacc/calc_code_provides.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/calc_code_provides.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/calc_code_provides.tab.c b/test/yacc/calc_code_provides.tab.c new file mode 100644 index 00000000000..46f68e4b039 --- /dev/null +++ b/test/yacc/calc_code_provides.tab.c @@ -0,0 +1,694 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +#ifndef yyparse +#define yyparse calc_code_provides_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_provides_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_provides_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_provides_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_provides_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_provides_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_provides_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_provides_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_provides_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_provides_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_provides_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_provides_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_provides_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_provides_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_provides_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_provides_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_provides_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_provides_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_provides_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_provides_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_provides_" + +#define YYPURE 0 + +#line 5 "calc_code_provides.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 111 "calc_code_provides.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_provides_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_provides_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_provides_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT calc_code_provides_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_provides_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_provides_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT calc_code_provides_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_provides_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_provides_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_provides_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const calc_code_provides_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; + +/* %code "provides" block start */ +#line 1 "calc_code_provides.y" +/* CODE-PROVIDES */ +#line 2 "calc_code_provides.y" +/* CODE-PROVIDES2 */ +/* %code "provides" block end */ +#line 321 "calc_code_provides.tab.c" +#line 69 "calc_code_provides.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 364 "calc_code_provides.tab.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_provides.y" + { yyerrok ; } +#line 566 "calc_code_provides.tab.c" +break; +case 4: +#line 35 "calc_code_provides.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 571 "calc_code_provides.tab.c" +break; +case 5: +#line 37 "calc_code_provides.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 576 "calc_code_provides.tab.c" +break; +case 6: +#line 41 "calc_code_provides.y" + { yyval = yystack.l_mark[-1]; } +#line 581 "calc_code_provides.tab.c" +break; +case 7: +#line 43 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 586 "calc_code_provides.tab.c" +break; +case 8: +#line 45 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 591 "calc_code_provides.tab.c" +break; +case 9: +#line 47 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 596 "calc_code_provides.tab.c" +break; +case 10: +#line 49 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 601 "calc_code_provides.tab.c" +break; +case 11: +#line 51 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 606 "calc_code_provides.tab.c" +break; +case 12: +#line 53 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 611 "calc_code_provides.tab.c" +break; +case 13: +#line 55 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 616 "calc_code_provides.tab.c" +break; +case 14: +#line 57 "calc_code_provides.y" + { yyval = - yystack.l_mark[0]; } +#line 621 "calc_code_provides.tab.c" +break; +case 15: +#line 59 "calc_code_provides.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 626 "calc_code_provides.tab.c" +break; +case 17: +#line 64 "calc_code_provides.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 631 "calc_code_provides.tab.c" +break; +case 18: +#line 66 "calc_code_provides.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 636 "calc_code_provides.tab.c" +break; +#line 638 "calc_code_provides.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc_code_provides.tab.h b/test/yacc/calc_code_provides.tab.h new file mode 100644 index 00000000000..a7004790d1f --- /dev/null +++ b/test/yacc/calc_code_provides.tab.h @@ -0,0 +1,9 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +/* %code "provides" block start */ +#line 1 "calc_code_provides.y" +/* CODE-PROVIDES */ +#line 2 "calc_code_provides.y" +/* CODE-PROVIDES2 */ +/* %code "provides" block end */ diff --git a/test/yacc/calc_code_requires.error b/test/yacc/calc_code_requires.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc_code_requires.output b/test/yacc/calc_code_requires.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/calc_code_requires.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/calc_code_requires.tab.c b/test/yacc/calc_code_requires.tab.c new file mode 100644 index 00000000000..e409d37e40c --- /dev/null +++ b/test/yacc/calc_code_requires.tab.c @@ -0,0 +1,694 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +#ifndef yyparse +#define yyparse calc_code_requires_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_requires_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_requires_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_requires_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_requires_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_requires_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_requires_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_requires_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_requires_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_requires_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_requires_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_requires_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_requires_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_requires_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_requires_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_requires_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_requires_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_requires_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_requires_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_requires_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_requires_" + +#define YYPURE 0 + +#line 5 "calc_code_requires.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 111 "calc_code_requires.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_requires_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_requires_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_requires_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT calc_code_requires_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_requires_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_requires_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT calc_code_requires_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_requires_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_requires_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_requires_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const calc_code_requires_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* %code "requires" block start */ +#line 1 "calc_code_requires.y" +/* CODE-REQUIRES */ +#line 2 "calc_code_requires.y" +/* CODE-REQUIRES2 */ +/* %code "requires" block end */ +#line 295 "calc_code_requires.tab.c" + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 69 "calc_code_requires.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 364 "calc_code_requires.tab.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_requires.y" + { yyerrok ; } +#line 566 "calc_code_requires.tab.c" +break; +case 4: +#line 35 "calc_code_requires.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 571 "calc_code_requires.tab.c" +break; +case 5: +#line 37 "calc_code_requires.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 576 "calc_code_requires.tab.c" +break; +case 6: +#line 41 "calc_code_requires.y" + { yyval = yystack.l_mark[-1]; } +#line 581 "calc_code_requires.tab.c" +break; +case 7: +#line 43 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 586 "calc_code_requires.tab.c" +break; +case 8: +#line 45 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 591 "calc_code_requires.tab.c" +break; +case 9: +#line 47 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 596 "calc_code_requires.tab.c" +break; +case 10: +#line 49 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 601 "calc_code_requires.tab.c" +break; +case 11: +#line 51 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 606 "calc_code_requires.tab.c" +break; +case 12: +#line 53 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 611 "calc_code_requires.tab.c" +break; +case 13: +#line 55 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 616 "calc_code_requires.tab.c" +break; +case 14: +#line 57 "calc_code_requires.y" + { yyval = - yystack.l_mark[0]; } +#line 621 "calc_code_requires.tab.c" +break; +case 15: +#line 59 "calc_code_requires.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 626 "calc_code_requires.tab.c" +break; +case 17: +#line 64 "calc_code_requires.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 631 "calc_code_requires.tab.c" +break; +case 18: +#line 66 "calc_code_requires.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 636 "calc_code_requires.tab.c" +break; +#line 638 "calc_code_requires.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc_code_requires.tab.h b/test/yacc/calc_code_requires.tab.h new file mode 100644 index 00000000000..b734c8358f5 --- /dev/null +++ b/test/yacc/calc_code_requires.tab.h @@ -0,0 +1,9 @@ +/* %code "requires" block start */ +#line 1 "calc_code_requires.y" +/* CODE-REQUIRES */ +#line 2 "calc_code_requires.y" +/* CODE-REQUIRES2 */ +/* %code "requires" block end */ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/calc_code_top.error b/test/yacc/calc_code_top.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/calc_code_top.output b/test/yacc/calc_code_top.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/calc_code_top.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/calc_code_top.tab.c b/test/yacc/calc_code_top.tab.c new file mode 100644 index 00000000000..1f47973f1ac --- /dev/null +++ b/test/yacc/calc_code_top.tab.c @@ -0,0 +1,694 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +/* %code "top" block start */ +#line 1 "calc_code_top.y" +/* CODE-TOP */ +#line 2 "calc_code_top.y" +/* CODE-TOP2 */ +/* %code "top" block end */ +#line 24 "calc_code_top.tab.c" + +#ifndef yyparse +#define yyparse calc_code_top_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_top_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_top_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_top_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_top_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_top_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_top_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_top_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_top_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_top_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_top_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_top_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_top_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_top_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_top_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_top_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_top_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_top_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_top_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_top_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_top_" + +#define YYPURE 0 + +#line 5 "calc_code_top.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 119 "calc_code_top.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT calc_code_top_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT calc_code_top_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT calc_code_top_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT calc_code_top_dgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT calc_code_top_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT calc_code_top_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT calc_code_top_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT calc_code_top_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT calc_code_top_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const calc_code_top_name[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const calc_code_top_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 69 "calc_code_top.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 364 "calc_code_top.tab.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_top.y" + { yyerrok ; } +#line 566 "calc_code_top.tab.c" +break; +case 4: +#line 35 "calc_code_top.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 571 "calc_code_top.tab.c" +break; +case 5: +#line 37 "calc_code_top.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 576 "calc_code_top.tab.c" +break; +case 6: +#line 41 "calc_code_top.y" + { yyval = yystack.l_mark[-1]; } +#line 581 "calc_code_top.tab.c" +break; +case 7: +#line 43 "calc_code_top.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 586 "calc_code_top.tab.c" +break; +case 8: +#line 45 "calc_code_top.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 591 "calc_code_top.tab.c" +break; +case 9: +#line 47 "calc_code_top.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 596 "calc_code_top.tab.c" +break; +case 10: +#line 49 "calc_code_top.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 601 "calc_code_top.tab.c" +break; +case 11: +#line 51 "calc_code_top.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 606 "calc_code_top.tab.c" +break; +case 12: +#line 53 "calc_code_top.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 611 "calc_code_top.tab.c" +break; +case 13: +#line 55 "calc_code_top.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 616 "calc_code_top.tab.c" +break; +case 14: +#line 57 "calc_code_top.y" + { yyval = - yystack.l_mark[0]; } +#line 621 "calc_code_top.tab.c" +break; +case 15: +#line 59 "calc_code_top.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 626 "calc_code_top.tab.c" +break; +case 17: +#line 64 "calc_code_top.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 631 "calc_code_top.tab.c" +break; +case 18: +#line 66 "calc_code_top.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 636 "calc_code_top.tab.c" +break; +#line 638 "calc_code_top.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/calc_code_top.tab.h b/test/yacc/calc_code_top.tab.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/calc_code_top.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/code_calc.code.c b/test/yacc/code_calc.code.c new file mode 100644 index 00000000000..608ff7fb4ad --- /dev/null +++ b/test/yacc/code_calc.code.c @@ -0,0 +1,595 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 2 +#define YYMINOR 0 +#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 +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_rule +#endif /* yyrule */ +#define YYPREFIX "calc_" + +#define YYPURE 0 + +#line 4 "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 +#undef yytname +#define yytname yyname +#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 int 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 || defined(yytname) +extern char *yyname[]; +#endif +#if YYDEBUG +extern char *yyrule[]; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 70 "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 265 "code_calc.code.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 32 "code_calc.y" + { yyerrok ; } +#line 467 "code_calc.code.c" +break; +case 4: +#line 36 "code_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 472 "code_calc.code.c" +break; +case 5: +#line 38 "code_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 477 "code_calc.code.c" +break; +case 6: +#line 42 "code_calc.y" + { yyval = yystack.l_mark[-1]; } +#line 482 "code_calc.code.c" +break; +case 7: +#line 44 "code_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 487 "code_calc.code.c" +break; +case 8: +#line 46 "code_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 492 "code_calc.code.c" +break; +case 9: +#line 48 "code_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 497 "code_calc.code.c" +break; +case 10: +#line 50 "code_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 502 "code_calc.code.c" +break; +case 11: +#line 52 "code_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 507 "code_calc.code.c" +break; +case 12: +#line 54 "code_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 512 "code_calc.code.c" +break; +case 13: +#line 56 "code_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 517 "code_calc.code.c" +break; +case 14: +#line 58 "code_calc.y" + { yyval = - yystack.l_mark[0]; } +#line 522 "code_calc.code.c" +break; +case 15: +#line 60 "code_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 527 "code_calc.code.c" +break; +case 17: +#line 65 "code_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 532 "code_calc.code.c" +break; +case 18: +#line 67 "code_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 537 "code_calc.code.c" +break; +#line 539 "code_calc.code.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/code_calc.error b/test/yacc/code_calc.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/code_calc.output b/test/yacc/code_calc.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/code_calc.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/code_calc.tab.c b/test/yacc/code_calc.tab.c new file mode 100644 index 00000000000..9242641a931 --- /dev/null +++ b/test/yacc/code_calc.tab.c @@ -0,0 +1,119 @@ +typedef int 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_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, +}; +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 +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, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +#if YYDEBUG +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/test/yacc/code_calc.tab.h b/test/yacc/code_calc.tab.h new file mode 100644 index 00000000000..b0bcb16dc45 --- /dev/null +++ b/test/yacc/code_calc.tab.h @@ -0,0 +1,5 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#undef yytname +#define yytname yyname diff --git a/test/yacc/code_error.code.c b/test/yacc/code_error.code.c new file mode 100644 index 00000000000..ef2e78c00b5 --- /dev/null +++ b/test/yacc/code_error.code.c @@ -0,0 +1,489 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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_" + +#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(); +typedef int 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 || defined(yytname) +extern char *yyname[]; +#endif +#if YYDEBUG +extern char *yyrule[]; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 235 "code_error.code.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/code_error.error b/test/yacc/code_error.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/code_error.output b/test/yacc/code_error.output new file mode 100644 index 00000000000..0c4db6225e2 --- /dev/null +++ b/test/yacc/code_error.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/test/yacc/code_error.tab.c b/test/yacc/code_error.tab.c new file mode 100644 index 00000000000..d394ad80849 --- /dev/null +++ b/test/yacc/code_error.tab.c @@ -0,0 +1,44 @@ +typedef int 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/test/yacc/code_error.tab.h b/test/yacc/code_error.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/defines1.calc.c b/test/yacc/defines1.calc.c new file mode 100644 index 00000000000..e5ebf355c00 --- /dev/null +++ b/test/yacc/defines1.calc.c @@ -0,0 +1,610 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 31 "y.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 280 "y.tab.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 482 "y.tab.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 487 "y.tab.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 492 "y.tab.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 497 "y.tab.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 502 "y.tab.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 507 "y.tab.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 512 "y.tab.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 517 "y.tab.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 522 "y.tab.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 527 "y.tab.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 532 "y.tab.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 537 "y.tab.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 542 "y.tab.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 547 "y.tab.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 552 "y.tab.c" +break; +#line 554 "y.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/defines1.calc.h b/test/yacc/defines1.calc.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/defines1.calc.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/defines1.error b/test/yacc/defines1.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/defines1.output b/test/yacc/defines1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/defines2.calc.c b/test/yacc/defines2.calc.c new file mode 100644 index 00000000000..e5ebf355c00 --- /dev/null +++ b/test/yacc/defines2.calc.c @@ -0,0 +1,610 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 31 "y.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 280 "y.tab.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 482 "y.tab.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 487 "y.tab.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 492 "y.tab.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 497 "y.tab.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 502 "y.tab.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 507 "y.tab.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 512 "y.tab.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 517 "y.tab.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 522 "y.tab.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 527 "y.tab.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 532 "y.tab.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 537 "y.tab.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 542 "y.tab.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 547 "y.tab.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 552 "y.tab.c" +break; +#line 554 "y.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/defines2.calc.h b/test/yacc/defines2.calc.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/defines2.calc.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/defines2.error b/test/yacc/defines2.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/defines2.output b/test/yacc/defines2.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/defines3.calc.c b/test/yacc/defines3.calc.c new file mode 100644 index 00000000000..90bca1d7b36 --- /dev/null +++ b/test/yacc/defines3.calc.c @@ -0,0 +1,610 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 31 "prefix.tab.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 280 "prefix.tab.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 482 "prefix.tab.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 487 "prefix.tab.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 492 "prefix.tab.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 497 "prefix.tab.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 502 "prefix.tab.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 507 "prefix.tab.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 512 "prefix.tab.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 517 "prefix.tab.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 522 "prefix.tab.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 527 "prefix.tab.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 532 "prefix.tab.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 537 "prefix.tab.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 542 "prefix.tab.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 547 "prefix.tab.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 552 "prefix.tab.c" +break; +#line 554 "prefix.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/defines3.calc.h b/test/yacc/defines3.calc.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/defines3.calc.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/defines3.error b/test/yacc/defines3.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/defines3.output b/test/yacc/defines3.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/empty.error b/test/yacc/empty.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/empty.output b/test/yacc/empty.output new file mode 100644 index 00000000000..b7cf396ef98 --- /dev/null +++ b/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/test/yacc/empty.tab.c b/test/yacc/empty.tab.c new file mode 100644 index 00000000000..f2387a4218e --- /dev/null +++ b/test/yacc/empty.tab.c @@ -0,0 +1,500 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 13 "empty.y" + +#include + +static int +YYLEX_DECL() { + return -1; +} + +static void +YYERROR_DECL() { + printf("%s\n",s); +} +#line 246 "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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/empty.tab.h b/test/yacc/empty.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax1.error b/test/yacc/err_syntax1.error new file mode 100644 index 00000000000..5df5c22ef17 --- /dev/null +++ b/test/yacc/err_syntax1.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./err_syntax1.y", syntax error + ?% { + ^ diff --git a/test/yacc/err_syntax1.output b/test/yacc/err_syntax1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax1.tab.c b/test/yacc/err_syntax1.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax1.tab.h b/test/yacc/err_syntax1.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax10.error b/test/yacc/err_syntax10.error new file mode 100644 index 00000000000..61a72c0408a --- /dev/null +++ b/test/yacc/err_syntax10.error @@ -0,0 +1,3 @@ +YACC: w - line 7 of "./err_syntax10.y", the type of '(' has been redeclared +YACC: w - line 7 of "./err_syntax10.y", the type of '*' has been redeclared +YACC: w - line 7 of "./err_syntax10.y", the type of '&' has been redeclared diff --git a/test/yacc/err_syntax10.output b/test/yacc/err_syntax10.output new file mode 100644 index 00000000000..1b4542bde5c --- /dev/null +++ b/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/test/yacc/err_syntax10.tab.c b/test/yacc/err_syntax10.tab.c new file mode 100644 index 00000000000..2cf718c93de --- /dev/null +++ b/test/yacc/err_syntax10.tab.c @@ -0,0 +1,499 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 245 "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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/err_syntax10.tab.h b/test/yacc/err_syntax10.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax11.error b/test/yacc/err_syntax11.error new file mode 100644 index 00000000000..b2dd79c5050 --- /dev/null +++ b/test/yacc/err_syntax11.error @@ -0,0 +1 @@ +YACC: w - line 7 of "./err_syntax11.y", the precedence of '|' has been redeclared diff --git a/test/yacc/err_syntax11.output b/test/yacc/err_syntax11.output new file mode 100644 index 00000000000..a71ff2a4001 --- /dev/null +++ b/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/test/yacc/err_syntax11.tab.c b/test/yacc/err_syntax11.tab.c new file mode 100644 index 00000000000..ef6c680724f --- /dev/null +++ b/test/yacc/err_syntax11.tab.c @@ -0,0 +1,505 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 251 "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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/err_syntax11.tab.h b/test/yacc/err_syntax11.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax12.error b/test/yacc/err_syntax12.error new file mode 100644 index 00000000000..358960bdb9e --- /dev/null +++ b/test/yacc/err_syntax12.error @@ -0,0 +1 @@ +YACC: w - line 7 of "./err_syntax12.y", the value of text has been redeclared diff --git a/test/yacc/err_syntax12.output b/test/yacc/err_syntax12.output new file mode 100644 index 00000000000..a71ff2a4001 --- /dev/null +++ b/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/test/yacc/err_syntax12.tab.c b/test/yacc/err_syntax12.tab.c new file mode 100644 index 00000000000..8060aaa26a1 --- /dev/null +++ b/test/yacc/err_syntax12.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 2 +#define YYMINOR 0 +#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 int 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 257 "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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/err_syntax12.tab.h b/test/yacc/err_syntax12.tab.h new file mode 100644 index 00000000000..c273c08742a --- /dev/null +++ b/test/yacc/err_syntax12.tab.h @@ -0,0 +1 @@ +#define text 456 diff --git a/test/yacc/err_syntax13.error b/test/yacc/err_syntax13.error new file mode 100644 index 00000000000..9ffa8b40c27 --- /dev/null +++ b/test/yacc/err_syntax13.error @@ -0,0 +1 @@ +YACC: e - line 7 of "./err_syntax13.y", the start symbol text is a token diff --git a/test/yacc/err_syntax13.output b/test/yacc/err_syntax13.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax13.tab.c b/test/yacc/err_syntax13.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax13.tab.h b/test/yacc/err_syntax13.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax14.error b/test/yacc/err_syntax14.error new file mode 100644 index 00000000000..73e9f7c8319 --- /dev/null +++ b/test/yacc/err_syntax14.error @@ -0,0 +1,2 @@ +YACC: w - line 7 of "./err_syntax14.y", the start symbol has been redeclared +YACC: e - the start symbol text2 is undefined diff --git a/test/yacc/err_syntax14.output b/test/yacc/err_syntax14.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax14.tab.c b/test/yacc/err_syntax14.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax14.tab.h b/test/yacc/err_syntax14.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax15.error b/test/yacc/err_syntax15.error new file mode 100644 index 00000000000..36dc03fef8b --- /dev/null +++ b/test/yacc/err_syntax15.error @@ -0,0 +1 @@ +YACC: e - line 9 of "./err_syntax15.y", no grammar has been specified diff --git a/test/yacc/err_syntax15.output b/test/yacc/err_syntax15.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax15.tab.c b/test/yacc/err_syntax15.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax15.tab.h b/test/yacc/err_syntax15.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax16.error b/test/yacc/err_syntax16.error new file mode 100644 index 00000000000..6ff15897045 --- /dev/null +++ b/test/yacc/err_syntax16.error @@ -0,0 +1 @@ +YACC: e - line 14 of "./err_syntax16.y", a token appears on the lhs of a production diff --git a/test/yacc/err_syntax16.output b/test/yacc/err_syntax16.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax16.tab.c b/test/yacc/err_syntax16.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax16.tab.h b/test/yacc/err_syntax16.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax17.error b/test/yacc/err_syntax17.error new file mode 100644 index 00000000000..8a8b64b0712 --- /dev/null +++ b/test/yacc/err_syntax17.error @@ -0,0 +1,3 @@ +YACC: e - line 8 of "./err_syntax17.y", unterminated action +S: { error + ^ diff --git a/test/yacc/err_syntax17.output b/test/yacc/err_syntax17.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax17.tab.c b/test/yacc/err_syntax17.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax17.tab.h b/test/yacc/err_syntax17.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax18.error b/test/yacc/err_syntax18.error new file mode 100644 index 00000000000..c52fd71a1ec --- /dev/null +++ b/test/yacc/err_syntax18.error @@ -0,0 +1 @@ +YACC: w - line 9 of "./err_syntax18.y", $4 references beyond the end of the current rule diff --git a/test/yacc/err_syntax18.output b/test/yacc/err_syntax18.output new file mode 100644 index 00000000000..09ed7d4c70a --- /dev/null +++ b/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/test/yacc/err_syntax18.tab.c b/test/yacc/err_syntax18.tab.c new file mode 100644 index 00000000000..1c08b55b5b7 --- /dev/null +++ b/test/yacc/err_syntax18.tab.c @@ -0,0 +1,513 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 253 "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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 1: +#line 9 "err_syntax18.y" + { yyval = yystack.l_mark[1]; } +#line 455 "err_syntax18.tab.c" +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) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/err_syntax18.tab.h b/test/yacc/err_syntax18.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax19.error b/test/yacc/err_syntax19.error new file mode 100644 index 00000000000..2499b7fc4f1 --- /dev/null +++ b/test/yacc/err_syntax19.error @@ -0,0 +1,3 @@ +YACC: e - line 9 of "./err_syntax19.y", illegal $-name + { $$ = $; } + ^ diff --git a/test/yacc/err_syntax19.output b/test/yacc/err_syntax19.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax19.tab.c b/test/yacc/err_syntax19.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax19.tab.h b/test/yacc/err_syntax19.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax2.error b/test/yacc/err_syntax2.error new file mode 100644 index 00000000000..29fe56c28b4 --- /dev/null +++ b/test/yacc/err_syntax2.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./err_syntax2.y", unmatched /* +%{ /* + ^ diff --git a/test/yacc/err_syntax2.output b/test/yacc/err_syntax2.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax2.tab.c b/test/yacc/err_syntax2.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax2.tab.h b/test/yacc/err_syntax2.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax20.error b/test/yacc/err_syntax20.error new file mode 100644 index 00000000000..76dac8152de --- /dev/null +++ b/test/yacc/err_syntax20.error @@ -0,0 +1 @@ +YACC: w - the symbol recur is undefined diff --git a/test/yacc/err_syntax20.output b/test/yacc/err_syntax20.output new file mode 100644 index 00000000000..cfe62800c64 --- /dev/null +++ b/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/test/yacc/err_syntax20.tab.c b/test/yacc/err_syntax20.tab.c new file mode 100644 index 00000000000..d0b02858dcc --- /dev/null +++ b/test/yacc/err_syntax20.tab.c @@ -0,0 +1,509 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 249 "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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 1: +#line 12 "err_syntax20.y" + { yystack.l_mark[-1].rechk = 3; } +#line 451 "err_syntax20.tab.c" +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) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/err_syntax20.tab.h b/test/yacc/err_syntax20.tab.h new file mode 100644 index 00000000000..60dabd611dd --- /dev/null +++ b/test/yacc/err_syntax20.tab.h @@ -0,0 +1 @@ +#define recur 257 diff --git a/test/yacc/err_syntax21.error b/test/yacc/err_syntax21.error new file mode 100644 index 00000000000..9b0dc17b662 --- /dev/null +++ b/test/yacc/err_syntax21.error @@ -0,0 +1 @@ +YACC: e - line 12 of "./err_syntax21.y", $0 is untyped diff --git a/test/yacc/err_syntax21.output b/test/yacc/err_syntax21.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax21.tab.c b/test/yacc/err_syntax21.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax21.tab.h b/test/yacc/err_syntax21.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax22.error b/test/yacc/err_syntax22.error new file mode 100644 index 00000000000..8622aa73f59 --- /dev/null +++ b/test/yacc/err_syntax22.error @@ -0,0 +1 @@ +YACC: e - line 17 of "./err_syntax22.y", $2 (recur) is untyped diff --git a/test/yacc/err_syntax22.output b/test/yacc/err_syntax22.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax22.tab.c b/test/yacc/err_syntax22.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax22.tab.h b/test/yacc/err_syntax22.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax23.error b/test/yacc/err_syntax23.error new file mode 100644 index 00000000000..3ccbbd1fee8 --- /dev/null +++ b/test/yacc/err_syntax23.error @@ -0,0 +1 @@ +YACC: e - line 18 of "./err_syntax23.y", $$ is untyped diff --git a/test/yacc/err_syntax23.output b/test/yacc/err_syntax23.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax23.tab.c b/test/yacc/err_syntax23.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax23.tab.h b/test/yacc/err_syntax23.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax24.error b/test/yacc/err_syntax24.error new file mode 100644 index 00000000000..e8bbfeca35f --- /dev/null +++ b/test/yacc/err_syntax24.error @@ -0,0 +1,2 @@ +YACC: w - line 21 of "./err_syntax24.y", the default action for expr assigns an undefined value to $$ +YACC: e - line 22 of "./err_syntax24.y", $$ is untyped diff --git a/test/yacc/err_syntax24.output b/test/yacc/err_syntax24.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax24.tab.c b/test/yacc/err_syntax24.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax24.tab.h b/test/yacc/err_syntax24.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax25.error b/test/yacc/err_syntax25.error new file mode 100644 index 00000000000..234a7b9fcd3 --- /dev/null +++ b/test/yacc/err_syntax25.error @@ -0,0 +1,3 @@ +YACC: e - line 11 of "./err_syntax25.y", too many %union declarations +%union { +^ diff --git a/test/yacc/err_syntax25.output b/test/yacc/err_syntax25.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax25.tab.c b/test/yacc/err_syntax25.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax25.tab.h b/test/yacc/err_syntax25.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax26.error b/test/yacc/err_syntax26.error new file mode 100644 index 00000000000..c9a09ad1992 --- /dev/null +++ b/test/yacc/err_syntax26.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./err_syntax26.y", unexpected end-of-file diff --git a/test/yacc/err_syntax26.output b/test/yacc/err_syntax26.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax26.tab.c b/test/yacc/err_syntax26.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax26.tab.h b/test/yacc/err_syntax26.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax27.error b/test/yacc/err_syntax27.error new file mode 100644 index 00000000000..2a277087c35 --- /dev/null +++ b/test/yacc/err_syntax27.error @@ -0,0 +1 @@ +YACC: e - line 3 of "./err_syntax27.y", missing '}' diff --git a/test/yacc/err_syntax27.output b/test/yacc/err_syntax27.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax27.tab.c b/test/yacc/err_syntax27.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax27.tab.h b/test/yacc/err_syntax27.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax3.error b/test/yacc/err_syntax3.error new file mode 100644 index 00000000000..7e4871b87ad --- /dev/null +++ b/test/yacc/err_syntax3.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax3.y", unterminated string +%token '(' '*' '& + ^ diff --git a/test/yacc/err_syntax3.output b/test/yacc/err_syntax3.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax3.tab.c b/test/yacc/err_syntax3.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax3.tab.h b/test/yacc/err_syntax3.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax4.error b/test/yacc/err_syntax4.error new file mode 100644 index 00000000000..6a10d4040eb --- /dev/null +++ b/test/yacc/err_syntax4.error @@ -0,0 +1,3 @@ +YACC: e - line 1 of "./err_syntax4.y", unmatched %{ +%{ +^ diff --git a/test/yacc/err_syntax4.output b/test/yacc/err_syntax4.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax4.tab.c b/test/yacc/err_syntax4.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax4.tab.h b/test/yacc/err_syntax4.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax5.error b/test/yacc/err_syntax5.error new file mode 100644 index 00000000000..37a8500b053 --- /dev/null +++ b/test/yacc/err_syntax5.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax5.y", unterminated %union declaration +%union { +^ diff --git a/test/yacc/err_syntax5.output b/test/yacc/err_syntax5.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax5.tab.c b/test/yacc/err_syntax5.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax5.tab.h b/test/yacc/err_syntax5.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax6.error b/test/yacc/err_syntax6.error new file mode 100644 index 00000000000..bde624a7159 --- /dev/null +++ b/test/yacc/err_syntax6.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax6.y", illegal tag +%token '\777' + ^ diff --git a/test/yacc/err_syntax7.output b/test/yacc/err_syntax7.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax7.tab.c b/test/yacc/err_syntax7.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax7.tab.h b/test/yacc/err_syntax7.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax7a.error b/test/yacc/err_syntax7a.error new file mode 100644 index 00000000000..213711e11ff --- /dev/null +++ b/test/yacc/err_syntax7a.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax7a.y", illegal character +%token '\xfff' + ^ diff --git a/test/yacc/err_syntax7a.output b/test/yacc/err_syntax7a.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax7a.tab.c b/test/yacc/err_syntax7a.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax7a.tab.h b/test/yacc/err_syntax7a.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax7b.error b/test/yacc/err_syntax7b.error new file mode 100644 index 00000000000..19b617ccca1 --- /dev/null +++ b/test/yacc/err_syntax7b.error @@ -0,0 +1,3 @@ +YACC: e - line 6 of "./err_syntax7b.y", illegal character +%token '\x.' + ^ diff --git a/test/yacc/err_syntax7b.output b/test/yacc/err_syntax7b.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax7b.tab.c b/test/yacc/err_syntax7b.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax7b.tab.h b/test/yacc/err_syntax7b.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax8.error b/test/yacc/err_syntax8.error new file mode 100644 index 00000000000..c6a4cc943fa --- /dev/null +++ b/test/yacc/err_syntax8.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./err_syntax8.y", illegal use of reserved symbol . diff --git a/test/yacc/err_syntax8.output b/test/yacc/err_syntax8.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax8.tab.c b/test/yacc/err_syntax8.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax8.tab.h b/test/yacc/err_syntax8.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax8a.error b/test/yacc/err_syntax8a.error new file mode 100644 index 00000000000..ed503e90451 --- /dev/null +++ b/test/yacc/err_syntax8a.error @@ -0,0 +1 @@ +YACC: e - line 6 of "./err_syntax8a.y", illegal use of reserved symbol $$123 diff --git a/test/yacc/err_syntax8a.output b/test/yacc/err_syntax8a.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax8a.tab.c b/test/yacc/err_syntax8a.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax8a.tab.h b/test/yacc/err_syntax8a.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax9.error b/test/yacc/err_syntax9.error new file mode 100644 index 00000000000..1f74b7ea0a2 --- /dev/null +++ b/test/yacc/err_syntax9.error @@ -0,0 +1 @@ +YACC: e - line 7 of "./err_syntax9.y", the start symbol text cannot be declared to be a token diff --git a/test/yacc/err_syntax9.output b/test/yacc/err_syntax9.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/err_syntax9.tab.c b/test/yacc/err_syntax9.tab.c new file mode 100644 index 00000000000..f0d4d2c7b6a --- /dev/null +++ b/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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 diff --git a/test/yacc/err_syntax9.tab.h b/test/yacc/err_syntax9.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/error.error b/test/yacc/error.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/error.output b/test/yacc/error.output new file mode 100644 index 00000000000..0c4db6225e2 --- /dev/null +++ b/test/yacc/error.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/test/yacc/error.tab.c b/test/yacc/error.tab.c new file mode 100644 index 00000000000..f21fa7dd854 --- /dev/null +++ b/test/yacc/error.tab.c @@ -0,0 +1,505 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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_" + +#define YYPURE 0 + +#line 2 "error.y" +int yylex(void); +static void yyerror(const char *); +#line 104 "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 int 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_dgoto[] = { 2, +}; +static const YYINT error_sindex[] = { -256, + 0, 0, +}; +static const YYINT error_rindex[] = { 0, + 0, 0, +}; +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-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 error_rule[] = { +"$accept : S", +"S : error", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 251 "error.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/error.tab.h b/test/yacc/error.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/expr.oxout.error b/test/yacc/expr.oxout.error new file mode 100644 index 00000000000..58fdb1c267f --- /dev/null +++ b/test/yacc/expr.oxout.error @@ -0,0 +1 @@ +YACC: w - line 6 of "expr.Y", the precedence of '*' has been redeclared diff --git a/test/yacc/expr.oxout.output b/test/yacc/expr.oxout.output new file mode 100644 index 00000000000..bfd433c03c7 --- /dev/null +++ b/test/yacc/expr.oxout.output @@ -0,0 +1,209 @@ + 0 $accept : yyyAugNonterm $end + + 1 $$1 : + + 2 yyyAugNonterm : $$1 s + + 3 s : expr + + 4 expr : expr '*' expr + 5 | expr '+' expr + 6 | expr '/' expr + 7 | expr '-' expr + 8 | '(' expr ')' + 9 | ID + 10 | CONST + +state 0 + $accept : . yyyAugNonterm $end (0) + $$1 : . (1) + + . reduce 1 + + yyyAugNonterm goto 1 + $$1 goto 2 + + +state 1 + $accept : yyyAugNonterm . $end (0) + + $end accept + + +state 2 + yyyAugNonterm : $$1 . s (2) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + s goto 6 + expr goto 7 + + +state 3 + expr : ID . (9) + + . reduce 9 + + +state 4 + expr : CONST . (10) + + . reduce 10 + + +state 5 + expr : '(' . expr ')' (8) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 8 + + +state 6 + yyyAugNonterm : $$1 s . (2) + + . reduce 2 + + +state 7 + s : expr . (3) + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + + '+' shift 9 + '-' shift 10 + '*' shift 11 + '/' shift 12 + $end reduce 3 + + +state 8 + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + expr : '(' expr . ')' (8) + + '+' shift 9 + '-' shift 10 + '*' shift 11 + '/' shift 12 + ')' shift 13 + . error + + +state 9 + expr : expr '+' . expr (5) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 14 + + +state 10 + expr : expr '-' . expr (7) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 15 + + +state 11 + expr : expr '*' . expr (4) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 16 + + +state 12 + expr : expr '/' . expr (6) + + ID shift 3 + CONST shift 4 + '(' shift 5 + . error + + expr goto 17 + + +state 13 + expr : '(' expr ')' . (8) + + . reduce 8 + + +state 14 + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr '+' expr . (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + + '*' shift 11 + '/' shift 12 + $end reduce 5 + '+' reduce 5 + '-' reduce 5 + ')' reduce 5 + + +state 15 + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + expr : expr '-' expr . (7) + + '*' shift 11 + '/' shift 12 + $end reduce 7 + '+' reduce 7 + '-' reduce 7 + ')' reduce 7 + + +state 16 + expr : expr . '*' expr (4) + expr : expr '*' expr . (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr . '-' expr (7) + + . reduce 4 + + +state 17 + expr : expr . '*' expr (4) + expr : expr . '+' expr (5) + expr : expr . '/' expr (6) + expr : expr '/' expr . (6) + expr : expr . '-' expr (7) + + '*' shift 11 + $end reduce 6 + '+' reduce 6 + '-' reduce 6 + '/' reduce 6 + ')' reduce 6 + + +10 terminals, 5 nonterminals +11 grammar rules, 18 states diff --git a/test/yacc/expr.oxout.tab.c b/test/yacc/expr.oxout.tab.c new file mode 100644 index 00000000000..af45682f868 --- /dev/null +++ b/test/yacc/expr.oxout.tab.c @@ -0,0 +1,1970 @@ +/* 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 2 +#define YYMINOR 0 +#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 expr_oxout_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex expr_oxout_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror expr_oxout_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar expr_oxout_char +#endif /* yychar */ + +#ifndef yyval +#define yyval expr_oxout_val +#endif /* yyval */ + +#ifndef yylval +#define yylval expr_oxout_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug expr_oxout_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs expr_oxout_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag expr_oxout_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs expr_oxout_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen expr_oxout_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred expr_oxout_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto expr_oxout_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex expr_oxout_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex expr_oxout_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex expr_oxout_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable expr_oxout_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck expr_oxout_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname expr_oxout_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule expr_oxout_rule +#endif /* yyrule */ +#define YYPREFIX "expr_oxout_" + +#define YYPURE 0 + +#line 5 "expr.oxout.y" +#include +#include +#line 8 "expr.Y" + +#include "expr.oxout.h" +#include + +extern int yylex(void); +extern void yyerror(const char *); +#line 27 "expr.oxout.y" +#include +#define yyyR USHRT_MAX +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 31 "expr.oxout.y" +typedef union YYSTYPE { +struct yyyOxAttrbs { +struct yyyStackItem *yyyOxStackItem; +} yyyOxAttrbs; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +#line 38 "expr.oxout.y" +#include +#include + +static int yyyYok = 1; + +extern yyyFT yyyRCIL[]; + +void yyyExecuteRRsection(yyyGNT *rootNode); +void yyyYoxInit(void); +void yyyDecorate(void); +struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ +void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); +void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); +void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); +void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); +void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); +void yyyabort(void); + +#line 146 "expr.oxout.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 ID 257 +#define CONST 258 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT expr_oxout_lhs[] = { -1, + 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, +}; +static const YYINT expr_oxout_len[] = { 2, + 0, 2, 1, 3, 3, 3, 3, 3, 1, 1, +}; +static const YYINT expr_oxout_defred[] = { 1, + 0, 0, 9, 10, 0, 2, 0, 0, 0, 0, + 0, 0, 8, 0, 0, 4, 0, +}; +static const YYINT expr_oxout_dgoto[] = { 1, + 6, 2, 7, +}; +static const YYINT expr_oxout_sindex[] = { 0, + 0, -40, 0, 0, -40, 0, -18, -24, -40, -40, + -40, -40, 0, -37, -37, 0, -39, +}; +static const YYINT expr_oxout_rindex[] = { 0, + 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, + 0, 0, 0, 2, 8, 0, 1, +}; +static const YYINT expr_oxout_gindex[] = { 0, + 0, 0, 4, +}; +#define YYTABLESIZE 218 +static const YYINT expr_oxout_table[] = { 5, + 6, 5, 11, 0, 11, 3, 0, 7, 8, 12, + 0, 0, 14, 15, 16, 17, 13, 11, 9, 0, + 10, 0, 12, 11, 9, 0, 10, 0, 12, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 6, 5, 6, 5, 6, 5, 6, 7, 0, + 7, 0, 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, 4, +}; +static const YYINT expr_oxout_check[] = { 40, + 0, 0, 42, -1, 42, 0, -1, 0, 5, 47, + -1, -1, 9, 10, 11, 12, 41, 42, 43, -1, + 45, -1, 47, 42, 43, -1, 45, -1, 47, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 41, 41, 43, 43, 45, 45, 47, 41, -1, + 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 258 +#define YYUNDFTOKEN 264 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const expr_oxout_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,"ID", +"CONST",0,0,0,0,0,"illegal-symbol", +}; +static const char *const expr_oxout_rule[] = { +"$accept : yyyAugNonterm", +"$$1 :", +"yyyAugNonterm : $$1 s", +"s : expr", +"expr : expr '*' expr", +"expr : expr '+' expr", +"expr : expr '/' expr", +"expr : expr '-' expr", +"expr : '(' expr ')'", +"expr : ID", +"expr : CONST", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 53 "expr.Y" + + +int yyparse(void); + +int main() + {yyparse(); + } + + + +#line 138 "expr.oxout.y" +long yyySSALspaceSize = 20000; +long yyyRSmaxSize = 1000; +long yyyTravStackMaxSize = 2000; + +struct yyySolvedSAlistCell {yyyWAT attrbNum; + long next; + }; + +#define yyyLambdaSSAL 0 +long yyySSALCfreeList = yyyLambdaSSAL; +long yyyNewSSALC = 1; + +struct yyySolvedSAlistCell *yyySSALspace; + +long yyyNbytesStackStg; + + + +yyyFT yyyRCIL[1]; + +short yyyIIIEL[] = {0, +0,2,6,10,14,18,22,24, +}; + +long yyyIIEL[] = { +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,1, +}; + +long yyyIEL[] = { +0,0,0, +}; + +yyyFT yyyEntL[1]; + +void yyyfatal(char *msg) +{fputs(msg,stderr);exit(-1);} + + + +#define yyySSALof 'S' +#define yyyRSof 'q' +#define yyyTSof 't' + + + +void yyyHandleOverflow(char which) + {char *msg1 = "?", *msg2; + long oldSize = 0, newSize; + switch(which) + { + case yyySSALof : + msg1 = "SSAL overflow: "; + oldSize = yyySSALspaceSize; + break; + case yyyRSof : + msg1 = "ready set overflow: "; + oldSize = yyyRSmaxSize; + break; + case yyyTSof : + msg1 = "traversal stack overflow: "; + oldSize = yyyTravStackMaxSize; + break; + default :; + } + newSize = (3*oldSize)/2; + if (newSize < 100) newSize = 100; + fputs(msg1,stderr); + fprintf(stderr,"size was %ld.\n",oldSize); + msg2 = " Have to modify evaluator: -Y%c%ld.\n"; + fprintf(stderr,msg2,which,newSize); + exit(-1); + } + + + +void yyySignalEnts(yyyGNT *node,long startP,long stopP) + {yyyGNT *dumNode; + + while (startP < stopP) + { + if (!yyyEntL[startP]) dumNode = node; + else dumNode = (node->cL)[yyyEntL[startP]-1]; + if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] + ) + ) + ) + { + if (++yyyRSTop == yyyAfterRS) + {yyyHandleOverflow(yyyRSof); + break; + } + yyyRSTop->node = dumNode; + yyyRSTop->whichSym = yyyEntL[startP]; + yyyRSTop->wa = yyyEntL[startP+1]; + } + startP += 2; + } + } + + + + + + +void yyySolveAndSignal() { +long yyyiDum,*yyypL; +int yyyws,yyywa; +yyyGNT *yyyRSTopN,*yyyRefN; +yyyParent yyyRSTopNp; + + +yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; +yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; +yyywa = yyyRSTop->wa; +yyyRSTop--; +switch(yyyRefN->prodNum) { +case 1: /***yacc rule 1***/ + switch (yyyws) { + } +break; +case 2: /***yacc rule 2***/ + switch (yyyws) { + } +break; +case 3: /***yacc rule 3***/ + switch (yyyws) { + } +break; +case 4: /***yacc rule 4***/ + switch (yyyws) { + } +break; +case 5: /***yacc rule 5***/ + switch (yyyws) { + } +break; +case 6: /***yacc rule 6***/ + switch (yyyws) { + } +break; +case 7: /***yacc rule 7***/ + switch (yyyws) { + case 1: /**/ + switch (yyywa) { + } + break; + } +break; +case 8: /***yacc rule 8***/ + switch (yyyws) { + case 1: /**/ + switch (yyywa) { + } + break; + } +break; +} /* switch */ + +if (yyyws) /* the just-solved instance was inherited. */ + {if (yyyRSTopN->prodNum) + {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; + yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], + yyyIEL[yyyiDum+1] + ); + } + } + else /* the just-solved instance was synthesized. */ + {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ + {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + + yyyRSTopN->whichSym + ] + + yyywa; + yyySignalEnts(yyyRSTopNp.noderef, + yyyIEL[yyyiDum], + yyyIEL[yyyiDum+1] + ); + } + else /* node is still on the stack--it has no parent yet. */ + {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); + if (yyySSALCfreeList == yyyLambdaSSAL) + {yyySSALspace[yyyNewSSALC].next = *yyypL; + if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) + yyyHandleOverflow(yyySSALof); + } + else + {yyyiDum = yyySSALCfreeList; + yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; + yyySSALspace[yyyiDum].next = *yyypL; + *yyypL = yyyiDum; + } + yyySSALspace[*yyypL].attrbNum = yyywa; + } + } + +} /* yyySolveAndSignal */ + + + + + + +#define condStg unsigned int conds; +#define yyyClearConds {yyyTST->conds = 0;} +#define yyySetCond(n) {yyyTST->conds += (1<<(n));} +#define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) + + + +struct yyyTravStackItem {yyyGNT *node; + char isReady; + condStg + }; + + + +void yyyDoTraversals(yyyGNT *rootNode) +{struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; + yyyGNT *yyyTSTn,**yyyCLptr2; + int yyyi,yyyRL,yyyPass; + int i; + + if (!yyyYok) return; + if ((yyyTravStack = + ((struct yyyTravStackItem *) + calloc((size_t)yyyTravStackMaxSize, + (size_t)sizeof(struct yyyTravStackItem) + ) + ) + ) + == + (struct yyyTravStackItem *)NULL + ) + {fputs("malloc error in traversal stack allocation\n",stderr); + exit(-1); + } + +yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; +yyyTravStack++; + + +for (yyyi=0; yyyi<2; yyyi++) { +yyyTST = yyyTravStack; +yyyTST->node = rootNode; +yyyTST->isReady = 0; +yyyClearConds + +while(yyyTST >= yyyTravStack) + {yyyTSTn = yyyTST->node; + if (yyyTST->isReady) + {yyyPass = 1; + goto yyyTravSwitch; +yyyTpop: + yyyTST--; + } + else + {yyyPass = 0; + goto yyyTravSwitch; +yyyTpush: + yyyTST->isReady = 1; + if (yyyTSTn->prodNum) + {if (yyyRL) + {yyyCLptr2 = yyyTSTn->cL; + i = yyyTSTn->cLlen; + while (i--) + {if (++yyyTST == yyyAfterTravStack) + yyyHandleOverflow(yyyTSof); + else + {yyyTST->node = *yyyCLptr2; + yyyTST->isReady = 0; + yyyClearConds + } + yyyCLptr2++; + } + } /* right to left */ + else /* left to right */ + {i = yyyTSTn->cLlen; + yyyCLptr2 = yyyTSTn->cL + i; + while (i--) + {yyyCLptr2--; + if (++yyyTST == yyyAfterTravStack) + yyyHandleOverflow(yyyTSof); + else + {yyyTST->node = *yyyCLptr2; + yyyTST->isReady = 0; + yyyClearConds + } + } + } /* left to right */ + } + } /* else */ + continue; +yyyTravSwitch: + switch(yyyTSTn->prodNum) { +case 1: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + +if (! +#line 24 "expr.Y" + (1) +#line 444 "expr.oxout.y" +) yyySetCond(1) +yyySetCond(2) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 24 "expr.Y" + +#line 453 "expr.oxout.y" +} +if (yyyCond(1) != yyyPass) { +#line 24 "expr.Y" + printf("\n"); + +#line 459 "expr.oxout.y" +} +if (yyyCond(2) != yyyPass) { +#line 25 "expr.Y" + printf("prefix: "); + +#line 465 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; +if ( +#line 23 "expr.Y" + (1) +#line 477 "expr.oxout.y" +) yyySetCond(2) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 22 "expr.Y" + printf("\n"); + +#line 486 "expr.oxout.y" +} +if (yyyCond(1) != yyyPass) { +#line 23 "expr.Y" + +#line 491 "expr.oxout.y" +} +if (yyyCond(2) != yyyPass) { +#line 23 "expr.Y" + printf("postfix: "); + +#line 497 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 2: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 29 "expr.Y" + printf(" * "); + +#line 518 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 28 "expr.Y" + printf(" * "); + +#line 533 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 3: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 32 "expr.Y" + printf(" + "); + +#line 554 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 33 "expr.Y" + printf(" + "); + +#line 569 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 4: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 37 "expr.Y" + printf(" / "); + +#line 590 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 36 "expr.Y" + printf(" / "); + +#line 605 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 5: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 41 "expr.Y" + printf(" - "); + +#line 626 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 40 "expr.Y" + printf(" - "); + +#line 641 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 6: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + + break; + } + break; + } + +break; +case 7: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 46 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 685 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 45 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 700 "expr.oxout.y" +} + break; + } + break; + } + +break; +case 8: + switch(yyyi) { + case 0: + switch(yyyPass) { + case 0: +yyyRL = 0;yyySetCond(0) + + case 1: + +if (yyyCond(0) != yyyPass) { +#line 50 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 721 "expr.oxout.y" +} + break; + } + break; + case 1: + switch(yyyPass) { + case 0: +yyyRL = 0; + case 1: + +if (yyyCond(0) != yyyPass) { +#line 49 "expr.Y" + printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); + +#line 736 "expr.oxout.y" +} + break; + } + break; + } + +break; + } /* switch */ + if (yyyPass) goto yyyTpop; else goto yyyTpush; + } /* while */ + } /* for */ +} /* yyyDoTraversals */ + +void yyyExecuteRRsection(yyyGNT *rootNode) { + int yyyi; + long cycleSum = 0; + long nNZrc = 0; + + if (!yyyYok) return; + yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); + if (nNZrc) + { + fputs("\n\n\n**********\n",stderr); + fputs("cycle detected in completed parse tree",stderr); + fputs(" after decoration.\n",stderr); +#if CYCLE_VERBOSE + fprintf(stderr, + "number of unsolved attribute instances == %ld.\n", + nNZrc + ); + fprintf(stderr, + "total number of remaining dependencies == %ld.\n", + cycleSum + ); + fputs("average number of remaining dependencies\n",stderr); + fprintf(stderr," per unsolved instance == %f.\n", + ((float)(cycleSum)/(float)(nNZrc)) + ); +#endif + fprintf(stderr, + "searching parse tree for %ld unsolved instances:\n", + nNZrc + ); + yyyUnsolvedInstSearchTravAux(rootNode); + } + yyyDoTraversals(rootNode); +} /* yyyExecuteRRsection */ + + + +yyyWAT yyyLRCIL[2] = {0,0, +}; + + + +void yyyYoxInit(void) + { + static int yyyInitDone = 0; + if (yyyInitDone) return; + + if ((yyyRS = (yyyRSitem *) + calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(yyyRSitem)) + ) + == + ((yyyRSitem *) NULL) + ) + yyyfatal("malloc error in ox ready set space allocation\n"); + yyyRS++; + yyyAfterRS = yyyRS + yyyRSmaxSize; + + + if ((yyySSALspace = (struct yyySolvedSAlistCell *) + calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) + ) + == + ((struct yyySolvedSAlistCell *) NULL) + ) + yyyfatal("malloc error in stack solved list space allocation\n"); + yyyInitDone = 1; + + yyyRSTop = yyyRS - 1; + } /* yyyYoxInit */ + + + +void yyyDecorate(void) + { + while (yyyRSTop >= yyyRS) + yyySolveAndSignal(); + } + + + +void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) + {yyyWST i; + yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; + yyyGNT *gnpDum; + va_list ap; + + *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); + if (*yyyOxStackItem == (yyySIT *) NULL) + yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); + (*yyyOxStackItem)->node = + (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); + if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) + yyyfatal("malloc error in ox node space allocation\n"); + (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; + (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; + (*yyyOxStackItem)->node->parentIsStack = 1; + (*yyyOxStackItem)->node->cLlen = yyyRHSlength; + (*yyyOxStackItem)->node->cL = + (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); + if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) + yyyfatal("malloc error in ox child list space allocation\n"); + (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; + (*yyyOxStackItem)->node->refCountList = + (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); + if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) + yyyfatal("malloc error in ox reference count list space allocation\n"); + (*yyyOxStackItem)->node->prodNum = (int) yyyProdNum; + va_start(ap, yyval_OxAttrbs); + for (i=1;i<=yyyRHSlength;i++) + {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; + gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; + gnpDum->whichSym = i; + gnpDum->parent.noderef = (*yyyOxStackItem)->node; + gnpDum->parentIsStack = 0; + } + va_end(ap); + } + + + +#define yyyDECORfREQ 50 + + + +void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) + {yyyWST i; + yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; + long SSALptr,SSALptrHead,*cPtrPtr; + long *pL; + yyyGNT *gnpDum; + long iTemp; + long nextP; + static unsigned short intNodeCount = yyyDECORfREQ; + va_list ap; + + nextP = startP; + while (nextP < stopP) + {if (yyyRCIL[nextP] == yyyR) + {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; + } + else + {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; + } + nextP += 3; + } + pL = yyyIIEL + yyyIIIEL[yyyProdNum]; + va_start(ap, yyval_OxAttrbs); + for (i=1;i<=yyyRHSlength;i++) + {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; + pL++; + SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); + if (SSALptr != yyyLambdaSSAL) + {*cPtrPtr = yyyLambdaSSAL; + do + { + iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); + yyySignalEnts(yyyOxStackItem->node, + yyyIEL[iTemp], + yyyIEL[iTemp+1] + ); + SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); + } + while (SSALptr != yyyLambdaSSAL); + *cPtrPtr = yyySSALCfreeList; + yyySSALCfreeList = SSALptrHead; + } + } + va_end(ap); + nextP = startP + 2; + while (nextP < stopP) + {if (!yyyRCIL[nextP]) + {if (yyyRCIL[nextP-2] == yyyR) + {pL = &(yyyOxStackItem->solvedSAlist); + if (yyySSALCfreeList == yyyLambdaSSAL) + {yyySSALspace[yyyNewSSALC].next = *pL; + if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) + yyyHandleOverflow(yyySSALof); + } + else + {iTemp = yyySSALCfreeList; + yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; + yyySSALspace[iTemp].next = *pL; + *pL = iTemp; + } + yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; + } + else + {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) + { + iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; + yyySignalEnts(gnpDum, + yyyIEL[iTemp], + yyyIEL[iTemp+1] + ); + } + } + } + nextP += 3; + } + if (!--intNodeCount) + {intNodeCount = yyyDECORfREQ; + yyyDecorate(); + } + } + + + +void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *mylval) + {yyyRCT *rcPdum; + yyySIT **yyyOxStackItem = &mylval->yyyOxAttrbs.yyyOxStackItem; + (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); + if ((*yyyOxStackItem) == (yyySIT *) NULL) + yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); + (*yyyOxStackItem)->node = + (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) + ; + if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) + yyyfatal("malloc error in ox node space allocation\n"); + (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; + (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; + (*yyyOxStackItem)->node->parentIsStack = 1; + (*yyyOxStackItem)->node->cLlen = 0; + (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; + (*yyyOxStackItem)->node->refCountListLen = nAttrbs; + rcPdum = (*yyyOxStackItem)->node->refCountList = + (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); + if (rcPdum == (yyyRCT *) NULL) + yyyfatal("malloc error in ox reference count list space allocation\n"); + while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; + (*yyyOxStackItem)->node->prodNum = 0; + (*yyyOxStackItem)->node->whichSym = 0; + } + + + +void yyyabort(void) + {yyyYok = 0; + } + + + + + +#define yyyLastProdNum 8 + + +#define yyyNsorts 1 + + +int yyyProdsInd[] = { + 0, + 0, 2, 6, 10, 14, 18, 22, 24, + 26, +}; + + +int yyyProds[][2] = { +{ 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, +{ 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, +{ 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, +{ 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, +{ 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, +{ 567, 1}, +}; + + +int yyySortsInd[] = { + 0, + 0, + 1, +}; + + +int yyySorts[] = { + 413, +}; + + + +char *yyyStringTab[] = { +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"s",0,0,0, +0,0,"y",0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"LRpre",0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"'('",0,0,0, +0,0,0,0,"')'", +0,0,0,0,0, +0,0,"'*'","lexeme",0, +0,0,0,0,0, +"'+'",0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"'-'",0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,"'/'",0,0, +0,0,0,0,0, +0,0,"expr",0,0, +0,0,0,0,0, +0,0,0,0,0, +0,"printf",0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,"CONST","LRpost",0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,"ID", +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0,0,0,0,0, +0, +}; + + + +#define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) + +#define yyyGSoccurStr(prodNum,symPos) \ + (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) + +#define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) + +#define yyySortOf(prodNum,symPos) \ + (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) + +#define yyyAttrbStr(prodNum,symPos,attrbNum) \ + (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ + (attrbNum) \ + ] \ + ] \ + ) + + + +void yyyShowProd(int i) + {int j,nSyms; + + nSyms = yyySizeofProd(i); + for (j=0; j\n",stderr); + else + putc('\n',stderr); + } + } + } + + + +void yyyCheckNodeInstancesSolved(yyyGNT *np) + {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; + int nUnsolvedInsts = 0; + + if (np->prodNum != 0) + {inTerminalNode = 0; + prodNum = np->prodNum; + symPos = 0; + } + else + {inTerminalNode = 1; + prodNum = np->parent.noderef->prodNum; + symPos = np->whichSym; + } + mysort = yyySortOf(prodNum,symPos); + sortSize = yyySizeofSort(mysort); + for (i=0; irefCountList)[i] != 0) nUnsolvedInsts += 1; + if (nUnsolvedInsts) + {fprintf(stderr, + "\nFound node that has %d unsolved attribute instance(s).\n", + nUnsolvedInsts + ); + fprintf(stderr,"Node is labeled \"%s\".\n", + yyyGSoccurStr(prodNum,symPos)); + if (inTerminalNode) + {fputs("Node is terminal. Its parent production is:\n ",stderr); + yyyShowProd(prodNum); + } + else + {fputs("Node is nonterminal. ",stderr); + if (!(np->parentIsStack)) + {fprintf(stderr, + "Node is %dth child in its parent production:\n ", + np->whichSym + ); + yyyShowProd(np->parent.noderef->prodNum); + } + fputs("Node is on left hand side of this production:\n ",stderr); + yyyShowProd(np->prodNum); + } + fputs("The following instances are unsolved:\n",stderr); + for (i=0; irefCountList)[i] != 0) + fprintf(stderr," %-16s still has %1d dependencies.\n", + yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); + } + } + + + +void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) + {yyyGNT **yyyCLpdum; + yyyRCT *rcp; + int i; + + /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ + rcp = pNode->refCountList; + i = pNode->refCountListLen; + while (i--) + if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} + yyyCLpdum = pNode->cL; + i = pNode->cLlen; + while (i--) + { + yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); + yyyCLpdum++; + } + } + + + +void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) + {yyyGNT **yyyCLpdum; + int i; + + yyyCheckNodeInstancesSolved(pNode); + yyyCLpdum = pNode->cL; + i = pNode->cLlen; + while (i--) + { + yyyUnsolvedInstSearchTravAux(*yyyCLpdum); + yyyCLpdum++; + } + } + + + +void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) + {yyyGNT **yyyCLpdum; + int i; + + yyyCLpdum = pNode->cL; + i = pNode->cLlen; + while (i--) + { + yyyUnsolvedInstSearchTravAux(*yyyCLpdum); + yyyCLpdum++; + } + } + + + +#line 1647 "expr.oxout.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 1: +#line 64 "expr.oxout.y" + {yyyYoxInit();} +#line 1849 "expr.oxout.tab.c" +break; +case 2: +#line 66 "expr.oxout.y" + { + yyyDecorate(); yyyExecuteRRsection(yystack.l_mark[0].yyyOxAttrbs.yyyOxStackItem->node); + } +#line 1856 "expr.oxout.tab.c" +break; +case 3: +#line 73 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(1,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(1,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 1863 "expr.oxout.tab.c" +break; +case 4: +#line 80 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(2,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(2,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 1870 "expr.oxout.tab.c" +break; +case 5: +#line 87 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(3,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(3,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 1877 "expr.oxout.tab.c" +break; +case 6: +#line 94 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(4,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(4,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 1884 "expr.oxout.tab.c" +break; +case 7: +#line 101 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(5,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(5,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 1891 "expr.oxout.tab.c" +break; +case 8: +#line 108 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(6,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(6,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 1898 "expr.oxout.tab.c" +break; +case 9: +#line 114 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(7,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(7,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 1905 "expr.oxout.tab.c" +break; +case 10: +#line 121 "expr.oxout.y" + {if(yyyYok){ +yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); +yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} +#line 1912 "expr.oxout.tab.c" +break; +#line 1914 "expr.oxout.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/expr.oxout.tab.h b/test/yacc/expr.oxout.tab.h new file mode 100644 index 00000000000..03527bb036a --- /dev/null +++ b/test/yacc/expr.oxout.tab.h @@ -0,0 +1,15 @@ +#define ID 257 +#define CONST 258 +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +typedef union YYSTYPE { +struct yyyOxAttrbs { +struct yyyStackItem *yyyOxStackItem; +} yyyOxAttrbs; +} YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ +extern YYSTYPE expr_oxout_lval; diff --git a/test/yacc/grammar.dot b/test/yacc/grammar.dot new file mode 100644 index 00000000000..1988e12ddd6 --- /dev/null +++ b/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/test/yacc/grammar.error b/test/yacc/grammar.error new file mode 100644 index 00000000000..d442f8abaeb --- /dev/null +++ b/test/yacc/grammar.error @@ -0,0 +1 @@ +YACC: 1 shift/reduce conflict, 29 reduce/reduce conflicts. diff --git a/test/yacc/grammar.output b/test/yacc/grammar.output new file mode 100644 index 00000000000..6351322345b --- /dev/null +++ b/test/yacc/grammar.output @@ -0,0 +1,2214 @@ + 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 diff --git a/test/yacc/grammar.tab.c b/test/yacc/grammar.tab.c new file mode 100644 index 00000000000..90136eca0db --- /dev/null +++ b/test/yacc/grammar.tab.c @@ -0,0 +1,2106 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 +#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3) + +/* 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 389 "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 int 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_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, +}; +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-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, +"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",0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,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 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 1015 "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 occurrences 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 1095 "grammar.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 10: +#line 378 "grammar.y" + { + yyerrok; + } +#line 1299 "grammar.tab.c" +break; +case 11: +#line 382 "grammar.y" + { + yyerrok; + } +#line 1306 "grammar.tab.c" +break; +case 13: +#line 393 "grammar.y" + { + /* Provide an empty action here so bison will not complain about + * incompatible types in the default action it normally would + * have generated. + */ + } +#line 1316 "grammar.tab.c" +break; +case 14: +#line 400 "grammar.y" + { + /* empty */ + } +#line 1323 "grammar.tab.c" +break; +case 15: +#line 407 "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(); + } +#line 1337 "grammar.tab.c" +break; +case 16: +#line 418 "grammar.y" + { + if (func_params != NULL) { + set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); + } 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(); + } +#line 1354 "grammar.tab.c" +break; +case 17: +#line 432 "grammar.y" + { + cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags; + free_decl_spec(&yystack.l_mark[0].decl_spec); + } +#line 1362 "grammar.tab.c" +break; +case 18: +#line 437 "grammar.y" + { + end_typedef(); + } +#line 1369 "grammar.tab.c" +break; +case 19: +#line 444 "grammar.y" + { + begin_typedef(); + } +#line 1376 "grammar.tab.c" +break; +case 20: +#line 448 "grammar.y" + { + begin_typedef(); + } +#line 1383 "grammar.tab.c" +break; +case 23: +#line 460 "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); + } +#line 1398 "grammar.tab.c" +break; +case 24: +#line 472 "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); + } +#line 1410 "grammar.tab.c" +break; +case 25: +#line 484 "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; + } +#line 1424 "grammar.tab.c" +break; +case 26: +#line 495 "grammar.y" + { + /* If we're converting to K&R and we've got a nominally K&R + * function which has a parameter which is ANSI (i.e., a prototyped + * 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); + } +#line 1451 "grammar.tab.c" +break; +case 28: +#line 520 "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; + } +#line 1464 "grammar.tab.c" +break; +case 29: +#line 530 "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); + } +#line 1483 "grammar.tab.c" +break; +case 36: +#line 561 "grammar.y" + { + join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec); + free(yystack.l_mark[-1].decl_spec.text); + free(yystack.l_mark[0].decl_spec.text); + } +#line 1492 "grammar.tab.c" +break; +case 40: +#line 576 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1499 "grammar.tab.c" +break; +case 41: +#line 580 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN); + } +#line 1506 "grammar.tab.c" +break; +case 42: +#line 584 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1513 "grammar.tab.c" +break; +case 43: +#line 588 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC); + } +#line 1520 "grammar.tab.c" +break; +case 44: +#line 592 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE); + } +#line 1527 "grammar.tab.c" +break; +case 45: +#line 596 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK); + } +#line 1534 "grammar.tab.c" +break; +case 46: +#line 603 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); + } +#line 1541 "grammar.tab.c" +break; +case 47: +#line 607 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1548 "grammar.tab.c" +break; +case 48: +#line 611 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT); + } +#line 1555 "grammar.tab.c" +break; +case 49: +#line 615 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1562 "grammar.tab.c" +break; +case 50: +#line 619 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1569 "grammar.tab.c" +break; +case 51: +#line 623 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT); + } +#line 1576 "grammar.tab.c" +break; +case 52: +#line 627 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1583 "grammar.tab.c" +break; +case 53: +#line 631 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1590 "grammar.tab.c" +break; +case 54: +#line 635 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1597 "grammar.tab.c" +break; +case 55: +#line 639 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); + } +#line 1604 "grammar.tab.c" +break; +case 56: +#line 643 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1611 "grammar.tab.c" +break; +case 57: +#line 647 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1618 "grammar.tab.c" +break; +case 58: +#line 651 "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); + } +#line 1628 "grammar.tab.c" +break; +case 61: +#line 663 "grammar.y" + { + new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); + } +#line 1635 "grammar.tab.c" +break; +case 62: +#line 667 "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); + } +#line 1648 "grammar.tab.c" +break; +case 63: +#line 680 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-2].text.text, TEXT_LEN, yystack.l_mark[-1].text.text); + new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); + } +#line 1658 "grammar.tab.c" +break; +case 64: +#line 687 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); + new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); + } +#line 1668 "grammar.tab.c" +break; +case 65: +#line 694 "grammar.y" + { + (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); + new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); + } +#line 1676 "grammar.tab.c" +break; +case 66: +#line 702 "grammar.y" + { + imply_typedef(yyval.text.text); + } +#line 1683 "grammar.tab.c" +break; +case 67: +#line 706 "grammar.y" + { + imply_typedef(yyval.text.text); + } +#line 1690 "grammar.tab.c" +break; +case 68: +#line 713 "grammar.y" + { + new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator); + } +#line 1697 "grammar.tab.c" +break; +case 69: +#line 717 "grammar.y" + { + add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator); + } +#line 1704 "grammar.tab.c" +break; +case 70: +#line 724 "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; + } +#line 1716 "grammar.tab.c" +break; +case 71: +#line 733 "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); + } + } +#line 1727 "grammar.tab.c" +break; +case 73: +#line 745 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, yystack.l_mark[-1].text.text); + new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); + } +#line 1737 "grammar.tab.c" +break; +case 74: +#line 752 "grammar.y" + { + char *s; + if ((s = implied_typedef()) == 0) + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); + new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); + } +#line 1747 "grammar.tab.c" +break; +case 75: +#line 759 "grammar.y" + { + (void)sprintf(buf, "enum %.*s", TEXT_LEN, yystack.l_mark[0].text.text); + new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); + } +#line 1755 "grammar.tab.c" +break; +case 76: +#line 767 "grammar.y" + { + imply_typedef("enum"); + yyval.text = yystack.l_mark[0].text; + } +#line 1763 "grammar.tab.c" +break; +case 79: +#line 780 "grammar.y" + { + yyval.declarator = yystack.l_mark[0].declarator; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + yyval.declarator->begin = yystack.l_mark[-1].text.begin; + yyval.declarator->pointer = TRUE; + } +#line 1775 "grammar.tab.c" +break; +case 81: +#line 793 "grammar.y" + { + yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin); + } +#line 1782 "grammar.tab.c" +break; +case 82: +#line 797 "grammar.y" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + yyval.declarator->begin = yystack.l_mark[-2].text.begin; + } +#line 1793 "grammar.tab.c" +break; +case 83: +#line 805 "grammar.y" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + } +#line 1803 "grammar.tab.c" +break; +case 84: +#line 812 "grammar.y" + { + yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); + yyval.declarator->params = yystack.l_mark[-1].param_list; + 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; + } +#line 1814 "grammar.tab.c" +break; +case 85: +#line 820 "grammar.y" + { + yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); + yyval.declarator->params = yystack.l_mark[-1].param_list; + 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; + } +#line 1825 "grammar.tab.c" +break; +case 86: +#line 831 "grammar.y" + { + (void)sprintf(yyval.text.text, "*%.*s", TEXT_LEN, yystack.l_mark[0].text.text); + yyval.text.begin = yystack.l_mark[-1].text.begin; + } +#line 1833 "grammar.tab.c" +break; +case 87: +#line 836 "grammar.y" + { + (void)sprintf(yyval.text.text, "*%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); + yyval.text.begin = yystack.l_mark[-2].text.begin; + } +#line 1841 "grammar.tab.c" +break; +case 88: +#line 844 "grammar.y" + { + strcpy(yyval.text.text, ""); + yyval.text.begin = 0L; + } +#line 1849 "grammar.tab.c" +break; +case 90: +#line 853 "grammar.y" + { + (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text); + yyval.text.begin = yystack.l_mark[0].decl_spec.begin; + free(yystack.l_mark[0].decl_spec.text); + } +#line 1858 "grammar.tab.c" +break; +case 91: +#line 859 "grammar.y" + { + (void)sprintf(yyval.text.text, "%.*s%.*s ", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].decl_spec.text); + yyval.text.begin = yystack.l_mark[-1].text.begin; + free(yystack.l_mark[0].decl_spec.text); + } +#line 1867 "grammar.tab.c" +break; +case 93: +#line 869 "grammar.y" + { + add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "..."); + } +#line 1874 "grammar.tab.c" +break; +case 94: +#line 876 "grammar.y" + { + new_param_list(&yyval.param_list, yystack.l_mark[0].parameter); + } +#line 1881 "grammar.tab.c" +break; +case 95: +#line 880 "grammar.y" + { + add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter); + } +#line 1888 "grammar.tab.c" +break; +case 96: +#line 887 "grammar.y" + { + check_untagged(&yystack.l_mark[-1].decl_spec); + yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); + } +#line 1896 "grammar.tab.c" +break; +case 97: +#line 892 "grammar.y" + { + check_untagged(&yystack.l_mark[-1].decl_spec); + yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); + } +#line 1904 "grammar.tab.c" +break; +case 98: +#line 897 "grammar.y" + { + check_untagged(&yystack.l_mark[0].decl_spec); + yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0); + } +#line 1912 "grammar.tab.c" +break; +case 99: +#line 905 "grammar.y" + { + new_ident_list(&yyval.param_list); + } +#line 1919 "grammar.tab.c" +break; +case 101: +#line 913 "grammar.y" + { + new_ident_list(&yyval.param_list); + add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text); + } +#line 1927 "grammar.tab.c" +break; +case 102: +#line 918 "grammar.y" + { + add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text); + } +#line 1934 "grammar.tab.c" +break; +case 103: +#line 925 "grammar.y" + { + yyval.text = yystack.l_mark[0].text; + } +#line 1941 "grammar.tab.c" +break; +case 104: +#line 929 "grammar.y" + { +#if OPT_LINTLIBRARY + if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */ + yyval.text = yystack.l_mark[0].text; + } else +#endif + (void)sprintf(yyval.text.text, "&%.*s", TEXT_LEN, yystack.l_mark[0].text.text); + yyval.text.begin = yystack.l_mark[-1].text.begin; + } +#line 1954 "grammar.tab.c" +break; +case 105: +#line 942 "grammar.y" + { + yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); + } +#line 1961 "grammar.tab.c" +break; +case 106: +#line 946 "grammar.y" + { + yyval.declarator = yystack.l_mark[0].declarator; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + yyval.declarator->begin = yystack.l_mark[-1].text.begin; + } +#line 1972 "grammar.tab.c" +break; +case 108: +#line 958 "grammar.y" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + yyval.declarator->begin = yystack.l_mark[-2].text.begin; + } +#line 1983 "grammar.tab.c" +break; +case 109: +#line 966 "grammar.y" + { + yyval.declarator = yystack.l_mark[-1].declarator; + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); + free(yyval.declarator->text); + yyval.declarator->text = xstrdup(buf); + } +#line 1993 "grammar.tab.c" +break; +case 110: +#line 973 "grammar.y" + { + yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); + } +#line 2000 "grammar.tab.c" +break; +case 111: +#line 977 "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; + } +#line 2011 "grammar.tab.c" +break; +case 112: +#line 985 "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; + } +#line 2021 "grammar.tab.c" +break; +case 113: +#line 992 "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; + } +#line 2035 "grammar.tab.c" +break; +case 114: +#line 1003 "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; + } +#line 2048 "grammar.tab.c" +break; +#line 2050 "grammar.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/grammar.tab.h b/test/yacc/grammar.tab.h new file mode 100644 index 00000000000..531dd2e849b --- /dev/null +++ b/test/yacc/grammar.tab.h @@ -0,0 +1,35 @@ +#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 diff --git a/test/yacc/help.error b/test/yacc/help.error new file mode 100644 index 00000000000..c4d890b024c --- /dev/null +++ b/test/yacc/help.error @@ -0,0 +1,31 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/yacc/help.output b/test/yacc/help.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_b_opt.error b/test/yacc/no_b_opt.error new file mode 100644 index 00000000000..c4d890b024c --- /dev/null +++ b/test/yacc/no_b_opt.error @@ -0,0 +1,31 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/yacc/no_b_opt.output b/test/yacc/no_b_opt.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_b_opt1.error b/test/yacc/no_b_opt1.error new file mode 100644 index 00000000000..87286c2661e --- /dev/null +++ b/test/yacc/no_b_opt1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/test/yacc/no_b_opt1.output b/test/yacc/no_b_opt1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_code_c.error b/test/yacc/no_code_c.error new file mode 100644 index 00000000000..87286c2661e --- /dev/null +++ b/test/yacc/no_code_c.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/test/yacc/no_code_c.output b/test/yacc/no_code_c.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_defines.error b/test/yacc/no_defines.error new file mode 100644 index 00000000000..773985d66f3 --- /dev/null +++ b/test/yacc/no_defines.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.h" diff --git a/test/yacc/no_defines.output b/test/yacc/no_defines.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_graph.error b/test/yacc/no_graph.error new file mode 100644 index 00000000000..d5575f40042 --- /dev/null +++ b/test/yacc/no_graph.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.dot" diff --git a/test/yacc/no_graph.output b/test/yacc/no_graph.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_include.error b/test/yacc/no_include.error new file mode 100644 index 00000000000..3ece4a454e3 --- /dev/null +++ b/test/yacc/no_include.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.i" diff --git a/test/yacc/no_include.output b/test/yacc/no_include.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_opts.error b/test/yacc/no_opts.error new file mode 100644 index 00000000000..ad3131a69ab --- /dev/null +++ b/test/yacc/no_opts.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.y" diff --git a/test/yacc/no_opts.output b/test/yacc/no_opts.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_output.error b/test/yacc/no_output.error new file mode 100644 index 00000000000..a2f142a9d53 --- /dev/null +++ b/test/yacc/no_output.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/test/yacc/no_output.output b/test/yacc/no_output.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_output1.error b/test/yacc/no_output1.error new file mode 100644 index 00000000000..a2f142a9d53 --- /dev/null +++ b/test/yacc/no_output1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/test/yacc/no_output1.output b/test/yacc/no_output1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_output2.error b/test/yacc/no_output2.error new file mode 100644 index 00000000000..c4d890b024c --- /dev/null +++ b/test/yacc/no_output2.error @@ -0,0 +1,31 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/yacc/no_output2.output b/test/yacc/no_output2.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_p_opt.error b/test/yacc/no_p_opt.error new file mode 100644 index 00000000000..c4d890b024c --- /dev/null +++ b/test/yacc/no_p_opt.error @@ -0,0 +1,31 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/yacc/no_p_opt.output b/test/yacc/no_p_opt.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_p_opt1.error b/test/yacc/no_p_opt1.error new file mode 100644 index 00000000000..87286c2661e --- /dev/null +++ b/test/yacc/no_p_opt1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/test/yacc/no_p_opt1.output b/test/yacc/no_p_opt1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/no_verbose.error b/test/yacc/no_verbose.error new file mode 100644 index 00000000000..a2f142a9d53 --- /dev/null +++ b/test/yacc/no_verbose.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/test/yacc/no_verbose.output b/test/yacc/no_verbose.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/nostdin.error b/test/yacc/nostdin.error new file mode 100644 index 00000000000..7f74f49a89b --- /dev/null +++ b/test/yacc/nostdin.error @@ -0,0 +1,30 @@ +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -h print this help-message + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit + +Long options: + --defines -H + --file-prefix -b + --graph -g + --help -h + --name-prefix -p + --no-lines -l + --output -o + --version -V diff --git a/test/yacc/nostdin.output b/test/yacc/nostdin.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/ok_syntax1.error b/test/yacc/ok_syntax1.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/ok_syntax1.output b/test/yacc/ok_syntax1.output new file mode 100644 index 00000000000..105a1d30d48 --- /dev/null +++ b/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/test/yacc/ok_syntax1.tab.c b/test/yacc/ok_syntax1.tab.c new file mode 100644 index 00000000000..917b9a3f883 --- /dev/null +++ b/test/yacc/ok_syntax1.tab.c @@ -0,0 +1,731 @@ +/* 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 2 +#define YYMINOR 0 +#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 + +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 43 "ok_syntax1.y" +union CalcData +{ + char * cval; + int ival; + double dval; +}; typedef union CalcData 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 int 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 + +#if YYDEBUG +int yydebug; +#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 + +#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 390 "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; + int yynerrs; + + /* 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 + + memset(&yyval, 0, sizeof(yyval)); + memset(&yylval, 0, sizeof(yylval)); + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 66 "ok_syntax1.y" + { yyerrok ; } +#line 603 "ok_syntax1.tab.c" +break; +case 4: +#line 70 "ok_syntax1.y" + { printf("%d\n",yystack.l_mark[0].ival);} +#line 608 "ok_syntax1.tab.c" +break; +case 5: +#line 72 "ok_syntax1.y" + { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; } +#line 613 "ok_syntax1.tab.c" +break; +case 6: +#line 76 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-1].ival; } +#line 618 "ok_syntax1.tab.c" +break; +case 7: +#line 78 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; } +#line 623 "ok_syntax1.tab.c" +break; +case 8: +#line 80 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; } +#line 628 "ok_syntax1.tab.c" +break; +case 9: +#line 82 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; } +#line 633 "ok_syntax1.tab.c" +break; +case 10: +#line 84 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; } +#line 638 "ok_syntax1.tab.c" +break; +case 11: +#line 86 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; } +#line 643 "ok_syntax1.tab.c" +break; +case 12: +#line 88 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; } +#line 648 "ok_syntax1.tab.c" +break; +case 13: +#line 90 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; } +#line 653 "ok_syntax1.tab.c" +break; +case 14: +#line 92 "ok_syntax1.y" + { yyval.ival = - yystack.l_mark[0].ival; } +#line 658 "ok_syntax1.tab.c" +break; +case 15: +#line 94 "ok_syntax1.y" + { yyval.ival = regs[yystack.l_mark[0].ival]; } +#line 663 "ok_syntax1.tab.c" +break; +case 17: +#line 99 "ok_syntax1.y" + { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; } +#line 668 "ok_syntax1.tab.c" +break; +case 18: +#line 101 "ok_syntax1.y" + { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } +#line 673 "ok_syntax1.tab.c" +break; +#line 675 "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) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/ok_syntax1.tab.h b/test/yacc/ok_syntax1.tab.h new file mode 100644 index 00000000000..da8e5052277 --- /dev/null +++ b/test/yacc/ok_syntax1.tab.h @@ -0,0 +1,29 @@ +#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 +union CalcData +{ + char * cval; + int ival; + double dval; +}; typedef union CalcData YYSTYPE; +#endif /* !YYSTYPE_IS_DECLARED */ diff --git a/test/yacc/pure_calc.error b/test/yacc/pure_calc.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/pure_calc.output b/test/yacc/pure_calc.output new file mode 100644 index 00000000000..3aed47511c9 --- /dev/null +++ b/test/yacc/pure_calc.output @@ -0,0 +1,461 @@ + 0 $accept : list $end + + 1 list : + 2 | list stat '\n' + 3 | list error '\n' + + 4 stat : expr + 5 | LETTER '=' expr + + 6 expr : '(' expr ')' + 7 | expr '+' expr + 8 | expr '-' expr + 9 | expr '*' expr + 10 | expr '/' expr + 11 | expr '%' expr + 12 | expr '&' expr + 13 | expr '|' expr + 14 | '-' expr + 15 | LETTER + 16 | number + + 17 number : DIGIT + 18 | number DIGIT + +state 0 + $accept : . list $end (0) + list : . (1) + + . reduce 1 + + list goto 1 + + +state 1 + $accept : list . $end (0) + list : list . stat '\n' (2) + list : list . error '\n' (3) + + $end accept + error shift 2 + DIGIT shift 3 + LETTER shift 4 + '-' shift 5 + '(' shift 6 + . error + + stat goto 7 + expr goto 8 + number goto 9 + + +state 2 + list : list error . '\n' (3) + + '\n' shift 10 + . error + + +state 3 + number : DIGIT . (17) + + . reduce 17 + + +state 4 + stat : LETTER . '=' expr (5) + expr : LETTER . (15) + + '=' shift 11 + '|' reduce 15 + '&' reduce 15 + '+' reduce 15 + '-' reduce 15 + '*' reduce 15 + '/' reduce 15 + '%' reduce 15 + '\n' reduce 15 + + +state 5 + expr : '-' . expr (14) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 13 + number goto 9 + + +state 6 + expr : '(' . expr ')' (6) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 14 + number goto 9 + + +state 7 + list : list stat . '\n' (2) + + '\n' shift 15 + . error + + +state 8 + stat : expr . (4) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 4 + + +state 9 + expr : number . (16) + number : number . DIGIT (18) + + DIGIT shift 23 + '|' reduce 16 + '&' reduce 16 + '+' reduce 16 + '-' reduce 16 + '*' reduce 16 + '/' reduce 16 + '%' reduce 16 + '\n' reduce 16 + ')' reduce 16 + + +state 10 + list : list error '\n' . (3) + + . reduce 3 + + +state 11 + stat : LETTER '=' . expr (5) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 24 + number goto 9 + + +state 12 + expr : LETTER . (15) + + . reduce 15 + + +state 13 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : '-' expr . (14) + + . reduce 14 + + +state 14 + expr : '(' expr . ')' (6) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + ')' shift 25 + . error + + +state 15 + list : list stat '\n' . (2) + + . reduce 2 + + +state 16 + expr : expr '|' . expr (13) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 26 + number goto 9 + + +state 17 + expr : expr '&' . expr (12) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 27 + number goto 9 + + +state 18 + expr : expr '+' . expr (7) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 28 + number goto 9 + + +state 19 + expr : expr '-' . expr (8) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 29 + number goto 9 + + +state 20 + expr : expr '*' . expr (9) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 30 + number goto 9 + + +state 21 + expr : expr '/' . expr (10) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 31 + number goto 9 + + +state 22 + expr : expr '%' . expr (11) + + DIGIT shift 3 + LETTER shift 12 + '-' shift 5 + '(' shift 6 + . error + + expr goto 32 + number goto 9 + + +state 23 + number : number DIGIT . (18) + + . reduce 18 + + +state 24 + stat : LETTER '=' expr . (5) + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '|' shift 16 + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '\n' reduce 5 + + +state 25 + expr : '(' expr ')' . (6) + + . reduce 6 + + +state 26 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + expr : expr '|' expr . (13) + + '&' shift 17 + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 13 + '\n' reduce 13 + ')' reduce 13 + + +state 27 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr '&' expr . (12) + expr : expr . '|' expr (13) + + '+' shift 18 + '-' shift 19 + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 12 + '&' reduce 12 + '\n' reduce 12 + ')' reduce 12 + + +state 28 + expr : expr . '+' expr (7) + expr : expr '+' expr . (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 7 + '&' reduce 7 + '+' reduce 7 + '-' reduce 7 + '\n' reduce 7 + ')' reduce 7 + + +state 29 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr '-' expr . (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + '*' shift 20 + '/' shift 21 + '%' shift 22 + '|' reduce 8 + '&' reduce 8 + '+' reduce 8 + '-' reduce 8 + '\n' reduce 8 + ')' reduce 8 + + +state 30 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr '*' expr . (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 9 + + +state 31 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr '/' expr . (10) + expr : expr . '%' expr (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 10 + + +state 32 + expr : expr . '+' expr (7) + expr : expr . '-' expr (8) + expr : expr . '*' expr (9) + expr : expr . '/' expr (10) + expr : expr . '%' expr (11) + expr : expr '%' expr . (11) + expr : expr . '&' expr (12) + expr : expr . '|' expr (13) + + . reduce 11 + + +16 terminals, 5 nonterminals +19 grammar rules, 33 states diff --git a/test/yacc/pure_calc.tab.c b/test/yacc/pure_calc.tab.c new file mode 100644 index 00000000000..eb0021549e2 --- /dev/null +++ b/test/yacc/pure_calc.tab.c @@ -0,0 +1,703 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_rule +#endif /* yyrule */ +#define YYPREFIX "calc_" + +#define YYPURE 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 117 "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 int 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_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, +}; +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-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const calc_rule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +/* 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 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 362 "pure_calc.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; + int yynerrs; + + /* 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 + + memset(&yyval, 0, sizeof(yyval)); + memset(&yylval, 0, sizeof(yylval)); + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 34 "pure_calc.y" + { yyerrok ; } +#line 575 "pure_calc.tab.c" +break; +case 4: +#line 38 "pure_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 580 "pure_calc.tab.c" +break; +case 5: +#line 40 "pure_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 585 "pure_calc.tab.c" +break; +case 6: +#line 44 "pure_calc.y" + { yyval = yystack.l_mark[-1]; } +#line 590 "pure_calc.tab.c" +break; +case 7: +#line 46 "pure_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 595 "pure_calc.tab.c" +break; +case 8: +#line 48 "pure_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 600 "pure_calc.tab.c" +break; +case 9: +#line 50 "pure_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 605 "pure_calc.tab.c" +break; +case 10: +#line 52 "pure_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 610 "pure_calc.tab.c" +break; +case 11: +#line 54 "pure_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 615 "pure_calc.tab.c" +break; +case 12: +#line 56 "pure_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 620 "pure_calc.tab.c" +break; +case 13: +#line 58 "pure_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 625 "pure_calc.tab.c" +break; +case 14: +#line 60 "pure_calc.y" + { yyval = - yystack.l_mark[0]; } +#line 630 "pure_calc.tab.c" +break; +case 15: +#line 62 "pure_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 635 "pure_calc.tab.c" +break; +case 17: +#line 67 "pure_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 640 "pure_calc.tab.c" +break; +case 18: +#line 69 "pure_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 645 "pure_calc.tab.c" +break; +#line 647 "pure_calc.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/pure_calc.tab.h b/test/yacc/pure_calc.tab.h new file mode 100644 index 00000000000..19211182d6b --- /dev/null +++ b/test/yacc/pure_calc.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/test/yacc/pure_error.error b/test/yacc/pure_error.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/pure_error.output b/test/yacc/pure_error.output new file mode 100644 index 00000000000..0c4db6225e2 --- /dev/null +++ b/test/yacc/pure_error.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/test/yacc/pure_error.tab.c b/test/yacc/pure_error.tab.c new file mode 100644 index 00000000000..f3e13bee933 --- /dev/null +++ b/test/yacc/pure_error.tab.c @@ -0,0 +1,524 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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_" + +#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 112 "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 int 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_dgoto[] = { 2, +}; +static const YYINT error_sindex[] = { -256, + 0, 0, +}; +static const YYINT error_rindex[] = { 0, + 0, 0, +}; +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-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 error_rule[] = { +"$accept : S", +"S : error", + +}; +#endif + +#if YYDEBUG +int yydebug; +#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 + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +#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 259 "pure_error.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; + int yynerrs; + + /* 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 + + memset(&yyval, 0, sizeof(yyval)); + memset(&yylval, 0, sizeof(yylval)); + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/pure_error.tab.h b/test/yacc/pure_error.tab.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/quote_calc-s.error b/test/yacc/quote_calc-s.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/yacc/quote_calc-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc-s.output b/test/yacc/quote_calc-s.output new file mode 100644 index 00000000000..0306652bfaa --- /dev/null +++ b/test/yacc/quote_calc-s.output @@ -0,0 +1,557 @@ + 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 diff --git a/test/yacc/quote_calc-s.tab.c b/test/yacc/quote_calc-s.tab.c new file mode 100644 index 00000000000..588c14b76a3 --- /dev/null +++ b/test/yacc/quote_calc-s.tab.c @@ -0,0 +1,701 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 111 "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 int 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_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, +}; +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-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,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, +0,0,"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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 371 "quote_calc-s.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "quote_calc.y" + { yyerrok ; } +#line 573 "quote_calc-s.tab.c" +break; +case 4: +#line 39 "quote_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 578 "quote_calc-s.tab.c" +break; +case 5: +#line 41 "quote_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 583 "quote_calc-s.tab.c" +break; +case 6: +#line 45 "quote_calc.y" + { yyval = yystack.l_mark[-1]; } +#line 588 "quote_calc-s.tab.c" +break; +case 7: +#line 47 "quote_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 593 "quote_calc-s.tab.c" +break; +case 8: +#line 49 "quote_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 598 "quote_calc-s.tab.c" +break; +case 9: +#line 51 "quote_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 603 "quote_calc-s.tab.c" +break; +case 10: +#line 53 "quote_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 608 "quote_calc-s.tab.c" +break; +case 11: +#line 55 "quote_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 613 "quote_calc-s.tab.c" +break; +case 12: +#line 57 "quote_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 618 "quote_calc-s.tab.c" +break; +case 13: +#line 59 "quote_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 623 "quote_calc-s.tab.c" +break; +case 14: +#line 61 "quote_calc.y" + { yyval = - yystack.l_mark[0]; } +#line 628 "quote_calc-s.tab.c" +break; +case 15: +#line 63 "quote_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 633 "quote_calc-s.tab.c" +break; +case 17: +#line 68 "quote_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 638 "quote_calc-s.tab.c" +break; +case 18: +#line 70 "quote_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 643 "quote_calc-s.tab.c" +break; +#line 645 "quote_calc-s.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/quote_calc-s.tab.h b/test/yacc/quote_calc-s.tab.h new file mode 100644 index 00000000000..1a465790341 --- /dev/null +++ b/test/yacc/quote_calc-s.tab.h @@ -0,0 +1,9 @@ +#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 diff --git a/test/yacc/quote_calc.error b/test/yacc/quote_calc.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/yacc/quote_calc.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc.output b/test/yacc/quote_calc.output new file mode 100644 index 00000000000..0306652bfaa --- /dev/null +++ b/test/yacc/quote_calc.output @@ -0,0 +1,557 @@ + 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 diff --git a/test/yacc/quote_calc.tab.c b/test/yacc/quote_calc.tab.c new file mode 100644 index 00000000000..33a718e5eaa --- /dev/null +++ b/test/yacc/quote_calc.tab.c @@ -0,0 +1,707 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 111 "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 int 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_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, +}; +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-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,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, +0,0,"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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 377 "quote_calc.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "quote_calc.y" + { yyerrok ; } +#line 579 "quote_calc.tab.c" +break; +case 4: +#line 39 "quote_calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 584 "quote_calc.tab.c" +break; +case 5: +#line 41 "quote_calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 589 "quote_calc.tab.c" +break; +case 6: +#line 45 "quote_calc.y" + { yyval = yystack.l_mark[-1]; } +#line 594 "quote_calc.tab.c" +break; +case 7: +#line 47 "quote_calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 599 "quote_calc.tab.c" +break; +case 8: +#line 49 "quote_calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 604 "quote_calc.tab.c" +break; +case 9: +#line 51 "quote_calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 609 "quote_calc.tab.c" +break; +case 10: +#line 53 "quote_calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 614 "quote_calc.tab.c" +break; +case 11: +#line 55 "quote_calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 619 "quote_calc.tab.c" +break; +case 12: +#line 57 "quote_calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 624 "quote_calc.tab.c" +break; +case 13: +#line 59 "quote_calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 629 "quote_calc.tab.c" +break; +case 14: +#line 61 "quote_calc.y" + { yyval = - yystack.l_mark[0]; } +#line 634 "quote_calc.tab.c" +break; +case 15: +#line 63 "quote_calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 639 "quote_calc.tab.c" +break; +case 17: +#line 68 "quote_calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 644 "quote_calc.tab.c" +break; +case 18: +#line 70 "quote_calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 649 "quote_calc.tab.c" +break; +#line 651 "quote_calc.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/quote_calc.tab.h b/test/yacc/quote_calc.tab.h new file mode 100644 index 00000000000..498eff210db --- /dev/null +++ b/test/yacc/quote_calc.tab.h @@ -0,0 +1,15 @@ +#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 diff --git a/test/yacc/quote_calc2-s.error b/test/yacc/quote_calc2-s.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/yacc/quote_calc2-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc2-s.output b/test/yacc/quote_calc2-s.output new file mode 100644 index 00000000000..ed28ae2f21c --- /dev/null +++ b/test/yacc/quote_calc2-s.output @@ -0,0 +1,557 @@ + 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 diff --git a/test/yacc/quote_calc2-s.tab.c b/test/yacc/quote_calc2-s.tab.c new file mode 100644 index 00000000000..98438d9f567 --- /dev/null +++ b/test/yacc/quote_calc2-s.tab.c @@ -0,0 +1,701 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 111 "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 int 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_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, +}; +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-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,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, +0,0,"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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 371 "quote_calc2-s.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "quote_calc2.y" + { yyerrok ; } +#line 573 "quote_calc2-s.tab.c" +break; +case 4: +#line 39 "quote_calc2.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 578 "quote_calc2-s.tab.c" +break; +case 5: +#line 41 "quote_calc2.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 583 "quote_calc2-s.tab.c" +break; +case 6: +#line 45 "quote_calc2.y" + { yyval = yystack.l_mark[-1]; } +#line 588 "quote_calc2-s.tab.c" +break; +case 7: +#line 47 "quote_calc2.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 593 "quote_calc2-s.tab.c" +break; +case 8: +#line 49 "quote_calc2.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 598 "quote_calc2-s.tab.c" +break; +case 9: +#line 51 "quote_calc2.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 603 "quote_calc2-s.tab.c" +break; +case 10: +#line 53 "quote_calc2.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 608 "quote_calc2-s.tab.c" +break; +case 11: +#line 55 "quote_calc2.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 613 "quote_calc2-s.tab.c" +break; +case 12: +#line 57 "quote_calc2.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 618 "quote_calc2-s.tab.c" +break; +case 13: +#line 59 "quote_calc2.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 623 "quote_calc2-s.tab.c" +break; +case 14: +#line 61 "quote_calc2.y" + { yyval = - yystack.l_mark[0]; } +#line 628 "quote_calc2-s.tab.c" +break; +case 15: +#line 63 "quote_calc2.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 633 "quote_calc2-s.tab.c" +break; +case 17: +#line 68 "quote_calc2.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 638 "quote_calc2-s.tab.c" +break; +case 18: +#line 70 "quote_calc2.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 643 "quote_calc2-s.tab.c" +break; +#line 645 "quote_calc2-s.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/quote_calc2-s.tab.h b/test/yacc/quote_calc2-s.tab.h new file mode 100644 index 00000000000..1a465790341 --- /dev/null +++ b/test/yacc/quote_calc2-s.tab.h @@ -0,0 +1,9 @@ +#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 diff --git a/test/yacc/quote_calc2.error b/test/yacc/quote_calc2.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/yacc/quote_calc2.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc2.output b/test/yacc/quote_calc2.output new file mode 100644 index 00000000000..ed28ae2f21c --- /dev/null +++ b/test/yacc/quote_calc2.output @@ -0,0 +1,557 @@ + 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 diff --git a/test/yacc/quote_calc2.tab.c b/test/yacc/quote_calc2.tab.c new file mode 100644 index 00000000000..8301c570b69 --- /dev/null +++ b/test/yacc/quote_calc2.tab.c @@ -0,0 +1,707 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 111 "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 int 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_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, +}; +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-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,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", +"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",0,0,0, +0,0,"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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 377 "quote_calc2.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "quote_calc2.y" + { yyerrok ; } +#line 579 "quote_calc2.tab.c" +break; +case 4: +#line 39 "quote_calc2.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 584 "quote_calc2.tab.c" +break; +case 5: +#line 41 "quote_calc2.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 589 "quote_calc2.tab.c" +break; +case 6: +#line 45 "quote_calc2.y" + { yyval = yystack.l_mark[-1]; } +#line 594 "quote_calc2.tab.c" +break; +case 7: +#line 47 "quote_calc2.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 599 "quote_calc2.tab.c" +break; +case 8: +#line 49 "quote_calc2.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 604 "quote_calc2.tab.c" +break; +case 9: +#line 51 "quote_calc2.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 609 "quote_calc2.tab.c" +break; +case 10: +#line 53 "quote_calc2.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 614 "quote_calc2.tab.c" +break; +case 11: +#line 55 "quote_calc2.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 619 "quote_calc2.tab.c" +break; +case 12: +#line 57 "quote_calc2.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 624 "quote_calc2.tab.c" +break; +case 13: +#line 59 "quote_calc2.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 629 "quote_calc2.tab.c" +break; +case 14: +#line 61 "quote_calc2.y" + { yyval = - yystack.l_mark[0]; } +#line 634 "quote_calc2.tab.c" +break; +case 15: +#line 63 "quote_calc2.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 639 "quote_calc2.tab.c" +break; +case 17: +#line 68 "quote_calc2.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 644 "quote_calc2.tab.c" +break; +case 18: +#line 70 "quote_calc2.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 649 "quote_calc2.tab.c" +break; +#line 651 "quote_calc2.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/quote_calc2.tab.h b/test/yacc/quote_calc2.tab.h new file mode 100644 index 00000000000..498eff210db --- /dev/null +++ b/test/yacc/quote_calc2.tab.h @@ -0,0 +1,15 @@ +#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 diff --git a/test/yacc/quote_calc3-s.error b/test/yacc/quote_calc3-s.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/yacc/quote_calc3-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc3-s.output b/test/yacc/quote_calc3-s.output new file mode 100644 index 00000000000..0306652bfaa --- /dev/null +++ b/test/yacc/quote_calc3-s.output @@ -0,0 +1,557 @@ + 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 diff --git a/test/yacc/quote_calc3-s.tab.c b/test/yacc/quote_calc3-s.tab.c new file mode 100644 index 00000000000..599ff8bfa75 --- /dev/null +++ b/test/yacc/quote_calc3-s.tab.c @@ -0,0 +1,702 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 111 "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 int 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_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, +}; +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-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,"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",0,0,0,0,0, +"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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 372 "quote_calc3-s.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "quote_calc3.y" + { yyerrok ; } +#line 574 "quote_calc3-s.tab.c" +break; +case 4: +#line 39 "quote_calc3.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 579 "quote_calc3-s.tab.c" +break; +case 5: +#line 41 "quote_calc3.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 584 "quote_calc3-s.tab.c" +break; +case 6: +#line 45 "quote_calc3.y" + { yyval = yystack.l_mark[-1]; } +#line 589 "quote_calc3-s.tab.c" +break; +case 7: +#line 47 "quote_calc3.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 594 "quote_calc3-s.tab.c" +break; +case 8: +#line 49 "quote_calc3.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 599 "quote_calc3-s.tab.c" +break; +case 9: +#line 51 "quote_calc3.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 604 "quote_calc3-s.tab.c" +break; +case 10: +#line 53 "quote_calc3.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 609 "quote_calc3-s.tab.c" +break; +case 11: +#line 55 "quote_calc3.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 614 "quote_calc3-s.tab.c" +break; +case 12: +#line 57 "quote_calc3.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 619 "quote_calc3-s.tab.c" +break; +case 13: +#line 59 "quote_calc3.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 624 "quote_calc3-s.tab.c" +break; +case 14: +#line 61 "quote_calc3.y" + { yyval = - yystack.l_mark[0]; } +#line 629 "quote_calc3-s.tab.c" +break; +case 15: +#line 63 "quote_calc3.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 634 "quote_calc3-s.tab.c" +break; +case 17: +#line 68 "quote_calc3.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 639 "quote_calc3-s.tab.c" +break; +case 18: +#line 70 "quote_calc3.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 644 "quote_calc3-s.tab.c" +break; +#line 646 "quote_calc3-s.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/quote_calc3-s.tab.h b/test/yacc/quote_calc3-s.tab.h new file mode 100644 index 00000000000..1a465790341 --- /dev/null +++ b/test/yacc/quote_calc3-s.tab.h @@ -0,0 +1,9 @@ +#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 diff --git a/test/yacc/quote_calc3.error b/test/yacc/quote_calc3.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/yacc/quote_calc3.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc3.output b/test/yacc/quote_calc3.output new file mode 100644 index 00000000000..0306652bfaa --- /dev/null +++ b/test/yacc/quote_calc3.output @@ -0,0 +1,557 @@ + 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 diff --git a/test/yacc/quote_calc3.tab.c b/test/yacc/quote_calc3.tab.c new file mode 100644 index 00000000000..4ba3ce72f31 --- /dev/null +++ b/test/yacc/quote_calc3.tab.c @@ -0,0 +1,702 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 111 "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 int 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_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, +}; +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-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,"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",0,0,0,0,0, +"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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 372 "quote_calc3.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "quote_calc3.y" + { yyerrok ; } +#line 574 "quote_calc3.tab.c" +break; +case 4: +#line 39 "quote_calc3.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 579 "quote_calc3.tab.c" +break; +case 5: +#line 41 "quote_calc3.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 584 "quote_calc3.tab.c" +break; +case 6: +#line 45 "quote_calc3.y" + { yyval = yystack.l_mark[-1]; } +#line 589 "quote_calc3.tab.c" +break; +case 7: +#line 47 "quote_calc3.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 594 "quote_calc3.tab.c" +break; +case 8: +#line 49 "quote_calc3.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 599 "quote_calc3.tab.c" +break; +case 9: +#line 51 "quote_calc3.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 604 "quote_calc3.tab.c" +break; +case 10: +#line 53 "quote_calc3.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 609 "quote_calc3.tab.c" +break; +case 11: +#line 55 "quote_calc3.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 614 "quote_calc3.tab.c" +break; +case 12: +#line 57 "quote_calc3.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 619 "quote_calc3.tab.c" +break; +case 13: +#line 59 "quote_calc3.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 624 "quote_calc3.tab.c" +break; +case 14: +#line 61 "quote_calc3.y" + { yyval = - yystack.l_mark[0]; } +#line 629 "quote_calc3.tab.c" +break; +case 15: +#line 63 "quote_calc3.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 634 "quote_calc3.tab.c" +break; +case 17: +#line 68 "quote_calc3.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 639 "quote_calc3.tab.c" +break; +case 18: +#line 70 "quote_calc3.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 644 "quote_calc3.tab.c" +break; +#line 646 "quote_calc3.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/quote_calc3.tab.h b/test/yacc/quote_calc3.tab.h new file mode 100644 index 00000000000..1a465790341 --- /dev/null +++ b/test/yacc/quote_calc3.tab.h @@ -0,0 +1,9 @@ +#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 diff --git a/test/yacc/quote_calc4-s.error b/test/yacc/quote_calc4-s.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/yacc/quote_calc4-s.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc4-s.output b/test/yacc/quote_calc4-s.output new file mode 100644 index 00000000000..a1d5afc9579 --- /dev/null +++ b/test/yacc/quote_calc4-s.output @@ -0,0 +1,557 @@ + 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 diff --git a/test/yacc/quote_calc4-s.tab.c b/test/yacc/quote_calc4-s.tab.c new file mode 100644 index 00000000000..86488292386 --- /dev/null +++ b/test/yacc/quote_calc4-s.tab.c @@ -0,0 +1,702 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 111 "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 int 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_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, +}; +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-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,"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",0,0,0,0,0, +"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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 372 "quote_calc4-s.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "quote_calc4.y" + { yyerrok ; } +#line 574 "quote_calc4-s.tab.c" +break; +case 4: +#line 39 "quote_calc4.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 579 "quote_calc4-s.tab.c" +break; +case 5: +#line 41 "quote_calc4.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 584 "quote_calc4-s.tab.c" +break; +case 6: +#line 45 "quote_calc4.y" + { yyval = yystack.l_mark[-1]; } +#line 589 "quote_calc4-s.tab.c" +break; +case 7: +#line 47 "quote_calc4.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 594 "quote_calc4-s.tab.c" +break; +case 8: +#line 49 "quote_calc4.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 599 "quote_calc4-s.tab.c" +break; +case 9: +#line 51 "quote_calc4.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 604 "quote_calc4-s.tab.c" +break; +case 10: +#line 53 "quote_calc4.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 609 "quote_calc4-s.tab.c" +break; +case 11: +#line 55 "quote_calc4.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 614 "quote_calc4-s.tab.c" +break; +case 12: +#line 57 "quote_calc4.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 619 "quote_calc4-s.tab.c" +break; +case 13: +#line 59 "quote_calc4.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 624 "quote_calc4-s.tab.c" +break; +case 14: +#line 61 "quote_calc4.y" + { yyval = - yystack.l_mark[0]; } +#line 629 "quote_calc4-s.tab.c" +break; +case 15: +#line 63 "quote_calc4.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 634 "quote_calc4-s.tab.c" +break; +case 17: +#line 68 "quote_calc4.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 639 "quote_calc4-s.tab.c" +break; +case 18: +#line 70 "quote_calc4.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 644 "quote_calc4-s.tab.c" +break; +#line 646 "quote_calc4-s.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/quote_calc4-s.tab.h b/test/yacc/quote_calc4-s.tab.h new file mode 100644 index 00000000000..1a465790341 --- /dev/null +++ b/test/yacc/quote_calc4-s.tab.h @@ -0,0 +1,9 @@ +#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 diff --git a/test/yacc/quote_calc4.error b/test/yacc/quote_calc4.error new file mode 100644 index 00000000000..729d01c0abb --- /dev/null +++ b/test/yacc/quote_calc4.error @@ -0,0 +1 @@ +YACC: 54 shift/reduce conflicts. diff --git a/test/yacc/quote_calc4.output b/test/yacc/quote_calc4.output new file mode 100644 index 00000000000..a1d5afc9579 --- /dev/null +++ b/test/yacc/quote_calc4.output @@ -0,0 +1,557 @@ + 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 diff --git a/test/yacc/quote_calc4.tab.c b/test/yacc/quote_calc4.tab.c new file mode 100644 index 00000000000..115a2c0beb5 --- /dev/null +++ b/test/yacc/quote_calc4.tab.c @@ -0,0 +1,702 @@ +/* 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 2 +#define YYMINOR 0 +#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 +#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 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 */ +#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 111 "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 int 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_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, +}; +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-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,"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",0,0,0,0,0, +"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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 372 "quote_calc4.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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "quote_calc4.y" + { yyerrok ; } +#line 574 "quote_calc4.tab.c" +break; +case 4: +#line 39 "quote_calc4.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 579 "quote_calc4.tab.c" +break; +case 5: +#line 41 "quote_calc4.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 584 "quote_calc4.tab.c" +break; +case 6: +#line 45 "quote_calc4.y" + { yyval = yystack.l_mark[-1]; } +#line 589 "quote_calc4.tab.c" +break; +case 7: +#line 47 "quote_calc4.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 594 "quote_calc4.tab.c" +break; +case 8: +#line 49 "quote_calc4.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 599 "quote_calc4.tab.c" +break; +case 9: +#line 51 "quote_calc4.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 604 "quote_calc4.tab.c" +break; +case 10: +#line 53 "quote_calc4.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 609 "quote_calc4.tab.c" +break; +case 11: +#line 55 "quote_calc4.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 614 "quote_calc4.tab.c" +break; +case 12: +#line 57 "quote_calc4.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 619 "quote_calc4.tab.c" +break; +case 13: +#line 59 "quote_calc4.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 624 "quote_calc4.tab.c" +break; +case 14: +#line 61 "quote_calc4.y" + { yyval = - yystack.l_mark[0]; } +#line 629 "quote_calc4.tab.c" +break; +case 15: +#line 63 "quote_calc4.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 634 "quote_calc4.tab.c" +break; +case 17: +#line 68 "quote_calc4.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 639 "quote_calc4.tab.c" +break; +case 18: +#line 70 "quote_calc4.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 644 "quote_calc4.tab.c" +break; +#line 646 "quote_calc4.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/quote_calc4.tab.h b/test/yacc/quote_calc4.tab.h new file mode 100644 index 00000000000..1a465790341 --- /dev/null +++ b/test/yacc/quote_calc4.tab.h @@ -0,0 +1,9 @@ +#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 diff --git a/test/yacc/rename_debug.c b/test/yacc/rename_debug.c new file mode 100644 index 00000000000..dad9d93ab7c --- /dev/null +++ b/test/yacc/rename_debug.c @@ -0,0 +1,385 @@ +/* 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 2 +#define YYMINOR 0 +#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 int 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 132 "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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/rename_debug.error b/test/yacc/rename_debug.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/rename_debug.h b/test/yacc/rename_debug.h new file mode 100644 index 00000000000..e1d14cbda09 --- /dev/null +++ b/test/yacc/rename_debug.h @@ -0,0 +1 @@ +#define YYERRCODE 256 diff --git a/test/yacc/rename_debug.i b/test/yacc/rename_debug.i new file mode 100644 index 00000000000..1e81e02e8f9 --- /dev/null +++ b/test/yacc/rename_debug.i @@ -0,0 +1,66 @@ +#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 + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif + +#if YYDEBUG +extern int yydebug; +#endif + +extern int yyerrflag; +extern int yychar; +extern YYSTYPE yyval; +extern YYSTYPE yylval; +extern int yynerrs; diff --git a/test/yacc/rename_debug.output b/test/yacc/rename_debug.output new file mode 100644 index 00000000000..0c4db6225e2 --- /dev/null +++ b/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/test/yacc/stdin1.calc.c b/test/yacc/stdin1.calc.c new file mode 100644 index 00000000000..19898028a66 --- /dev/null +++ b/test/yacc/stdin1.calc.c @@ -0,0 +1,610 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "(null)" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 31 "stdin1.calc.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 66 "(null)" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 280 "stdin1.calc.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "(null)" + { yyerrok ; } +#line 482 "stdin1.calc.c" +break; +case 4: +#line 32 "(null)" + { printf("%d\n",yystack.l_mark[0]);} +#line 487 "stdin1.calc.c" +break; +case 5: +#line 34 "(null)" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 492 "stdin1.calc.c" +break; +case 6: +#line 38 "(null)" + { yyval = yystack.l_mark[-1]; } +#line 497 "stdin1.calc.c" +break; +case 7: +#line 40 "(null)" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 502 "stdin1.calc.c" +break; +case 8: +#line 42 "(null)" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 507 "stdin1.calc.c" +break; +case 9: +#line 44 "(null)" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 512 "stdin1.calc.c" +break; +case 10: +#line 46 "(null)" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 517 "stdin1.calc.c" +break; +case 11: +#line 48 "(null)" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 522 "stdin1.calc.c" +break; +case 12: +#line 50 "(null)" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 527 "stdin1.calc.c" +break; +case 13: +#line 52 "(null)" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 532 "stdin1.calc.c" +break; +case 14: +#line 54 "(null)" + { yyval = - yystack.l_mark[0]; } +#line 537 "stdin1.calc.c" +break; +case 15: +#line 56 "(null)" + { yyval = regs[yystack.l_mark[0]]; } +#line 542 "stdin1.calc.c" +break; +case 17: +#line 61 "(null)" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 547 "stdin1.calc.c" +break; +case 18: +#line 63 "(null)" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 552 "stdin1.calc.c" +break; +#line 554 "stdin1.calc.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/stdin1.error b/test/yacc/stdin1.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/stdin1.output b/test/yacc/stdin1.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/stdin2.calc.c b/test/yacc/stdin2.calc.c new file mode 100644 index 00000000000..218350e19ab --- /dev/null +++ b/test/yacc/stdin2.calc.c @@ -0,0 +1,610 @@ +/* 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 2 +#define YYMINOR 0 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 31 "stdin2.calc.c" + +#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) +/* Default: YYSTYPE is the semantic value type. */ +typedef int YYSTYPE; +# define YYSTYPE_IS_DECLARED 1 +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +typedef int YYINT; +static const YYINT yylhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const YYINT yylen[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const YYINT yydgoto[] = { 1, + 7, 8, 9, +}; +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const YYINT yygindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) +#if YYDEBUG +static const char *const yyname[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", +}; +static const char *const yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 280 "stdin2.calc.c" + +#if YYDEBUG +#include /* 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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +#line 482 "stdin2.calc.c" +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +#line 487 "stdin2.calc.c" +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +#line 492 "stdin2.calc.c" +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +#line 497 "stdin2.calc.c" +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +#line 502 "stdin2.calc.c" +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +#line 507 "stdin2.calc.c" +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +#line 512 "stdin2.calc.c" +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +#line 517 "stdin2.calc.c" +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +#line 522 "stdin2.calc.c" +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +#line 527 "stdin2.calc.c" +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +#line 532 "stdin2.calc.c" +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +#line 537 "stdin2.calc.c" +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +#line 542 "stdin2.calc.c" +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +#line 547 "stdin2.calc.c" +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +#line 552 "stdin2.calc.c" +break; +#line 554 "stdin2.calc.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/stdin2.error b/test/yacc/stdin2.error new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/stdin2.output b/test/yacc/stdin2.output new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/yacc/varsyntax_calc1.error b/test/yacc/varsyntax_calc1.error new file mode 100644 index 00000000000..9c1f7152c30 --- /dev/null +++ b/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/test/yacc/varsyntax_calc1.output b/test/yacc/varsyntax_calc1.output new file mode 100644 index 00000000000..2b628d47ddb --- /dev/null +++ b/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/test/yacc/varsyntax_calc1.tab.c b/test/yacc/varsyntax_calc1.tab.c new file mode 100644 index 00000000000..c151810d423 --- /dev/null +++ b/test/yacc/varsyntax_calc1.tab.c @@ -0,0 +1,937 @@ +/* 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 2 +#define YYMINOR 0 +#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]; + +#ifdef YYSTYPE +#undef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#endif +#ifndef YYSTYPE_IS_DECLARED +#define YYSTYPE_IS_DECLARED 1 +#line 32 "varsyntax_calc1.y" +typedef union YYSTYPE +{ + 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 int 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 + +#if YYDEBUG +int yydebug; +#endif + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; +int yynerrs; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 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 494 "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 + + /* yym is set below */ + /* yyn is set below */ + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 59 "varsyntax_calc1.y" + { + (void) printf("%15.8f\n", yystack.l_mark[-1].dval); + } +#line 698 "varsyntax_calc1.tab.c" +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); + } +#line 705 "varsyntax_calc1.tab.c" +break; +case 5: +#line 67 "varsyntax_calc1.y" + { + dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; + } +#line 712 "varsyntax_calc1.tab.c" +break; +case 6: +#line 71 "varsyntax_calc1.y" + { + vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; + } +#line 719 "varsyntax_calc1.tab.c" +break; +case 7: +#line 75 "varsyntax_calc1.y" + { + yyerrok; + } +#line 726 "varsyntax_calc1.tab.c" +break; +case 9: +#line 82 "varsyntax_calc1.y" + { + yyval.dval = dreg[yystack.l_mark[0].ival]; /* $$ & $1 are sufficient here*/ + } +#line 733 "varsyntax_calc1.tab.c" +break; +case 10: +#line 86 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; + } +#line 740 "varsyntax_calc1.tab.c" +break; +case 11: +#line 90 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; + } +#line 747 "varsyntax_calc1.tab.c" +break; +case 12: +#line 94 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; + } +#line 754 "varsyntax_calc1.tab.c" +break; +case 13: +#line 98 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; + } +#line 761 "varsyntax_calc1.tab.c" +break; +case 14: +#line 102 "varsyntax_calc1.y" + { + yyval.dval = -yystack.l_mark[0].dval; + } +#line 768 "varsyntax_calc1.tab.c" +break; +case 15: +#line 106 "varsyntax_calc1.y" + { + yyval.dval = yystack.l_mark[-1].dval; + } +#line 775 "varsyntax_calc1.tab.c" +break; +case 16: +#line 112 "varsyntax_calc1.y" + { + yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; + } +#line 782 "varsyntax_calc1.tab.c" +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; + } + } +#line 795 "varsyntax_calc1.tab.c" +break; +case 18: +#line 126 "varsyntax_calc1.y" + { + yyval.vval = vreg[yystack.l_mark[0].ival]; + } +#line 802 "varsyntax_calc1.tab.c" +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; + } +#line 810 "varsyntax_calc1.tab.c" +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; + } +#line 818 "varsyntax_calc1.tab.c" +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; + } +#line 826 "varsyntax_calc1.tab.c" +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; + } +#line 834 "varsyntax_calc1.tab.c" +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 ); + } +#line 841 "varsyntax_calc1.tab.c" +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 ); + } +#line 848 "varsyntax_calc1.tab.c" +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 ); + } +#line 856 "varsyntax_calc1.tab.c" +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 ); + } +#line 864 "varsyntax_calc1.tab.c" +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; + } +#line 872 "varsyntax_calc1.tab.c" +break; +case 28: +#line 173 "varsyntax_calc1.y" + { + yyval.vval = yystack.l_mark[-1].vval; + } +#line 879 "varsyntax_calc1.tab.c" +break; +#line 881 "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) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/test/yacc/varsyntax_calc1.tab.h b/test/yacc/varsyntax_calc1.tab.h new file mode 100644 index 00000000000..50369b22642 --- /dev/null +++ b/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 YYSTYPE +{ + 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;