diff --git a/contrib/byacc/CHANGES b/contrib/byacc/CHANGES index 3aa6a9853eac..994fcc5ce4f4 100644 --- a/contrib/byacc/CHANGES +++ b/contrib/byacc/CHANGES @@ -1,3 +1,423 @@ +2020-03-30 Thomas E. Dickey + + * package/debian/copyright: bump + + * test/yacc/grammar.tab.c, test/btyacc/grammar.tab.c, test/grammar.y, reader.c: + typo found with codespell + + * yacc.1: fixes noted in the original report, overlooked in followup + +2020-03-30 Bjarni.Ingi.Gislason + + * yacc.1: typography/spelling fixes - Debian #955175 + +2020-03-30 Thomas E. Dickey + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2020-03-10 Thomas E. Dickey + + * configure: regen + + * aclocal.m4: + resync with my-autoconf, mostly fixes for compiler-warnings + + * configure.in: use macro to suppress X-dependency from newer macros + +2019-12-20 Thomas E. Dickey + + * config.guess: 2019-12-21 + +2019-11-25 Tom.Shields + + * main.c: + fix an inconsistency between the getopt and non-getopt configuration. + In the former, getopt always used "yacc", not the name of the executable. + +2019-11-25 Thomas E. Dickey + + * test/run_make.sh: + suppress bison's -Wyacc warning, which is not useful. + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2019-11-19 Thomas E. Dickey + + * yacc.1: new version of manpage + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * yacc.1: document %code + + * test/btyacc/calc_code_all.error, test/btyacc/calc_code_all.output, test/btyacc/calc_code_all.tab.c, test/btyacc/calc_code_all.tab.h, test/btyacc/calc_code_default.error, test/btyacc/calc_code_default.output, test/btyacc/calc_code_default.tab.c, test/btyacc/calc_code_default.tab.h, test/btyacc/calc_code_imports.error, test/btyacc/calc_code_imports.output, test/btyacc/calc_code_imports.tab.c, test/btyacc/calc_code_imports.tab.h, test/btyacc/calc_code_provides.error, test/btyacc/calc_code_provides.output, test/btyacc/calc_code_provides.tab.c, test/btyacc/calc_code_provides.tab.h, test/btyacc/calc_code_requires.error, test/btyacc/calc_code_requires.output, test/btyacc/calc_code_requires.tab.c, test/btyacc/calc_code_requires.tab.h, test/btyacc/calc_code_top.error, test/btyacc/calc_code_top.output, test/btyacc/calc_code_top.tab.c, test/btyacc/calc_code_top.tab.h, test/yacc/calc_code_all.tab.c, test/yacc/calc_code_all.tab.h, test/yacc/calc_code_default.tab.c, test/yacc/calc_code_provides.tab.c, test/yacc/calc_code_provides.tab.h, test/yacc/calc_code_requires.tab.c, test/yacc/calc_code_requires.tab.h, test/yacc/calc_code_top.tab.c: + RCS_BASE + + * output.c: + amend updates for 'outline' when processing "%code" in code-file + + * output.c: + modify output_code_lines() to show begin/end block comments which were in + reader.c, and to generate a #line for the code-file. + + * reader.c: + modify copy_code() to allow for multiple %code directives for a given + section, recording the input line-number for each directive as a #line + in the resulting string. remove the block start/end comments, since those + will be done for a whole section in output.c + + * mstring.c, defs.h: add msrenew() + + * test/yacc/calc_code_all.error, test/yacc/calc_code_all.output, test/yacc/calc_code_default.error, test/yacc/calc_code_default.output, test/yacc/calc_code_default.tab.h, test/yacc/calc_code_imports.error, test/yacc/calc_code_imports.output, test/yacc/calc_code_imports.tab.c, test/yacc/calc_code_imports.tab.h, test/yacc/calc_code_provides.error, test/yacc/calc_code_provides.output, test/yacc/calc_code_requires.error, test/yacc/calc_code_requires.output, test/yacc/calc_code_top.error, test/yacc/calc_code_top.output, test/yacc/calc_code_top.tab.h: + RCS_BASE + +2019-11-18 Thomas E. Dickey + + * test/calc_code_imports.y, test/calc_code_all.y, test/calc_code_default.y, test/calc_code_top.y, test/calc_code_provides.y, test/calc_code_requires.y: + RCS_BASE + +2019-11-04 Michael.Forney + + * defs.h: add missing "extern" for new variable "code_lines" + +2019-11-03 Thomas E. Dickey + + * main.c: build-fix for MinGW cross-compiling + + * output.c, reader.c: gcc-warnings + + * output.c: check validity of text_file before rewind + remove redundant check of iflag + + * main.c: fix memory-leak reported by clang + + * mkpar.c: guard against a null-reference reported by clang (unlikely) + + * reader.c: fix two coverity warnings: + a) resource leak on malloc-failure + b) possible null-pointer dereference on parse-error + + * test/btyacc/err_inherit4.tab.h, test/btyacc/btyacc_demo.tab.h: regen + + * defs.h: use enum's to simplify recent change + + * mstring.c: + enable mstring() in regular byacc, since Zoulas' change relies upon it + +2019-11-03 Christos.Zoulas + + * defs.h, reader.c, output.c: add support for bison's "%code" feature + also fix a small bug: declare YYLTYPE externally when producing locations + +2019-11-03 Thomas E. Dickey + + * test/btyacc/help.error, test/btyacc/no_b_opt.error, test/btyacc/no_output2.error, test/btyacc/no_p_opt.error, test/yacc/help.error, test/yacc/no_b_opt.error, test/yacc/no_output2.error, test/yacc/no_p_opt.error: + regen + + * test/run_test.sh: + there's no standard wording for the options-errors from getopt; + filter that to "error message" in the test reference files. + + * main.c: + provide for using getopt(), to accommodate a case where developers have + relied upon non-POSIX behavior. + + * test/run_test.sh: + getopt's messages do not print the full pathname of yacc in some cases; + adjust the sed-script which changes those to "YACC" + + * configure: regen + + * config_h.in: regen, using autoheader-252 + + * configure.in: add configure check for getopt + + * configure: regen + + * aclocal.m4: + resync with my-autoconf adds a fix which accommodates a difference in + warning options between gcc/clang when --enable-warnings is not set. + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2019-09-11 Thomas E. Dickey + + * config.guess, config.sub: 2019-09-10 + +2019-06-17 Thomas E. Dickey + + * test/btyacc/big_b.error, test/btyacc/big_l.error, test/btyacc/help.error, test/btyacc/no_b_opt.error, test/btyacc/no_output2.error, test/btyacc/no_p_opt.error, test/btyacc/nostdin.error, test/yacc/big_b.error, test/yacc/big_l.error, test/yacc/help.error, test/yacc/no_b_opt.error, test/yacc/no_output2.error, test/yacc/no_p_opt.error, test/yacc/nostdin.error: + regen + + * test/run_test.sh: test "-H" rather than "-D" + +2019-06-16 Thomas E. Dickey + + * main.c, yacc.1: + change "-D" option to "-H" (discussion with Ethan Sommer) + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * test/btyacc/defines1.calc.c, test/btyacc/defines2.calc.c, test/btyacc/defines3.calc.c: + RCS_BASE + + * test/run_test.sh: in test_defines, save the ".c" file too + + * test/yacc/defines3.calc.c, test/yacc/defines2.calc.c, test/yacc/defines1.calc.c: + RCS_BASE + + * test/run_test.sh: + output of test_defines should be a header ".h", not ".c" + + * test/btyacc/defines1.calc.h, test/btyacc/defines1.error, test/btyacc/defines1.output, test/btyacc/defines2.calc.h, test/btyacc/defines2.error, test/btyacc/defines2.output, test/btyacc/defines3.calc.h, test/btyacc/defines3.error, test/btyacc/defines3.output: + RCS_BASE + + * main.c: however, a subsequent -d cancels -D + + * test/yacc/defines1.calc.h, test/yacc/defines3.calc.h: RCS_BASE + + * main.c: -D option implies -d + + * test/yacc/defines1.error, test/yacc/defines1.output, test/yacc/defines2.calc.h, test/yacc/defines2.error, test/yacc/defines2.output, test/yacc/defines3.error, test/yacc/defines3.output: + RCS_BASE + + * yacc.1: align macro definitions with my other manpages + + * test/run_test.sh: add test for -D after -d or -b options + + * test/btyacc/stdin1.calc.c, test/btyacc/stdin1.error, test/btyacc/stdin1.output, test/btyacc/stdin2.calc.c, test/btyacc/stdin2.error, test/btyacc/stdin2.output: + RCS_BASE + + * test/btyacc/big_b.error, test/btyacc/big_b.output, test/btyacc/big_l.error, test/btyacc/big_l.output, test/btyacc/help.error, test/btyacc/help.output, test/btyacc/no_b_opt.error, test/btyacc/no_b_opt.output, test/btyacc/no_b_opt1.error, test/btyacc/no_b_opt1.output, test/btyacc/no_code_c.error, test/btyacc/no_code_c.output, test/btyacc/no_defines.error, test/btyacc/no_defines.output, test/btyacc/no_graph.error, test/btyacc/no_graph.output, test/btyacc/no_include.error, test/btyacc/no_include.output, test/btyacc/no_opts.error, test/btyacc/no_opts.output, test/btyacc/no_output.error, test/btyacc/no_output.output, test/btyacc/no_output1.error, test/btyacc/no_output1.output, test/btyacc/no_output2.error, test/btyacc/no_output2.output, test/btyacc/no_p_opt.error, test/btyacc/no_p_opt.output, test/btyacc/no_p_opt1.error, test/btyacc/no_p_opt1.output, test/btyacc/no_verbose.error, test/btyacc/no_verbose.output, test/btyacc/nostdin.error, test/btyacc/nostdin.output, test/yacc/big_b.error, test/yacc/big_b.output, test/yacc/big_l.error, test/yacc/big_l.output, test/yacc/help.error, test/yacc/help.output, test/yacc/no_b_opt.error, test/yacc/no_b_opt.output, test/yacc/no_b_opt1.error, test/yacc/no_b_opt1.output, test/yacc/no_code_c.error, test/yacc/no_code_c.output, test/yacc/no_defines.error, test/yacc/no_defines.output, test/yacc/no_graph.error, test/yacc/no_graph.output, test/yacc/no_include.error, test/yacc/no_include.output, test/yacc/no_opts.error, test/yacc/no_opts.output, test/yacc/no_output.error, test/yacc/no_output.output, test/yacc/no_output1.error, test/yacc/no_output1.output, test/yacc/no_output2.error, test/yacc/no_output2.output, test/yacc/no_p_opt.error, test/yacc/no_p_opt.output, test/yacc/no_p_opt1.error, test/yacc/no_p_opt1.output, test/yacc/no_verbose.error, test/yacc/no_verbose.output, test/yacc/nostdin.error, test/yacc/nostdin.output: + regen + + * test/run_test.sh: + add a test for stdin "-" vs end-options "--", and correct a redirection + of stderr in test_flags + + * test/yacc/stdin2.output, test/yacc/stdin2.calc.c, test/yacc/stdin1.calc.c, test/yacc/stdin1.error, test/yacc/stdin1.output, test/yacc/stdin2.error: + RCS_BASE + + * test/btyacc/big_b.output, test/btyacc/big_l.output, test/btyacc/help.output, test/btyacc/no_b_opt.output, test/btyacc/no_output2.output, test/btyacc/no_p_opt.output, test/btyacc/nostdin.output, test/yacc/big_b.output, test/yacc/big_l.output, test/yacc/help.output, test/yacc/no_b_opt.output, test/yacc/no_output2.output, test/yacc/no_p_opt.output, test/yacc/nostdin.output: + regen + + * main.c: add -D option, to specify filename vs y.tab.h for -d + + * defs.h: add dflag2, for -D option + + * yacc.1: document -D option + + * config_h.in: updated with autoheader-252 + + * configure: regen + + * package/debian/copyright: bump + + * aclocal.m4: add CF_GETOPT_HEADER + + * aclocal.m4: Improved autoconf macros: + + CF_CC_ENV_FLAGS + putting preprocessor flags in CFLAGS also is a nuisance, which can be + addressed in the same way. + + CF_GCC_WARNINGS + factor out workaround for XTSTRINGDEFINES as CF_CONST_X_STRING + + CF_GNU_SOURCE + The check for _DEFAULT_SOURCE should apply to "recent" Cygwin (since early 2016), + and except for "NEWLIB" vs "GLIBC" in the test, acts the same if I pretend + that "newlib" is the GNU C library. Without this, the check falls through + to the _XOPEN_SOURCE test, which breaks the pseudoterminal checks for xterm. + + CF_POSIX_C_SOURCE + add/use CF_POSIX_VISIBLE + + CF_TRY_XOPEN_SOURCE + use CF_APPEND_TEXT + + CF_WITH_MAN2HTML + use sed to work around non-POSIX tail utility + + CF_XOPEN_SOURCE + use CF_APPEND_TEXT + add/use CF_POSIX_VISIBLE + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2019-06-10 Thomas E. Dickey + + * config.guess: 2019-06-10 + +2019-05-22 Thomas E. Dickey + + * config.sub: 2019-05-22 + +2018-06-09 Thomas E. Dickey + + * yacc.1: minor typographical fixes + + * test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c, test/btyacc/expr.oxout.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/ok_syntax1.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/btyacc_destroy1.tab.c, test/btyacc/btyacc_destroy2.tab.c, test/btyacc/btyacc_destroy3.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/rename_debug.c, btyaccpar.c: + regen + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2018-06-09 Tom.Shields + + * btyaccpar.skel: + add casts to fix g++ (clang++) compile errors in the backtracking skeleton + due to assignment of ‘void *’ to another pointer type. + +2018-05-25 Thomas E. Dickey + + * test/run_make.sh: + check if this is bison 3+ before adding options to suppress warnings + + * package/byacc.spec: build-fix for Mageia 6 + + * package/byacc.spec: add btyacc package + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * package/debian/control: add a package for btyacc + + * package/debian/rules: generate a package for btyacc + +2018-05-24 Thomas E. Dickey + + * test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c, test/btyacc/expr.oxout.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/ok_syntax1.tab.c, btyaccpar.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/btyacc_destroy1.tab.c, test/btyacc/btyacc_destroy2.tab.c, test/btyacc/btyacc_destroy3.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/rename_debug.c: + regen + + * btyaccpar.skel: fix typo + +2018-05-21 Thomas E. Dickey + + * test/run_make.sh: + ignore case for "%" directives to skip with old-yacc, and add %token-table + to the list + + * btyaccpar.c: regen + +2018-05-21 Christos.Zoulas + + * btyaccpar.skel: + improve compatibility with bison by changing the YYLLOC_DEFAULT macro to use + YYRHSLOC() macro, and adjusting the array indices of yyerror_loc_range[] for + consistency. + +2018-05-10 Thomas E. Dickey + + * output.c: + add a fallback definition for YYDEBUG to the -i externs file. + + * test/btyacc/rename_debug.i, test/yacc/rename_debug.i: regen + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2018-05-09 Thomas E. Dickey + + * configure: regen + + * aclocal.m4: resync with my-autoconf + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * test/btyacc/rename_debug.i, btyaccpar.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/btyacc_destroy1.tab.c, test/btyacc/btyacc_destroy2.tab.c, test/btyacc/btyacc_destroy3.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c, test/btyacc/expr.oxout.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/ok_syntax1.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/rename_debug.c, test/btyacc/varsyntax_calc1.tab.c: + regen + + * btyaccpar.skel: apply Guy Harris' changes here as well + + * test/btyacc/rename_debug.i, test/yacc/rename_debug.i: regen + + * output.c: correct/improve fallback prototype for yylex() + + * test/btyacc/rename_debug.i, test/yacc/rename_debug.i: regen + +2018-05-08 Thomas E. Dickey + + * test/btyacc/grammar.tab.c, test/yacc/grammar.tab.c: regen + + * test/grammar.y: + quiet some warnings from gcc 7 when doing "make check_make" + + * package/debian/watch, package/pkgsrc/Makefile: update ftp-url + + * test/btyacc/ok_syntax1.tab.h, test/btyacc/btyacc_calc1.tab.h: regen + + * output.c: + provide yylex() declaration for simple case (request by "Mutiny") + + * test/yacc/err_syntax20.tab.c, test/yacc/error.tab.c, test/yacc/expr.oxout.tab.c, test/yacc/grammar.tab.c, test/yacc/ok_syntax1.tab.c, test/yacc/ok_syntax1.tab.h, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/rename_debug.c, test/yacc/rename_debug.i, yaccpar.c: + regen + + * VERSION, package/byacc.spec, package/debian/changelog, package/debian/copyright, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2018-05-06 Guy.Harris + + * yaccpar.skel: two fixes: + 1) define yydebug only if YYDEBUG is defined and + 2) make yynerrs a parser-local variable if the parser is reentrant. + +2018-02-24 Guy.Harris + + * output.c: do not emit "extern YYSTYPE yylval;" for pure parsers + +2018-02-05 Thomas E. Dickey + + * config.sub: 2018-01-15 + + * config.guess: 2018-01-26 + +2017-12-04 erik.b.andersen + + * main.c: A proper path for temporary files is needed by byacc under + Windows commandline, otherwise there's a risk of empty files. + The TEMP environment variable is always defined in Windows. + + * defs.h: The noreturn attribute needs to be specified before function + to be portable among compilers (gcc, clang, msvc). + +2017-12-04 Thomas E. Dickey + + * reader.c: adapted fix by Erik B: + a) increase the length of name[] to account for a trailing null + b) note that calling syntax_error() from get_number() does not return + +2017-09-14 Tom.Shields + + * yacc.1: fix typo + +2017-07-09 Thomas E. Dickey + + * package/byacc.spec, package/mingw-byacc.spec: + use predefined "configure" + + * reader.c: remove unused assignment + + * package/debian/rules: use dpkg-buildflags + + * configure: regen + + * aclocal.m4: resync with my-autoconf + + * reader.c, output.c, defs.h: + add/use IS_NAME1() and IS_NAME2() to reduce clutter + + * reader.c, output.c, defs.h: + guard against sign-extension in ctype-macros + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * reader.c: check for numeric overflow in get_number() + + * reader.c: + correct limit-checks for input filename and line-number, in case no valid + filename and/or number was found. + 2017-04-30 Thomas E. Dickey * test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c, test/btyacc/expr.oxout.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/ok_syntax1.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/btyacc_destroy1.tab.c, test/btyacc/btyacc_destroy2.tab.c, test/btyacc/btyacc_destroy3.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/rename_debug.c, btyaccpar.c, btyaccpar.skel: @@ -22,6 +442,10 @@ * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: bump +2017-04-29 Thomas E. Dickey + + * config.sub: 2017-04-02 + 2017-03-18 Thomas E. Dickey * config.sub: 2017-02-07 @@ -2558,7 +2982,7 @@ * vmsbuild.com: original version -2000-02-23 dickey@clark.net +2000-02-23 Thomas E. Dickey * test/RCS, RCS: PERMIT FILE @@ -2597,7 +3021,7 @@ * test/ftp.output, test/ftp.tab.c, test/ftp.tab.h: RCS_BASE -1993-02-22 Thomas E. Dickey +1993-02-22 dickey@software.org * test/yacc/error.output, test/yacc/error.tab.h: reference output for testing @@ -2637,7 +3061,7 @@ * symtab.c, lalr.c, error.c: original version -1990-01-16 Thomas E. Dickey +1990-01-16 dickey@software.org * test/code_error.y, test/pure_error.y: RCS_BASE diff --git a/contrib/byacc/MANIFEST b/contrib/byacc/MANIFEST index cd0dbdfa036d..8afb19f27af0 100644 --- a/contrib/byacc/MANIFEST +++ b/contrib/byacc/MANIFEST @@ -1,4 +1,4 @@ -MANIFEST for byacc-20170430, version t20170430 +MANIFEST for byacc-20200330, version t20200330 -------------------------------------------------------------------------------- MANIFEST this file ACKNOWLEDGEMENTS original version of byacc - 1993 @@ -77,10 +77,6 @@ test/btyacc/btyacc_demo.error reference output for testing test/btyacc/btyacc_demo.output reference output for testing test/btyacc/btyacc_demo.tab.c reference output for testing test/btyacc/btyacc_demo.tab.h reference output for testing -test/btyacc/btyacc_demo2.error reference output for testing -test/btyacc/btyacc_demo2.output reference output for testing -test/btyacc/btyacc_demo2.tab.c reference output for testing -test/btyacc/btyacc_demo2.tab.h reference output for testing test/btyacc/btyacc_destroy1.error reference output for testing test/btyacc/btyacc_destroy1.output reference output for testing test/btyacc/btyacc_destroy1.tab.c reference output for testing @@ -114,11 +110,6 @@ test/btyacc/code_calc.error reference output for testing test/btyacc/code_calc.output reference output for testing test/btyacc/code_calc.tab.c reference output for testing test/btyacc/code_calc.tab.h reference output for testing -test/btyacc/code_debug.c reference for test-output -test/btyacc/code_debug.error reference for test-output -test/btyacc/code_debug.h reference for test-output -test/btyacc/code_debug.i reference for test-output -test/btyacc/code_debug.output reference for test-output test/btyacc/code_error.code.c reference output for testing test/btyacc/code_error.error reference output for testing test/btyacc/code_error.output reference output for testing @@ -382,6 +373,7 @@ test/btyacc_demo.y testcase for btyacc test/btyacc_destroy1.y btyacc test-case for %parse-param test/btyacc_destroy2.y btyacc test-case for %parse-param test/btyacc_destroy3.y btyacc test-case for %parse-param +test/calc.tab.c c-file for calc.y test/calc.y example from VMS freeware version of byacc test/calc1.y advanced example from Steve Johnson's paper. test/calc2.y test-cases and reference files for %lex-param / %parse-param diff --git a/contrib/byacc/VERSION b/contrib/byacc/VERSION index 59aff9a1ff47..e597618f32bd 100644 --- a/contrib/byacc/VERSION +++ b/contrib/byacc/VERSION @@ -1 +1 @@ -20170430 +20200330 diff --git a/contrib/byacc/aclocal.m4 b/contrib/byacc/aclocal.m4 index a3d6aa04d5f2..22570b68b3e4 100644 --- a/contrib/byacc/aclocal.m4 +++ b/contrib/byacc/aclocal.m4 @@ -1,7 +1,7 @@ -dnl $Id: aclocal.m4,v 1.42 2017/02/01 10:12:21 tom Exp $ +dnl $Id: aclocal.m4,v 1.48 2020/03/10 22:53:47 tom Exp $ dnl Macros for byacc configure script (Thomas E. Dickey) dnl --------------------------------------------------------------------------- -dnl Copyright 2004-2016,2017 Thomas E. Dickey +dnl Copyright 2004-2019,2020 Thomas E. Dickey dnl dnl Permission is hereby granted, free of charge, to any person obtaining a dnl copy of this software and associated documentation files (the @@ -54,7 +54,7 @@ define([CF_ACVERSION_COMPARE], [ifelse([$8], , ,[$8])], [ifelse([$9], , ,[$9])])])dnl dnl --------------------------------------------------------------------------- -dnl CF_ADD_CFLAGS version: 12 updated: 2015/04/12 15:39:00 +dnl CF_ADD_CFLAGS version: 13 updated: 2017/02/25 18:57:40 dnl ------------- dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS dnl The second parameter if given makes this macro verbose. @@ -84,10 +84,10 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags) continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags) continue fi ;; @@ -102,17 +102,17 @@ case $cf_fix_cppflags in CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags) ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags) ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags) ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags) cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'` @@ -125,21 +125,31 @@ done if test -n "$cf_new_cflags" ; then ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)]) - CFLAGS="$CFLAGS $cf_new_cflags" + CF_APPEND_TEXT(CFLAGS,$cf_new_cflags) fi if test -n "$cf_new_cppflags" ; then ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)]) - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" + CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags) fi if test -n "$cf_new_extra_cppflags" ; then ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)]) - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" + CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags) fi AC_SUBST(EXTRA_CPPFLAGS) +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55 +dnl -------------- +dnl use this macro for appending text without introducing an extra blank at +dnl the beginning +define([CF_APPEND_TEXT], +[ + test -n "[$]$1" && $1="[$]$1 " + $1="[$]{$1}$2" ])dnl dnl --------------------------------------------------------------------------- dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31 @@ -171,7 +181,7 @@ ifelse([$3],,[ :]dnl ])dnl ])])dnl dnl --------------------------------------------------------------------------- -dnl CF_CC_ENV_FLAGS version: 6 updated: 2016/08/29 20:57:00 +dnl CF_CC_ENV_FLAGS version: 9 updated: 2018/07/29 18:03:26 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 @@ -188,19 +198,37 @@ AC_DEFUN([CF_CC_ENV_FLAGS], # This should have been defined by AC_PROG_CC : ${CC:=cc} +AC_MSG_CHECKING(\$CFLAGS variable) +case "x$CFLAGS" in +(*-[[IUD]]*) + AC_MSG_RESULT(broken) + AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options) + cf_flags="$CFLAGS" + CFLAGS= + for cf_arg in $cf_flags + do + CF_ADD_CFLAGS($cf_arg) + done + ;; +(*) + AC_MSG_RESULT(ok) + ;; +esac + AC_MSG_CHECKING(\$CC variable) case "$CC" in (*[[\ \ ]]-*) AC_MSG_RESULT(broken) - AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options) + AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options) # humor him... - cf_flags=`echo "$CC" | sed -e 's/^.*[[ ]]\(-[[^ ]]\)/\1/'` - CC=`echo "$CC " | sed -e 's/[[ ]]-[[^ ]].*$//' -e 's/[[ ]]*$//'` + 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))); }'` + CC="$cf_prog" for cf_arg in $cf_flags do case "x$cf_arg" in (x-[[IUDfgOW]]*) - CF_ADD_CFLAGS($cf_flags) + CF_ADD_CFLAGS($cf_arg) ;; (*) CC="$CC $cf_arg" @@ -285,6 +313,66 @@ cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments" fi ]) dnl --------------------------------------------------------------------------- +dnl CF_CONST_X_STRING version: 4 updated: 2020/03/10 18:53:47 +dnl ----------------- +dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most +dnl character-strings. +dnl +dnl It is ambiguous because the specification accommodated the pre-ANSI +dnl compilers bundled by more than one vendor in lieu of providing a standard C +dnl compiler other than by costly add-ons. Because of this, the specification +dnl did not take into account the use of const for telling the compiler that +dnl string literals would be in readonly memory. +dnl +dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to +dnl let the compiler decide how to represent Xt's strings which were #define'd. +dnl That does not solve the problem of using the block of Xt's strings which +dnl are compiled into the library (and is less efficient than one might want). +dnl +dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both +dnl when compiling the library and compiling using the library, to tell the +dnl compiler that String is const. +AC_DEFUN([CF_CONST_X_STRING], +[ +AC_REQUIRE([AC_PATH_XTRA]) + +CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING]) + +AC_TRY_COMPILE( +[ +#include +#include +], +[String foo = malloc(1); (void)foo],[ + +AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[ + AC_TRY_COMPILE( + [ +#define _CONST_X_STRING /* X11R7.8 (perhaps) */ +#undef XTSTRINGDEFINES /* X11R5 and later */ +#include +#include + ],[String foo = malloc(1); *foo = 0],[ + cf_cv_const_x_string=no + ],[ + cf_cv_const_x_string=yes + ]) +]) + +CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING]) + +case $cf_cv_const_x_string in +(no) + CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES) + ;; +(*) + CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING) + ;; +esac + +]) +])dnl +dnl --------------------------------------------------------------------------- dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57 dnl --------------- dnl You can always use "make -n" to see the actual options, but it's hard to @@ -345,7 +433,7 @@ if test "$with_no_leaks" = yes ; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00 +dnl CF_GCC_ATTRIBUTES version: 18 updated: 2020/03/10 18:53:47 dnl ----------------- dnl Test for availability of useful gcc __attribute__ directives to quiet dnl compiler warnings. Though useful, not all are supported -- and contrary @@ -389,7 +477,7 @@ cat > conftest.$ac_ext < conftest.$ac_ext <], +[int x = optind; char *y = optarg], +[cf_cv_getopt_header=$cf_header + break]) +done +]) +if test $cf_cv_getopt_header != none ; then + AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header]) +fi +if test $cf_cv_getopt_header = getopt.h ; then + AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h]) +fi +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41 dnl ------------- dnl Check if we must define _GNU_SOURCE to get a reasonable value for dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect @@ -598,38 +709,106 @@ dnl (or misfeature) of glibc2, which breaks portability of many applications, dnl since it is interwoven with GNU extensions. dnl dnl Well, yes we could work around it... +dnl +dnl Parameters: +dnl $1 is the nominal value for _XOPEN_SOURCE AC_DEFUN([CF_GNU_SOURCE], [ -AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[ +cf_gnu_xopen_source=ifelse($1,,500,$1) + +AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[ AC_TRY_COMPILE([#include ],[ -#ifndef _XOPEN_SOURCE -make an error -#endif], - [cf_cv_gnu_source=no], - [cf_save="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" - AC_TRY_COMPILE([#include ],[ -#ifdef _XOPEN_SOURCE -make an error -#endif], - [cf_cv_gnu_source=no], - [cf_cv_gnu_source=yes]) - CPPFLAGS="$cf_save" - ]) + #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0 + return 0; + #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0 + return 0; + #else + # error not GNU C library + #endif], + [cf_cv_gnu_library=yes], + [cf_cv_gnu_library=no]) ]) -if test "$cf_cv_gnu_source" = yes -then -AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[ -CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" - AC_TRY_COMPILE([#include ],[ -#ifdef _DEFAULT_SOURCE -make an error -#endif], - [cf_cv_default_source=no], - [cf_cv_default_source=yes]) +if test x$cf_cv_gnu_library = xyes; then + + # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE + # was changed to help a little. newlib incorporated the change about 4 + # years later. + AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[ + cf_save="$CPPFLAGS" + CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE) + AC_TRY_COMPILE([#include ],[ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2) + return 0; + #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3) + return 0; + #else + # error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old + #endif], + [cf_cv_gnu_library_219=yes], + [cf_cv_gnu_library_219=no]) + CPPFLAGS="$cf_save" ]) -test "$cf_cv_default_source" = yes && CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE" + + if test "x$cf_cv_gnu_library_219" = xyes; then + cf_save="$CPPFLAGS" + AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[ + CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source) + AC_TRY_COMPILE([ + #include + #include + ],[ + #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1) + return 0; + #else + # error GNU C library is too old + #endif], + [cf_cv_gnu_dftsrc_219=yes], + [cf_cv_gnu_dftsrc_219=no]) + ]) + test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save" + else + cf_cv_gnu_dftsrc_219=maybe + fi + + if test "x$cf_cv_gnu_dftsrc_219" != xyes; then + + AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[ + AC_TRY_COMPILE([#include ],[ + #ifndef _XOPEN_SOURCE + #error expected _XOPEN_SOURCE to be defined + #endif], + [cf_cv_gnu_source=no], + [cf_save="$CPPFLAGS" + CF_ADD_CFLAGS(-D_GNU_SOURCE) + AC_TRY_COMPILE([#include ],[ + #ifdef _XOPEN_SOURCE + #error expected _XOPEN_SOURCE to be undefined + #endif], + [cf_cv_gnu_source=no], + [cf_cv_gnu_source=yes]) + CPPFLAGS="$cf_save" + ]) + ]) + + if test "$cf_cv_gnu_source" = yes + then + AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[ + CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE) + AC_TRY_COMPILE([#include ],[ + #ifdef _DEFAULT_SOURCE + #error expected _DEFAULT_SOURCE to be undefined + #endif], + [cf_cv_default_source=no], + [cf_cv_default_source=yes]) + ]) + if test "$cf_cv_default_source" = yes + then + CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE) + fi + fi + fi + fi ])dnl dnl --------------------------------------------------------------------------- @@ -935,7 +1114,7 @@ case ".[$]$1" in esac ])dnl dnl --------------------------------------------------------------------------- -dnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00 +dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17 dnl ----------------- dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed. dnl @@ -950,7 +1129,10 @@ dnl dnl Parameters: dnl $1 is the nominal value for _POSIX_C_SOURCE AC_DEFUN([CF_POSIX_C_SOURCE], -[ +[AC_REQUIRE([CF_POSIX_VISIBLE])dnl + +if test "$cf_cv_posix_visible" = no; then + cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1]) cf_save_CFLAGS="$CFLAGS" @@ -988,7 +1170,8 @@ make an error fi CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE) CFLAGS="$cf_trim_CFLAGS" - CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" + CPPFLAGS="$cf_trim_CPPFLAGS" + CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source) CF_MSG_LOG(if the second compile does not leave our definition intact error) AC_TRY_COMPILE([#include ],[ #ifndef _POSIX_C_SOURCE @@ -1006,6 +1189,35 @@ if test "$cf_cv_posix_c_source" != no ; then CF_ADD_CFLAGS($cf_cv_posix_c_source) fi +fi # cf_cv_posix_visible + +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17 +dnl ---------------- +dnl POSIX documents test-macros which an application may set before any system +dnl headers are included to make features available. +dnl +dnl Some BSD platforms (originally FreeBSD, but copied by a few others) +dnl diverged from POSIX in 2002 by setting symbols which make all of the most +dnl recent features visible in the system header files unless the application +dnl overrides the corresponding test-macros. Doing that introduces portability +dnl problems. +dnl +dnl This macro makes a special check for the symbols used for this, to avoid a +dnl conflicting definition. +AC_DEFUN([CF_POSIX_VISIBLE], +[ +AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[ +AC_TRY_COMPILE([#include ],[ +#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \ + && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \ + && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \ + && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0) +#error conflicting symbols found +#endif +],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes]) +]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59 @@ -1017,11 +1229,15 @@ AC_PROG_AWK test -z "$AWK" && AC_MSG_ERROR(No awk program found) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58 +dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54 dnl ---------- dnl standard check for CC, plus followup sanity checks dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name AC_DEFUN([CF_PROG_CC],[ +CF_ACVERSION_CHECK(2.53, + [AC_MSG_WARN(this will incorrectly handle gnatgcc choice) + AC_REQUIRE([AC_PROG_CC])], + []) ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)]) CF_GCC_VERSION CF_ACVERSION_CHECK(2.52, @@ -1030,13 +1246,14 @@ CF_ACVERSION_CHECK(2.52, CF_CC_ENV_FLAGS ])dnl dnl --------------------------------------------------------------------------- -dnl CF_PROG_GROFF version: 2 updated: 2015/07/04 11:16:27 +dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19 dnl ------------- dnl Check if groff is available, for cases (such as html output) where nroff dnl is not enough. AC_DEFUN([CF_PROG_GROFF],[ AC_PATH_PROG(GROFF_PATH,groff,no) -AC_PATH_PROG(NROFF_PATH,nroff,no) +AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no) +AC_PATH_PROG(TBL_PATH,tbl,cat) if test "x$GROFF_PATH" = xno then NROFF_NOTE= @@ -1049,11 +1266,16 @@ AC_SUBST(GROFF_NOTE) AC_SUBST(NROFF_NOTE) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_PROG_LINT version: 3 updated: 2016/05/22 15:25:54 +dnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37 dnl ------------ AC_DEFUN([CF_PROG_LINT], [ AC_CHECK_PROGS(LINT, lint cppcheck splint) +case "x$LINT" in +(xcppcheck|x*/cppcheck) + test -z "$LINT_OPTS" && LINT_OPTS="--enable=all" + ;; +esac AC_SUBST(LINT_OPTS) ])dnl dnl --------------------------------------------------------------------------- @@ -1074,7 +1296,7 @@ $1=`echo "$2" | \ -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'` ])dnl dnl --------------------------------------------------------------------------- -dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50 +dnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13 dnl ------------------- dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we dnl can define it successfully. @@ -1090,7 +1312,7 @@ make an error #endif], [cf_cv_xopen_source=no], [cf_save="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" + CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE) AC_TRY_COMPILE([ #include #include @@ -1130,6 +1352,14 @@ AC_DEFUN([CF_VERBOSE], CF_MSG_LOG([$1]) ])dnl dnl --------------------------------------------------------------------------- +dnl CF_WITHOUT_X version: 1 updated: 2020/03/03 18:27:24 +dnl ------------ +dnl Use this to cancel the check for X headers/libraries which would be pulled +dnl in via CF_GCC_WARNINGS. +define([CF_WITHOUT_X], +AC_DEFUN([CF_CONST_X_STRING],[echo "skipping X-const check";])dnl +[])dnl +dnl --------------------------------------------------------------------------- dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47 dnl ---------------- dnl Configure-option for dbmalloc. The optional parameter is used to override @@ -1160,9 +1390,13 @@ if test "$with_dmalloc" = yes ; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_WITH_MAN2HTML version: 5 updated: 2015/08/20 04:51:36 +dnl CF_WITH_MAN2HTML version: 8 updated: 2018/06/27 18:44:03 dnl ---------------- -dnl Check for man2html and groff. Optionally prefer man2html over groff. +dnl Check for man2html and groff. Prefer man2html over groff, but use groff +dnl as a fallback. See +dnl +dnl http://invisible-island.net/scripts/man2html.html +dnl dnl Generate a shell script which hides the differences between the two. dnl dnl We name that "man2html.tmp". @@ -1171,11 +1405,35 @@ dnl The shell script can be removed later, e.g., using "make distclean". AC_DEFUN([CF_WITH_MAN2HTML],[ AC_REQUIRE([CF_PROG_GROFF]) +case "x${with_man2html}" in +(xno) + cf_man2html=no + ;; +(x|xyes) + AC_PATH_PROG(cf_man2html,man2html,no) + case "x$cf_man2html" in + (x/*) + AC_MSG_CHECKING(for the modified Earl Hood script) + if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null ) + then + cf_man2html_ok=yes + else + cf_man2html=no + cf_man2html_ok=no + fi + AC_MSG_RESULT($cf_man2html_ok) + ;; + (*) + cf_man2html=no + ;; + esac +esac + AC_MSG_CHECKING(for program to convert manpage to html) AC_ARG_WITH(man2html, [ --with-man2html=XXX use XXX rather than groff], [cf_man2html=$withval], - [cf_man2html=$GROFF_PATH]) + [cf_man2html=$cf_man2html]) cf_with_groff=no @@ -1223,7 +1481,7 @@ then MAN2HTML_NOTE="$GROFF_NOTE" MAN2HTML_PATH="$GROFF_PATH" cat >>$MAN2HTML_TEMP <conftest.out + LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'` cf_man2html_top=`expr $cf_man2html_1st - 2` @@ -1266,8 +1524,8 @@ CF_EOF CF_EOF done - LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out - cf_man2html_page=`fgrep -n HEAD1 conftest.out |tail -n 1 |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'` + LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out + cf_man2html_page=`fgrep -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'` test -z "$cf_man2html_page" && cf_man2html_page=99999 test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999 @@ -1279,10 +1537,10 @@ CF_EOF MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page" case \${TYPE} in (ms) - tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS + $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS ;; (*) - tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS + $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS ;; esac CF_EOF @@ -1326,7 +1584,7 @@ fi fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_XOPEN_SOURCE version: 52 updated: 2016/08/27 12:21:42 +dnl CF_XOPEN_SOURCE version: 55 updated: 2018/12/31 20:46:17 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, @@ -1337,6 +1595,9 @@ dnl $1 is the nominal value for _XOPEN_SOURCE dnl $2 is the nominal value for _POSIX_C_SOURCE AC_DEFUN([CF_XOPEN_SOURCE],[ AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([CF_POSIX_VISIBLE]) + +if test "$cf_cv_posix_visible" = no; then cf_XOPEN_SOURCE=ifelse([$1],,500,[$1]) cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2]) @@ -1356,7 +1617,7 @@ case $host_os in cf_xopen_source="-D_DARWIN_C_SOURCE" cf_XOPEN_SOURCE= ;; -(freebsd*|dragonfly*) +(freebsd*|dragonfly*|midnightbsd*) # 5.x headers associate # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L @@ -1375,7 +1636,7 @@ case $host_os in cf_XOPEN_SOURCE= ;; (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin) - CF_GNU_SOURCE + CF_GNU_SOURCE($cf_XOPEN_SOURCE) ;; (minix*) cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this... @@ -1451,4 +1712,5 @@ make an error CF_TRY_XOPEN_SOURCE fi fi +fi # cf_cv_posix_visible ]) diff --git a/contrib/byacc/btyaccpar.c b/contrib/byacc/btyaccpar.c index 786978afd817..64a9febd17e4 100644 --- a/contrib/byacc/btyaccpar.c +++ b/contrib/byacc/btyaccpar.c @@ -2,7 +2,7 @@ * @Id: skel2c,v 1.4 2016/06/07 00:26:09 tom Exp @ */ -/* @Id: btyaccpar.skel,v 1.6 2017/04/30 23:40:34 tom Exp @ */ +/* @Id: btyaccpar.skel,v 1.10 2018/05/25 01:03:46 tom Exp @ */ #include "defs.h" @@ -78,8 +78,9 @@ const char *const tables[] = const char *const global_vars[] = { "", + "#if YYDEBUG", "int yydebug;", - "int yynerrs;", + "#endif", 0 }; @@ -90,6 +91,8 @@ const char *const impure_vars[] = "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 */", @@ -107,17 +110,17 @@ const char *const hdr_defs[] = "{ \\", " if (n == 0) \\", " { \\", - " (loc).first_line = ((rhs)[-1]).last_line; \\", - " (loc).first_column = ((rhs)[-1]).last_column; \\", - " (loc).last_line = ((rhs)[-1]).last_line; \\", - " (loc).last_column = ((rhs)[-1]).last_column; \\", + " (loc).first_line = YYRHSLOC(rhs, 0).last_line; \\", + " (loc).first_column = YYRHSLOC(rhs, 0).last_column; \\", + " (loc).last_line = YYRHSLOC(rhs, 0).last_line; \\", + " (loc).last_column = YYRHSLOC(rhs, 0).last_column; \\", " } \\", " else \\", " { \\", - " (loc).first_line = ((rhs)[ 0 ]).first_line; \\", - " (loc).first_column = ((rhs)[ 0 ]).first_column; \\", - " (loc).last_line = ((rhs)[n-1]).last_line; \\", - " (loc).last_column = ((rhs)[n-1]).last_column; \\", + " (loc).first_line = YYRHSLOC(rhs, 1).first_line; \\", + " (loc).first_column = YYRHSLOC(rhs, 1).first_column; \\", + " (loc).last_line = YYRHSLOC(rhs, n).last_line; \\", + " (loc).last_column = YYRHSLOC(rhs, n).last_column; \\", " } \\", "} while (0)", "#endif /* YYLLOC_DEFAULT */", @@ -232,6 +235,8 @@ const char *const body_vars[] = " 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 */", @@ -436,7 +441,7 @@ const char *const body_2[] = "#endif /* YYBTYACC */", #endif /* defined(YYBTYACC) */ "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", - " YYLTYPE yyerror_loc_range[2]; /* position of error start & end */", + " YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */", "#endif", "#if YYDEBUG", " const char *yys;", @@ -525,10 +530,10 @@ const char *const body_3[] = " size_t s = (size_t) (yylvlim - yylvals);", "", " s += YYLVQUEUEGROWTH;", - " if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;", - " if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;", + " if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;", + " if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;", "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", - " if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;", + " if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;", "#endif", " yylvp = yylve = yylvals + p;", " yylvlim = yylvals + s;", @@ -645,7 +650,7 @@ const char *const body_3[] = " /* If this is a first conflict in the stack, start saving lexemes */", " if (!yylexemes)", " {", - " yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));", + " yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));", " if (yylexemes == NULL) goto yyenomem;", " yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));", " if (yylvals == NULL) goto yyenomem;", @@ -858,7 +863,7 @@ const char *const body_3[] = "", " YYERROR_CALL(\"syntax error\");", "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", - " yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */", + " yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */", "#endif", "", "#if !YYBTYACC", @@ -887,7 +892,7 @@ const char *const body_3[] = " *++yystack.l_mark = yylval;", "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", " /* lookahead position is error end position */", - " yyerror_loc_range[1] = yylloc;", + " yyerror_loc_range[2] = yylloc;", " YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */", " *++yystack.p_mark = yyloc;", "#endif", @@ -903,7 +908,7 @@ const char *const body_3[] = " if (yystack.s_mark <= yystack.s_base) goto yyabort;", "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", " /* the current TOS position is the error start position */", - " yyerror_loc_range[0] = *yystack.p_mark;", + " yyerror_loc_range[1] = *yystack.p_mark;", "#endif", "#if defined(YYDESTRUCT_CALL)", #if defined(YYBTYACC) @@ -997,10 +1002,10 @@ const char *const body_3[] = "#endif /* YYBTYACC */", #endif /* defined(YYBTYACC) */ " {", - " YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);", + " YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);", " /* just in case YYERROR is invoked within the action, save", " the start of the rhs as the error start position */", - " yyerror_loc_range[0] = yystack.p_mark[1-yym];", + " yyerror_loc_range[1] = yystack.p_mark[1-yym];", " }", "#endif", "", @@ -1068,12 +1073,12 @@ const char *const trailer[] = " size_t s = (size_t) (yylvlim - yylvals);", "", " s += YYLVQUEUEGROWTH;", - " if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)", + " if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)", " goto yyenomem;", - " if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)", + " if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)", " goto yyenomem;", "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", - " if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)", + " if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)", " goto yyenomem;", "#endif", " yylvp = yylve = yylvals + p;", diff --git a/contrib/byacc/btyaccpar.skel b/contrib/byacc/btyaccpar.skel index 6f20d7dc5a54..009942ee041f 100644 --- a/contrib/byacc/btyaccpar.skel +++ b/contrib/byacc/btyaccpar.skel @@ -1,4 +1,4 @@ -/* $Id: btyaccpar.skel,v 1.7 2017/05/01 00:13:19 tom Exp $ */ +/* $Id: btyaccpar.skel,v 1.11 2018/06/10 00:41:06 Tom.Shields Exp $ */ #include "defs.h" @@ -53,14 +53,17 @@ extern const char *const yyrule[]; #endif %% global_vars +#if YYDEBUG int yydebug; -int yynerrs; +#endif %% impure_vars 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 */ @@ -74,17 +77,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -185,6 +188,8 @@ static YYINT *yylexemes = 0; 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 */ @@ -371,7 +376,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; %%endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -449,10 +454,10 @@ yyloop: size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -563,7 +568,7 @@ yyloop: /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -773,7 +778,7 @@ yyerrhandler: YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -802,7 +807,7 @@ yyinrecovery: *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -818,7 +823,7 @@ yyinrecovery: if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) %%ifdef YYBTYACC @@ -904,10 +909,10 @@ yyreduce: if (!yytrial) %%endif { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -968,12 +973,12 @@ yyreduce: size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/config.guess b/contrib/byacc/config.guess index 69ed3e573bb3..95b16c7747a1 100755 --- a/contrib/byacc/config.guess +++ b/contrib/byacc/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2019 Free Software Foundation, Inc. -timestamp='2017-03-05' +timestamp='2019-12-21' # 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 @@ -15,7 +15,7 @@ timestamp='2017-03-05' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,7 +27,7 @@ timestamp='2017-03-05' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . @@ -39,7 +39,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2019 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." @@ -84,8 +84,6 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a @@ -96,34 +94,40 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$driver" + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi @@ -132,14 +136,14 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu - eval $set_cc_for_build - cat <<-EOF > $dummy.c + set_cc_for_build + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc @@ -149,13 +153,20 @@ Linux|GNU|GNU/*) LIBC=gnu #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -169,30 +180,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-unknown + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -208,10 +219,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -219,45 +230,60 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" + echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + exit ;; + *:OS108:*:*) + echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) - echo ${UNAME_MACHINE}-unknown-sortix + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Twizzler:*:*) + echo "$UNAME_MACHINE"-unknown-twizzler + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in @@ -310,28 +336,19 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -343,7 +360,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos @@ -370,19 +387,19 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build + set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. @@ -395,13 +412,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -410,25 +427,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -439,44 +456,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -485,23 +502,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -527,17 +544,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -554,7 +571,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id @@ -566,14 +583,14 @@ EOF if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -584,7 +601,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else @@ -598,7 +615,7 @@ EOF exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc @@ -607,18 +624,18 @@ EOF IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -633,28 +650,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in + case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in + case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if [ "$HP_ARCH" = "" ]; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -687,13 +704,13 @@ EOF exit (0); } EOF - (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = hppa2.0w ] + if [ "$HP_ARCH" = hppa2.0w ] then - eval $set_cc_for_build + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -712,15 +729,15 @@ EOF HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -745,11 +762,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -758,7 +775,7 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) @@ -766,9 +783,9 @@ EOF exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -793,131 +810,123 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi + else + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf + fi exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin + echo x86_64-pc-cygwin exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -928,140 +937,168 @@ EOF esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} + echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} + echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} + echo powerpcle-unknown-linux-"$LIBC" exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1075,34 +1112,34 @@ EOF # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) @@ -1112,12 +1149,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1127,9 +1164,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1149,9 +1186,9 @@ EOF exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1171,9 +1208,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1182,28 +1219,28 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1214,7 +1251,7 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1234,23 +1271,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1269,60 +1306,68 @@ EOF echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux${UNAME_RELEASE} + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` @@ -1330,22 +1375,25 @@ EOF UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" exit ;; - NSX-?:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk${UNAME_RELEASE} + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1354,18 +1402,19 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. + # shellcheck disable=SC2154 if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1386,14 +1435,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1402,32 +1451,184 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; + *:Unleashed:*:*) + echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" + exit ;; +esac + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 </dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/contrib/byacc/config.sub b/contrib/byacc/config.sub index 87abeab6cdfc..0f2234c174d4 100755 --- a/contrib/byacc/config.sub +++ b/contrib/byacc/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2019 Free Software Foundation, Inc. -timestamp='2017-02-07' +timestamp='2019-06-30' # 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 @@ -15,7 +15,7 @@ timestamp='2017-02-07' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +33,7 @@ timestamp='2017-02-07' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -57,7 +57,7 @@ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -67,7 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2019 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." @@ -89,12 +89,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -110,1247 +110,1164 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 + *-*-*-*) + basic_machine=$field1-$field2 + os=$field3-$field4 ;; - -bluegene*) - os=-cnk + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \ + | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + os=linux-android + ;; + *) + basic_machine=$field1-$field2 + os=$field3 + ;; + esac ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + os= + ;; + *) + basic_machine=$field1 + os=$field2 + ;; + esac + ;; + esac ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + os=bsd + ;; + a29khif) + basic_machine=a29k-amd + os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=scout + ;; + alliant) + basic_machine=fx80-alliant + os= + ;; + altos | altos3068) + basic_machine=m68k-altos + os= + ;; + am29k) + basic_machine=a29k-none + os=bsd + ;; + amdahl) + basic_machine=580-amdahl + os=sysv + ;; + amiga) + basic_machine=m68k-unknown + os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=bsd + ;; + aros) + basic_machine=i386-pc + os=aros + ;; + aux) + basic_machine=m68k-apple + os=aux + ;; + balance) + basic_machine=ns32k-sequent + os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=linux + ;; + cegcc) + basic_machine=arm-unknown + os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=bsd + ;; + convex-c2) + basic_machine=c2-convex + os=bsd + ;; + convex-c32) + basic_machine=c32-convex + os=bsd + ;; + convex-c34) + basic_machine=c34-convex + os=bsd + ;; + convex-c38) + basic_machine=c38-convex + os=bsd + ;; + cray) + basic_machine=j90-cray + os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + os= + ;; + da30) + basic_machine=m68k-da30 + os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + os= + ;; + delta88) + basic_machine=m88k-motorola + os=sysv3 + ;; + dicos) + basic_machine=i686-pc + os=dicos + ;; + djgpp) + basic_machine=i586-pc + os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=ose + ;; + gmicro) + basic_machine=tron-gmicro + os=sysv + ;; + go32) + basic_machine=i386-pc + os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=hms + ;; + harris) + basic_machine=m88k-harris + os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=proelf + ;; + i386mach) + basic_machine=i386-mach + os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + os=sysv + ;; + merlin) + basic_machine=ns32k-utek + os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + os=coff + ;; + morphos) + basic_machine=powerpc-unknown + os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=moxiebox + ;; + msdos) + basic_machine=i386-pc + os=msdos + ;; + msys) + basic_machine=i686-pc + os=msys + ;; + mvs) + basic_machine=i370-ibm + os=mvs + ;; + nacl) + basic_machine=le32-unknown + os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=newsos + ;; + news1000) + basic_machine=m68030-sony + os=newsos + ;; + necv70) + basic_machine=v70-nec + os=sysv + ;; + nh3000) + basic_machine=m68k-harris + os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=cxux + ;; + nindy960) + basic_machine=i960-intel + os=nindy + ;; + mon960) + basic_machine=i960-intel + os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=ose + ;; + os68k) + basic_machine=m68k-none + os=os68k + ;; + paragon) + basic_machine=i860-intel + os=osf + ;; + parisc) + basic_machine=hppa-unknown + os=linux + ;; + pw32) + basic_machine=i586-unknown + os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=rdos + ;; + rdos32) + basic_machine=i386-pc + os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=coff + ;; + sa29200) + basic_machine=a29k-amd + os=udi + ;; + sei) + basic_machine=mips-sei + os=seiux + ;; + sequent) + basic_machine=i386-sequent + os= + ;; + sps7) + basic_machine=m68k-bull + os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + os= + ;; + stratus) + basic_machine=i860-stratus + os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + os= + ;; + sun2os3) + basic_machine=m68000-sun + os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + os= + ;; + sun3os3) + basic_machine=m68k-sun + os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + os= + ;; + sun4os3) + basic_machine=sparc-sun + os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + os= + ;; + sv1) + basic_machine=sv1-cray + os=unicos + ;; + symmetry) + basic_machine=i386-sequent + os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=unicos + ;; + t90) + basic_machine=t90-cray + os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + os=tpf + ;; + udi29k) + basic_machine=a29k-amd + os=udi + ;; + ultra3) + basic_machine=a29k-nyu + os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=none + ;; + vaxv) + basic_machine=vax-dec + os=sysv + ;; + vms) + basic_machine=vax-dec + os=vms + ;; + vsta) + basic_machine=i386-pc + os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=vxworks + ;; + xbox) + basic_machine=i686-pc + os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + os=unicos + ;; + *) + basic_machine=$1 + os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - c54x) - basic_machine=tic54x-unknown + op50n) + cpu=hppa1.1 + vendor=oki ;; - c55x) - basic_machine=tic55x-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - c6x) - basic_machine=tic6x-unknown + ibm*) + cpu=i370 + vendor=ibm + ;; + orion105) + cpu=clipper + vendor=highlevel + ;; + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple + ;; + pmac | pmac-mpw) + cpu=powerpc + vendor=apple + ;; + + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + cpu=m68000 + vendor=att + ;; + 3b*) + cpu=we32k + vendor=att + ;; + bluegene*) + cpu=powerpc + vendor=ibm + os=cnk + ;; + decsystem10* | dec10*) + cpu=pdp10 + vendor=dec + os=tops10 + ;; + decsystem20* | dec20*) + cpu=pdp10 + vendor=dec + os=tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + cpu=m68k + vendor=motorola + ;; + dpx2*) + cpu=m68k + vendor=bull + os=sysv3 + ;; + encore | umax | mmax) + cpu=ns32k + vendor=encore + ;; + elxsi) + cpu=elxsi + vendor=elxsi + os=${os:-bsd} + ;; + fx2800) + cpu=i860 + vendor=alliant + ;; + genix) + cpu=ns32k + vendor=ns + ;; + h3050r* | hiux*) + cpu=hppa1.1 + vendor=hitachi + os=hiuxwe2 + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + cpu=m68000 + vendor=hp + ;; + hp9k3[2-9][0-9]) + cpu=m68k + vendor=hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + i*86v32) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=sysv32 + ;; + i*86v4*) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=sysv4 + ;; + i*86v) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=sysv + ;; + i*86sol2) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + os=solaris2 + ;; + j90 | j90-cray) + cpu=j90 + vendor=cray + os=${os:-unicos} + ;; + iris | iris4d) + cpu=mips + vendor=sgi + case $os in + irix*) + ;; + *) + os=irix4 + ;; + esac + ;; + miniframe) + cpu=m68000 + vendor=convergent + ;; + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + os=mint + ;; + news-3600 | risc-news) + cpu=mips + vendor=sony + os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $os in + openstep*) + ;; + nextstep*) + ;; + ns2*) + os=nextstep2 + ;; + *) + os=nextstep3 + ;; + esac + ;; + np1) + cpu=np1 + vendor=gould + ;; + op50n-* | op60c-*) + cpu=hppa1.1 + vendor=oki + os=proelf + ;; + pa-hitachi) + cpu=hppa1.1 + vendor=hitachi + os=hiuxwe2 + ;; + pbd) + cpu=sparc + vendor=tti + ;; + pbb) + cpu=m68k + vendor=tti + ;; + pc532) + cpu=ns32k + vendor=pc532 + ;; + pn) + cpu=pn + vendor=gould + ;; + power) + cpu=power + vendor=ibm + ;; + ps2) + cpu=i386 + vendor=ibm + ;; + rm[46]00) + cpu=mips + vendor=siemens + ;; + rtpc | rtpc-*) + cpu=romp + vendor=ibm + ;; + sde) + cpu=mipsisa32 + vendor=sde + os=${os:-elf} + ;; + simso-wrs) + cpu=sparclite + vendor=wrs + os=vxworks + ;; + tower | tower-32) + cpu=m68k + vendor=ncr + ;; + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu + ;; + w65) + cpu=w65 + vendor=wdc + ;; + w89k-*) + cpu=hppa1.1 + vendor=winbond + os=proelf + ;; + none) + cpu=none + vendor=none ;; leon|leon[3-9]) - basic_machine=sparc-$basic_machine + cpu=sparc + vendor=$basic_machine ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - strongarm | thumb | xscale) - basic_machine=arm-unknown + *-*) + # shellcheck disable=SC2162 + IFS="-" read cpu vendor <&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - os=$os"spe" - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - nsx-tandem) - basic_machine=nsx-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 + cpu=$basic_machine + vendor=pc ;; + # These rules are duplicated from below for sake of the special case above; + # i.e. things that normalized to x86 arches should also default to "pc" pc98) - basic_machine=i386-pc + cpu=i386 + vendor=pc ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + x64 | amd64) + cpu=x86_64 + vendor=pc ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc + # Recognize the basic CPU types without company name. + *) + cpu=$basic_machine + vendor=unknown ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc +esac + +unset -v basic_machine + +# Decode basic machines in the full and proper CPU-Company form. +case $cpu-$vendor in + # Here we handle the default manufacturer of certain CPU types in canonical form. It is in + # some cases the only manufacturer, in others, it is the most popular. + craynv-unknown) + vendor=cray + os=${os:-unicosmp} ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc + c90-unknown | c90-cray) + vendor=cray + os=${os:-unicos} ;; - pentium4) - basic_machine=i786-pc + fx80-unknown) + vendor=alliant ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + romp-unknown) + vendor=ibm ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + mmix-unknown) + vendor=knuth ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + microblaze-unknown | microblazeel-unknown) + vendor=xilinx ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + rs6000-unknown) + vendor=ibm ;; - pn) - basic_machine=pn-gould + vax-unknown) + vendor=dec ;; - power) basic_machine=power-ibm + pdp11-unknown) + vendor=dec ;; - ppc | ppcbe) basic_machine=powerpc-unknown + we32k-unknown) + vendor=att ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + cydra-unknown) + vendor=cydrome ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown + i370-ibm*) + vendor=ibm ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + orion-unknown) + vendor=highlevel ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none + xps-unknown | xps100-unknown) + cpu=xps100 + vendor=honeywell ;; -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond + # Here we normalize CPU types with a missing or matching vendor + dpx20-unknown | dpx20-bull) + cpu=rs6000 + vendor=bull + os=${os:-bosx} ;; - op50n) - basic_machine=hppa1.1-oki + + # Here we normalize CPU types irrespective of the vendor + amd64-*) + cpu=x86_64 ;; - op60c) - basic_machine=hppa1.1-oki + blackfin-*) + cpu=bfin + os=linux ;; - romp) - basic_machine=romp-ibm + c54x-*) + cpu=tic54x ;; - mmix) - basic_machine=mmix-knuth + c55x-*) + cpu=tic55x ;; - rs6000) - basic_machine=rs6000-ibm + c6x-*) + cpu=tic6x ;; - vax) - basic_machine=vax-dec + e500v[12]-*) + cpu=powerpc + os=$os"spe" ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown + mips3*-*) + cpu=mips64 ;; - pdp11) - basic_machine=pdp11-dec + ms1-*) + cpu=mt ;; - we32k) - basic_machine=we32k-att + m68knommu-*) + cpu=m68k + os=linux ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown + m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) + cpu=s12z ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun + openrisc-*) + cpu=or32 ;; - cydra) - basic_machine=cydra-cydrome + parisc-*) + cpu=hppa + os=linux ;; - orion) - basic_machine=orion-highlevel + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + cpu=i586 ;; - orion105) - basic_machine=clipper-highlevel + pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + cpu=i686 ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + cpu=i686 ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple + pentium4-*) + cpu=i786 ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. + pc98-*) + cpu=i386 ;; + ppc-* | ppcbe-*) + cpu=powerpc + ;; + ppcle-* | powerpclittle-*) + cpu=powerpcle + ;; + ppc64-*) + cpu=powerpc64 + ;; + ppc64le-* | powerpc64little-*) + cpu=powerpc64le + ;; + sb1-*) + cpu=mipsisa64sb1 + ;; + sb1el-*) + cpu=mipsisa64sb1el + ;; + sh5e[lb]-*) + cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'` + ;; + spur-*) + cpu=spur + ;; + strongarm-* | thumb-*) + cpu=arm + ;; + tx39-*) + cpu=mipstx39 + ;; + tx39el-*) + cpu=mipstx39el + ;; + x64-*) + cpu=x86_64 + ;; + xscale-* | xscalee[bl]-*) + cpu=`echo "$cpu" | sed 's/^xscale/arm/'` + ;; + + # Recognize the canonical CPU Types that limit and/or modify the + # company names they are paired with. + cr16-*) + os=${os:-elf} + ;; + crisv32-* | etraxfs*-*) + cpu=crisv32 + vendor=axis + ;; + cris-* | etrax*-*) + cpu=cris + vendor=axis + ;; + crx-*) + os=${os:-elf} + ;; + neo-tandem) + cpu=neo + vendor=tandem + ;; + nse-tandem) + cpu=nse + vendor=tandem + ;; + nsr-tandem) + cpu=nsr + vendor=tandem + ;; + nsv-tandem) + cpu=nsv + vendor=tandem + ;; + nsx-tandem) + cpu=nsx + vendor=tandem + ;; + s390-*) + cpu=s390 + vendor=ibm + ;; + s390x-*) + cpu=s390x + vendor=ibm + ;; + tile*-*) + os=${os:-linux-gnu} + ;; + *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | 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 \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv64 \ + | rl78 | romp | rs6000 | rx \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1358,200 +1275,244 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if [ x$os != x ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + # First match some system type aliases that might get confused + # with valid system types. + # solaris* is a basic system type, with this one exception. + auroraux) + os=auroraux ;; - -solaris1 | -solaris1.*) + bluegene*) + os=cnk + ;; + solaris1 | solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; - -solaris) - os=-solaris2 + solaris) + os=solaris2 ;; - -svr4*) - os=-sysv4 + unixware*) + os=sysv4.2uw ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) + gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # First accept the basic system types. + # es1800 is here to avoid being matched by es* (a different OS) + es1800*) + os=ose + ;; + # Some version numbers need modification + chorusos*) + os=chorusos + ;; + isc) + os=isc2.2 + ;; + sco6) + os=sco5v6 + ;; + sco5) + os=sco3.2v5 + ;; + sco4) + os=sco3.2v4 + ;; + sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + ;; + sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + scout) + # Don't match below + ;; + sco*) + os=sco3.2v2 + ;; + psos*) + os=psos + ;; + # Now accept the basic system types. # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* | -sortix* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) + # Each alternative MUST end in a * to match a version number. + # sysv* is not here because it comes later, after sysvr4. + gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | kopensolaris* | plan9* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | knetbsd* | mirbsd* | netbsd* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \ + | linux-newlib* | linux-musl* | linux-uclibc* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* \ + | morphos* | superux* | rtmk* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix) # Remember, each alternative MUST END IN *, to match a version number. ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) + qnx*) + case $cpu in + x86 | i*86) ;; *) - os=-nto$os + os=nto-$os ;; esac ;; - -nto-qnx*) + hiux*) + os=hiuxwe2 ;; - -nto*) + nto-qnx*) + ;; + nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + sim | xray | os68k* | v88r* \ + | windows* | osx | abug | netware* | os9* \ + | macos* | mpw* | magic* | mmixware* | mon960* | lnews*) ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + linux-dietlibc) + os=linux-dietlibc ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) + linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + lynx*178) + os=lynxos178 ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + lynx*5) + os=lynxos5 ;; - -opened*) - os=-openedition + lynx*) + os=lynxos ;; - -os400*) - os=-os400 + mac*) + os=`echo "$os" | sed -e 's|mac|macos|'` ;; - -wince*) - os=-wince + opened*) + os=openedition ;; - -osfrose*) - os=-osfrose + os400*) + os=os400 ;; - -osf*) - os=-osf + sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; - -utek*) - os=-bsd + sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; - -dynix*) - os=-bsd + wince*) + os=wince ;; - -acis*) - os=-aos + utek*) + os=bsd ;; - -atheos*) - os=-atheos + dynix*) + os=bsd ;; - -syllable*) - os=-syllable + acis*) + os=aos ;; - -386bsd) - os=-bsd + atheos*) + os=atheos ;; - -ctix* | -uts*) - os=-sysv + syllable*) + os=syllable ;; - -nova*) - os=-rtmk-nova + 386bsd) + os=bsd ;; - -ns2 ) - os=-nextstep2 + ctix* | uts*) + os=sysv ;; - -nsk*) - os=-nsk + nova*) + os=rtmk-nova + ;; + ns2) + os=nextstep2 ;; # Preserve the version number of sinix5. - -sinix5.*) + sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; - -sinix*) - os=-sysv4 + sinix*) + os=sysv4 ;; - -tpf*) - os=-tpf + tpf*) + os=tpf ;; - -triton*) - os=-sysv3 + triton*) + os=sysv3 ;; - -oss*) - os=-sysv3 + oss*) + os=sysv3 ;; - -svr4) - os=-sysv4 + svr4*) + os=sysv4 ;; - -svr3) - os=-sysv3 + svr3) + os=sysv3 ;; - -sysvr4) - os=-sysv4 + sysvr4) + os=sysv4 ;; - # This must come after -sysvr4. - -sysv*) + # This must come after sysvr4. + sysv*) ;; - -ose*) - os=-ose + ose*) + os=ose ;; - -es1800*) - os=-ose + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + os=mint ;; - -xenix) - os=-xenix + zvmoe) + os=zvmoe ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + dicos*) + os=dicos ;; - -aros*) - os=-aros + pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $cpu in + arm*) + os=eabi + ;; + *) + os=elf + ;; + esac ;; - -zvmoe) - os=-zvmoe + nacl*) ;; - -dicos*) - os=-dicos + ios) ;; - -nacl*) + none) ;; - -ios) - ;; - -none) + *-eabi) ;; *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac @@ -1567,264 +1528,265 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + os=linux ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; pru-*) - os=-elf + os=elf ;; *-be) - os=-beos - ;; - *-haiku) - os=-haiku + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs + os=luna ;; *-next) - os=-nextstep3 + os=nextstep + ;; + *-sequent) + os=ptx + ;; + *-crds) + os=unos + ;; + *-ns) + os=genix + ;; + i370-*) + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) +case $vendor in + unknown) case $os in - -riscix*) + riscix*) vendor=acorn ;; - -sunos*) + sunos*) vendor=sun ;; - -cnk*|-aix*) + cnk*|-aix*) vendor=ibm ;; - -beos*) + beos*) vendor=be ;; - -hpux*) + hpux*) vendor=hp ;; - -mpeix*) + mpeix*) vendor=hp ;; - -hiux*) + hiux*) vendor=hitachi ;; - -unos*) + unos*) vendor=crds ;; - -dgux*) + dgux*) vendor=dg ;; - -luna*) + luna*) vendor=omron ;; - -genix*) + genix*) vendor=ns ;; - -mvs* | -opened*) + clix*) + vendor=intergraph + ;; + mvs* | opened*) vendor=ibm ;; - -os400*) + os400*) vendor=ibm ;; - -ptx*) + ptx*) vendor=sequent ;; - -tpf*) + tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + vxsim* | vxworks* | windiss*) vendor=wrs ;; - -aux*) + aux*) vendor=apple ;; - -hms*) + hms*) vendor=hitachi ;; - -mpw* | -macos*) + mpw* | macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) vendor=atari ;; - -vos*) + vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/contrib/byacc/config_h.in b/contrib/byacc/config_h.in index c7d6d910857b..1b0fd6e239f6 100644 --- a/contrib/byacc/config_h.in +++ b/contrib/byacc/config_h.in @@ -21,16 +21,52 @@ /* Define if you have the header file. */ #undef HAVE_FCNTL_H +/* Define if you have the `getopt' function. */ +#undef HAVE_GETOPT + +/* Define if you have the header file. */ +#undef HAVE_GETOPT_H + +/* Define to 1 if getopt variables are declared in header */ +#undef HAVE_GETOPT_HEADER + +/* Define if you have the header file. */ +#undef HAVE_INTTYPES_H + /* Define if you have the `dbmalloc' library (-ldbmalloc). */ #undef HAVE_LIBDBMALLOC /* Define if you have the `dmalloc' library (-ldmalloc). */ #undef HAVE_LIBDMALLOC +/* Define if you have the header file. */ +#undef HAVE_MEMORY_H + /* Define to 1 if mkstemp() is available and working. */ #undef HAVE_MKSTEMP -/* Define to 1 if vsnprintf() is available and working. */ +/* Define if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define if you have the header file. */ +#undef HAVE_STRING_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* Define to maximum table size (default: 32500) */ @@ -39,9 +75,15 @@ /* Define to 1 if filesystem supports mixed-case filenames. */ #undef MIXEDCASE_FILENAMES +/* Define to 1 if we must include getopt.h */ +#undef NEED_GETOPT_H + /* Define to 1 if you want to perform memory-leak testing. */ #undef NO_LEAKS +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + /* Define to the system name. */ #undef SYSTEM_NAME @@ -59,3 +101,6 @@ /* Define to 1 if you want to perform memory-leak testing. */ #undef YY_NO_LEAKS + +/* Define to `int' if does not define. */ +#undef mode_t diff --git a/contrib/byacc/configure b/contrib/byacc/configure index a636db7ce9b5..8016645b0f6b 100755 --- a/contrib/byacc/configure +++ b/contrib/byacc/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in Revision: 1.21 . +# From configure.in Revision: 1.23 . # Guess values for system-dependent variables and create Makefiles. -# Generated by Autoconf 2.52.20150926. +# Generated by Autoconf 2.52.20200111. # # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. @@ -176,6 +176,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' @@ -318,6 +319,15 @@ do | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst \ + | --runs | --run | --ru) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* \ + | --runs=* | --run=* | --ru=*) + runstatedir=$ac_optarg ;; + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) @@ -655,6 +665,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR extra definition of runtime data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -767,7 +778,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.20150926. Invocation command line was +generated by GNU Autoconf 2.52.20200111. Invocation command line was $ $0 $@ @@ -891,7 +902,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:894: loading site script $ac_site_file" >&5 + { echo "$as_me:905: 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" @@ -902,7 +913,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:905: loading cache $cache_file" >&5 + { echo "$as_me:916: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; @@ -910,7 +921,7 @@ echo "$as_me: loading cache $cache_file" >&6;} esac fi else - { echo "$as_me:913: creating cache $cache_file" >&5 + { echo "$as_me:924: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -926,21 +937,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:929: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 + { echo "$as_me:940: 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:933: error: \`$ac_var' was not set in the previous run" >&5 + { echo "$as_me:944: 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:939: error: \`$ac_var' has changed since the previous run:" >&5 + { echo "$as_me:950: 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:941: former value: $ac_old_val" >&5 + { echo "$as_me:952: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:943: current value: $ac_new_val" >&5 + { echo "$as_me:954: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; @@ -959,9 +970,9 @@ echo "$as_me: current value: $ac_new_val" >&2;} fi done if $ac_cache_corrupted; then - { echo "$as_me:962: error: changes in the environment can compromise the build" >&5 + { echo "$as_me:973: 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:964: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 + { { echo "$as_me:975: 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 @@ -982,10 +993,10 @@ esac echo "#! $SHELL" >conftest.sh echo "exit 0" >>conftest.sh chmod +x conftest.sh -if { (echo "$as_me:985: PATH=\".;.\"; conftest.sh") >&5 +if { (echo "$as_me:996: PATH=\".;.\"; conftest.sh") >&5 (PATH=".;."; conftest.sh) 2>&5 ac_status=$? - echo "$as_me:988: \$? = $ac_status" >&5 + echo "$as_me:999: \$? = $ac_status" >&5 (exit $ac_status); }; then ac_path_separator=';' else @@ -1013,7 +1024,7 @@ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do fi done if test -z "$ac_aux_dir"; then - { { echo "$as_me:1016: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 + { { echo "$as_me:1027: 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 @@ -1023,11 +1034,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:1026: error: cannot run $ac_config_sub" >&5 + { { echo "$as_me:1037: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } -echo "$as_me:1030: checking build system type" >&5 +echo "$as_me:1041: 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 @@ -1036,23 +1047,23 @@ else test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && - { { echo "$as_me:1039: error: cannot guess build type; you must specify one" >&5 + { { echo "$as_me:1050: 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:1043: error: $ac_config_sub $ac_cv_build_alias failed." >&5 + { { echo "$as_me:1054: 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:1048: result: $ac_cv_build" >&5 +echo "$as_me:1059: 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:1055: checking host system type" >&5 +echo "$as_me:1066: 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 @@ -1061,12 +1072,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:1064: error: $ac_config_sub $ac_cv_host_alias failed" >&5 + { { echo "$as_me:1075: 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:1069: result: $ac_cv_host" >&5 +echo "$as_me:1080: 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/'` @@ -1074,7 +1085,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:1077: checking target system type" >&5 + echo "$as_me:1088: 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 @@ -1083,12 +1094,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:1086: error: $ac_config_sub $ac_cv_target_alias failed" >&5 + { { echo "$as_me:1097: 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:1091: result: $ac_cv_target" >&5 +echo "$as_me:1102: 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/'` @@ -1120,13 +1131,13 @@ else fi test -z "$system_name" && system_name="$cf_cv_system_name" -test -n "$cf_cv_system_name" && echo "$as_me:1123: result: Configuring for $cf_cv_system_name" >&5 +test -n "$cf_cv_system_name" && echo "$as_me:1134: 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:1127: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5 + echo "$as_me:1138: 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:1129: error: \"Please remove config.cache and try again.\"" >&5 + { { echo "$as_me:1140: 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 @@ -1153,7 +1164,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:1156: checking for $ac_word" >&5 +echo "$as_me:1167: 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 @@ -1168,7 +1179,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:1171: found $ac_dir/$ac_word" >&5 +echo "$as_me:1182: found $ac_dir/$ac_word" >&5 break done @@ -1176,10 +1187,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1179: result: $CC" >&5 + echo "$as_me:1190: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1182: result: no" >&5 + echo "$as_me:1193: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1188,7 +1199,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:1191: checking for $ac_word" >&5 +echo "$as_me:1202: 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 @@ -1203,7 +1214,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:1206: found $ac_dir/$ac_word" >&5 +echo "$as_me:1217: found $ac_dir/$ac_word" >&5 break done @@ -1211,10 +1222,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:1214: result: $ac_ct_CC" >&5 + echo "$as_me:1225: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:1217: result: no" >&5 + echo "$as_me:1228: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1227,7 +1238,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:1230: checking for $ac_word" >&5 +echo "$as_me:1241: 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 @@ -1242,7 +1253,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:1245: found $ac_dir/$ac_word" >&5 +echo "$as_me:1256: found $ac_dir/$ac_word" >&5 break done @@ -1250,10 +1261,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1253: result: $CC" >&5 + echo "$as_me:1264: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1256: result: no" >&5 + echo "$as_me:1267: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1262,7 +1273,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:1265: checking for $ac_word" >&5 +echo "$as_me:1276: 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 @@ -1277,7 +1288,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:1280: found $ac_dir/$ac_word" >&5 +echo "$as_me:1291: found $ac_dir/$ac_word" >&5 break done @@ -1285,10 +1296,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:1288: result: $ac_ct_CC" >&5 + echo "$as_me:1299: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:1291: result: no" >&5 + echo "$as_me:1302: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1301,7 +1312,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:1304: checking for $ac_word" >&5 +echo "$as_me:1315: 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 @@ -1321,7 +1332,7 @@ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then continue fi ac_cv_prog_CC="cc" -echo "$as_me:1324: found $ac_dir/$ac_word" >&5 +echo "$as_me:1335: found $ac_dir/$ac_word" >&5 break done @@ -1343,10 +1354,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1346: result: $CC" >&5 + echo "$as_me:1357: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1349: result: no" >&5 + echo "$as_me:1360: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1357,7 +1368,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:1360: checking for $ac_word" >&5 +echo "$as_me:1371: 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 @@ -1372,7 +1383,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:1375: found $ac_dir/$ac_word" >&5 +echo "$as_me:1386: found $ac_dir/$ac_word" >&5 break done @@ -1380,10 +1391,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:1383: result: $CC" >&5 + echo "$as_me:1394: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:1386: result: no" >&5 + echo "$as_me:1397: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1396,7 +1407,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:1399: checking for $ac_word" >&5 +echo "$as_me:1410: 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 @@ -1411,7 +1422,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:1414: found $ac_dir/$ac_word" >&5 +echo "$as_me:1425: found $ac_dir/$ac_word" >&5 break done @@ -1419,10 +1430,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:1422: result: $ac_ct_CC" >&5 + echo "$as_me:1433: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:1425: result: no" >&5 + echo "$as_me:1436: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -1434,36 +1445,36 @@ fi fi -test -z "$CC" && { { echo "$as_me:1437: error: no acceptable cc found in \$PATH" >&5 +test -z "$CC" && { { echo "$as_me:1448: 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:1442:" \ +echo "$as_me:1453:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:1445: \"$ac_compiler --version &5\"") >&5 +{ (eval echo "$as_me:1456: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? - echo "$as_me:1448: \$? = $ac_status" >&5 + echo "$as_me:1459: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:1450: \"$ac_compiler -v &5\"") >&5 +{ (eval echo "$as_me:1461: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? - echo "$as_me:1453: \$? = $ac_status" >&5 + echo "$as_me:1464: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:1455: \"$ac_compiler -V &5\"") >&5 +{ (eval echo "$as_me:1466: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? - echo "$as_me:1458: \$? = $ac_status" >&5 + echo "$as_me:1469: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF -#line 1462 "configure" +#line 1473 "configure" #include "confdefs.h" int -main () +main (void) { ; @@ -1475,13 +1486,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:1478: checking for C compiler default output" >&5 +echo "$as_me:1489: 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:1481: \"$ac_link_default\"") >&5 +if { (eval echo "$as_me:1492: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? - echo "$as_me:1484: \$? = $ac_status" >&5 + echo "$as_me:1495: \$? = $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 @@ -1504,34 +1515,34 @@ done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -{ { echo "$as_me:1507: error: C compiler cannot create executables" >&5 +{ { echo "$as_me:1518: 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:1513: result: $ac_file" >&5 +echo "$as_me:1524: 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:1518: checking whether the C compiler works" >&5 +echo "$as_me:1529: 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:1524: \"$ac_try\"") >&5 + { (eval echo "$as_me:1535: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1527: \$? = $ac_status" >&5 + echo "$as_me:1538: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { echo "$as_me:1534: error: cannot run C compiled programs. + { { echo "$as_me:1545: 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;} @@ -1539,24 +1550,24 @@ If you meant to cross compile, use \`--host'." >&2;} fi fi fi -echo "$as_me:1542: result: yes" >&5 +echo "$as_me:1553: 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:1549: checking whether we are cross compiling" >&5 +echo "$as_me:1560: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:1551: result: $cross_compiling" >&5 +echo "$as_me:1562: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 -echo "$as_me:1554: checking for executable suffix" >&5 +echo "$as_me:1565: checking for executable suffix" >&5 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 -if { (eval echo "$as_me:1556: \"$ac_link\"") >&5 +if { (eval echo "$as_me:1567: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:1559: \$? = $ac_status" >&5 + echo "$as_me:1570: \$? = $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 @@ -1572,29 +1583,29 @@ for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do esac done else - { { echo "$as_me:1575: error: cannot compute EXEEXT: cannot compile and link" >&5 + { { echo "$as_me:1586: 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:1581: result: $ac_cv_exeext" >&5 +echo "$as_me:1592: 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:1587: checking for object suffix" >&5 +echo "$as_me:1598: 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 1593 "configure" +#line 1604 "configure" #include "confdefs.h" int -main () +main (void) { ; @@ -1602,10 +1613,10 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (eval echo "$as_me:1605: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1616: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1608: \$? = $ac_status" >&5 + echo "$as_me:1619: \$? = $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 @@ -1617,28 +1628,28 @@ done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -{ { echo "$as_me:1620: error: cannot compute OBJEXT: cannot compile" >&5 +{ { echo "$as_me:1631: 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:1627: result: $ac_cv_objext" >&5 +echo "$as_me:1638: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -echo "$as_me:1631: checking whether we are using the GNU C compiler" >&5 +echo "$as_me:1642: 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 1637 "configure" +#line 1648 "configure" #include "confdefs.h" int -main () +main (void) { #ifndef __GNUC__ choke me @@ -1649,16 +1660,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1652: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1663: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1655: \$? = $ac_status" >&5 + echo "$as_me:1666: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1658: \"$ac_try\"") >&5 + { (eval echo "$as_me:1669: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1661: \$? = $ac_status" >&5 + echo "$as_me:1672: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else @@ -1670,23 +1681,23 @@ rm -f conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:1673: result: $ac_cv_c_compiler_gnu" >&5 +echo "$as_me:1684: 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:1679: checking whether $CC accepts -g" >&5 +echo "$as_me:1690: 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 1685 "configure" +#line 1696 "configure" #include "confdefs.h" int -main () +main (void) { ; @@ -1694,16 +1705,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1697: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1708: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1700: \$? = $ac_status" >&5 + echo "$as_me:1711: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1703: \"$ac_try\"") >&5 + { (eval echo "$as_me:1714: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1706: \$? = $ac_status" >&5 + echo "$as_me:1717: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else @@ -1713,7 +1724,7 @@ ac_cv_prog_cc_g=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:1716: result: $ac_cv_prog_cc_g" >&5 +echo "$as_me:1727: 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 @@ -1740,16 +1751,16 @@ cat >conftest.$ac_ext <<_ACEOF #endif _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1743: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1754: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1746: \$? = $ac_status" >&5 + echo "$as_me:1757: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1749: \"$ac_try\"") >&5 + { (eval echo "$as_me:1760: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1752: \$? = $ac_status" >&5 + echo "$as_me:1763: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ ''\ @@ -1761,12 +1772,12 @@ if { (eval echo "$as_me:1743: \"$ac_compile\"") >&5 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF -#line 1764 "configure" +#line 1775 "configure" #include "confdefs.h" #include $ac_declaration int -main () +main (void) { exit (42); ; @@ -1774,16 +1785,16 @@ exit (42); } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1777: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1788: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1780: \$? = $ac_status" >&5 + echo "$as_me:1791: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1783: \"$ac_try\"") >&5 + { (eval echo "$as_me:1794: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1786: \$? = $ac_status" >&5 + echo "$as_me:1797: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -1793,11 +1804,11 @@ continue fi rm -f conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF -#line 1796 "configure" +#line 1807 "configure" #include "confdefs.h" $ac_declaration int -main () +main (void) { exit (42); ; @@ -1805,16 +1816,16 @@ exit (42); } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:1808: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:1819: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1811: \$? = $ac_status" >&5 + echo "$as_me:1822: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1814: \"$ac_try\"") >&5 + { (eval echo "$as_me:1825: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1817: \$? = $ac_status" >&5 + echo "$as_me:1828: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else @@ -1844,15 +1855,117 @@ ac_main_return=return GCC_VERSION=none if test "$GCC" = yes ; then - echo "$as_me:1847: checking version of $CC" >&5 + echo "$as_me:1858: checking version of $CC" >&5 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" test -z "$GCC_VERSION" && GCC_VERSION=unknown - echo "$as_me:1851: result: $GCC_VERSION" >&5 + echo "$as_me:1862: result: $GCC_VERSION" >&5 echo "${ECHO_T}$GCC_VERSION" >&6 fi -echo "$as_me:1855: checking for $CC option to accept ANSI C" >&5 +INTEL_COMPILER=no + +if test "$GCC" = yes ; then + case $host_os in + (linux*|gnu*) + echo "$as_me:1871: 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 1876 "configure" +#include "confdefs.h" + +int +main (void) +{ + +#ifdef __INTEL_COMPILER +#else +make an error +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1893: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1896: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1899: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1902: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + INTEL_COMPILER=yes +cf_save_CFLAGS="$cf_save_CFLAGS -we147" + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + CFLAGS="$cf_save_CFLAGS" + echo "$as_me:1913: result: $INTEL_COMPILER" >&5 +echo "${ECHO_T}$INTEL_COMPILER" >&6 + ;; + esac +fi + +CLANG_COMPILER=no + +if test "$GCC" = yes ; then + echo "$as_me:1922: checking if this is really Clang C compiler" >&5 +echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6 + cf_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Qunused-arguments" + cat >conftest.$ac_ext <<_ACEOF +#line 1927 "configure" +#include "confdefs.h" + +int +main (void) +{ + +#ifdef __clang__ +#else +make an error +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1944: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1947: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1950: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1953: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + CLANG_COMPILER=yes +cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments" + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext + CFLAGS="$cf_save_CFLAGS" + echo "$as_me:1964: result: $CLANG_COMPILER" >&5 +echo "${ECHO_T}$CLANG_COMPILER" >&6 +fi + +echo "$as_me:1968: 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 @@ -1860,7 +1973,7 @@ else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF -#line 1863 "configure" +#line 1976 "configure" #include "confdefs.h" #include #include @@ -1891,7 +2004,7 @@ int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, i int argc; char **argv; int -main () +main (void) { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; @@ -1909,16 +2022,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:1912: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2025: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:1915: \$? = $ac_status" >&5 + echo "$as_me:2028: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:1918: \"$ac_try\"") >&5 + { (eval echo "$as_me:2031: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:1921: \$? = $ac_status" >&5 + echo "$as_me:2034: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_stdc=$ac_arg break @@ -1935,10 +2048,10 @@ fi case "x$ac_cv_prog_cc_stdc" in x|xno) - echo "$as_me:1938: result: none needed" >&5 + echo "$as_me:2051: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) - echo "$as_me:1941: result: $ac_cv_prog_cc_stdc" >&5 + echo "$as_me:2054: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac @@ -1946,28 +2059,25 @@ esac # This should have been defined by AC_PROG_CC : ${CC:=cc} -echo "$as_me:1949: checking \$CC variable" >&5 -echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6 -case "$CC" in -(*[\ \ ]-*) - echo "$as_me:1953: result: broken" >&5 +echo "$as_me:2062: checking \$CFLAGS variable" >&5 +echo $ECHO_N "checking \$CFLAGS variable... $ECHO_C" >&6 +case "x$CFLAGS" in +(*-[IUD]*) + echo "$as_me:2066: result: broken" >&5 echo "${ECHO_T}broken" >&6 - { echo "$as_me:1955: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&5 -echo "$as_me: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;} - # humor him... - cf_flags=`echo "$CC" | sed -e 's/^.*[ ]\(-[^ ]\)/\1/'` - CC=`echo "$CC " | sed -e 's/[ ]-[^ ].*$//' -e 's/[ ]*$//'` + { echo "$as_me:2068: 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= for cf_arg in $cf_flags do - case "x$cf_arg" in - (x-[IUDfgOW]*) cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= -for cf_add_cflags in $cf_flags +for cf_add_cflags in $cf_arg do case $cf_fix_cppflags in (no) @@ -1982,10 +2092,16 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue fi ;; @@ -2004,17 +2120,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \ ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` @@ -2027,17 +2151,146 @@ done if test -n "$cf_new_cflags" ; then - CFLAGS="$CFLAGS $cf_new_cflags" + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + fi if test -n "$cf_new_cppflags" ; then - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + fi if test -n "$cf_new_extra_cppflags" ; then - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + +fi + + done + ;; +(*) + echo "$as_me:2176: result: ok" >&5 +echo "${ECHO_T}ok" >&6 + ;; +esac + +echo "$as_me:2181: checking \$CC variable" >&5 +echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6 +case "$CC" in +(*[\ \ ]-*) + echo "$as_me:2185: result: broken" >&5 +echo "${ECHO_T}broken" >&6 + { echo "$as_me:2187: 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))); }'` + CC="$cf_prog" + for cf_arg in $cf_flags + do + case "x$cf_arg" in + (x-[IUDfgOW]*) + +cf_fix_cppflags=no +cf_new_cflags= +cf_new_cppflags= +cf_new_extra_cppflags= + +for cf_add_cflags in $cf_arg +do +case $cf_fix_cppflags in +(no) + case $cf_add_cflags in + (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) + case $cf_add_cflags in + (-D*) + cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=yes + + if test $cf_fix_cppflags = yes ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + elif test "${cf_tst_cflags}" = "\"'" ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + fi + ;; + esac + case "$CPPFLAGS" in + (*$cf_add_cflags) + ;; + (*) + case $cf_add_cflags in + (-D*) + cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` + +CPPFLAGS=`echo "$CPPFLAGS" | \ + sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ + -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` + + ;; + esac + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + + ;; + esac + ;; + (*) + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + + ;; + esac + ;; +(yes) + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=no + ;; +esac +done + +if test -n "$cf_new_cflags" ; then + + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + +fi + +if test -n "$cf_new_cppflags" ; then + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + +fi + +if test -n "$cf_new_extra_cppflags" ; then + + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + fi ;; @@ -2048,24 +2301,24 @@ fi done test -n "$verbose" && echo " resulting CC: '$CC'" 1>&6 -echo "${as_me:-configure}:2051: testing resulting CC: '$CC' ..." 1>&5 +echo "${as_me:-configure}:2304: testing resulting CC: '$CC' ..." 1>&5 test -n "$verbose" && echo " resulting CFLAGS: '$CFLAGS'" 1>&6 -echo "${as_me:-configure}:2055: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5 +echo "${as_me:-configure}:2308: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5 test -n "$verbose" && echo " resulting CPPFLAGS: '$CPPFLAGS'" 1>&6 -echo "${as_me:-configure}:2059: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5 +echo "${as_me:-configure}:2312: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5 ;; (*) - echo "$as_me:2063: result: ok" >&5 + echo "$as_me:2316: result: ok" >&5 echo "${ECHO_T}ok" >&6 ;; esac -echo "$as_me:2068: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "$as_me:2321: 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 @@ -2085,11 +2338,11 @@ fi rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:2088: result: yes" >&5 + echo "$as_me:2341: result: yes" >&5 echo "${ECHO_T}yes" >&6 SET_MAKE= else - echo "$as_me:2092: result: no" >&5 + echo "$as_me:2345: result: no" >&5 echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi @@ -2106,7 +2359,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:2109: checking for a BSD compatible install" >&5 +echo "$as_me:2362: 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 @@ -2155,7 +2408,7 @@ fi INSTALL=$ac_install_sh fi fi -echo "$as_me:2158: result: $INSTALL" >&5 +echo "$as_me:2411: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. @@ -2166,7 +2419,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -echo "$as_me:2169: checking if filesystem supports mixed-case filenames" >&5 +echo "$as_me:2422: 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 @@ -2193,7 +2446,7 @@ else fi fi -echo "$as_me:2196: result: $cf_cv_mixedcase" >&5 +echo "$as_me:2449: result: $cf_cv_mixedcase" >&5 echo "${ECHO_T}$cf_cv_mixedcase" >&6 test "$cf_cv_mixedcase" = yes && cat >>confdefs.h <<\EOF @@ -2204,7 +2457,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:2207: checking for $ac_word" >&5 +echo "$as_me:2460: 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 @@ -2219,7 +2472,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:2222: found $ac_dir/$ac_word" >&5 +echo "$as_me:2475: found $ac_dir/$ac_word" >&5 break done @@ -2227,10 +2480,10 @@ fi fi CTAGS=$ac_cv_prog_CTAGS if test -n "$CTAGS"; then - echo "$as_me:2230: result: $CTAGS" >&5 + echo "$as_me:2483: result: $CTAGS" >&5 echo "${ECHO_T}$CTAGS" >&6 else - echo "$as_me:2233: result: no" >&5 + echo "$as_me:2486: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2241,7 +2494,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:2244: checking for $ac_word" >&5 +echo "$as_me:2497: 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 @@ -2256,7 +2509,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:2259: found $ac_dir/$ac_word" >&5 +echo "$as_me:2512: found $ac_dir/$ac_word" >&5 break done @@ -2264,10 +2517,10 @@ fi fi ETAGS=$ac_cv_prog_ETAGS if test -n "$ETAGS"; then - echo "$as_me:2267: result: $ETAGS" >&5 + echo "$as_me:2520: result: $ETAGS" >&5 echo "${ECHO_T}$ETAGS" >&6 else - echo "$as_me:2270: result: no" >&5 + echo "$as_me:2523: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2276,7 +2529,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:2279: checking for $ac_word" >&5 +echo "$as_me:2532: 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 @@ -2291,7 +2544,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:2294: found $ac_dir/$ac_word" >&5 +echo "$as_me:2547: found $ac_dir/$ac_word" >&5 break done @@ -2300,17 +2553,17 @@ fi fi MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS if test -n "$MAKE_LOWER_TAGS"; then - echo "$as_me:2303: result: $MAKE_LOWER_TAGS" >&5 + echo "$as_me:2556: result: $MAKE_LOWER_TAGS" >&5 echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6 else - echo "$as_me:2306: result: no" >&5 + echo "$as_me:2559: 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:2313: checking for $ac_word" >&5 +echo "$as_me:2566: 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 @@ -2325,7 +2578,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:2328: found $ac_dir/$ac_word" >&5 +echo "$as_me:2581: found $ac_dir/$ac_word" >&5 break done @@ -2334,10 +2587,10 @@ fi fi MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS if test -n "$MAKE_UPPER_TAGS"; then - echo "$as_me:2337: result: $MAKE_UPPER_TAGS" >&5 + echo "$as_me:2590: result: $MAKE_UPPER_TAGS" >&5 echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6 else - echo "$as_me:2340: result: no" >&5 + echo "$as_me:2593: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2361,7 +2614,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:2364: checking for $ac_word" >&5 +echo "$as_me:2617: 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 @@ -2376,7 +2629,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:2379: found $ac_dir/$ac_word" >&5 +echo "$as_me:2632: found $ac_dir/$ac_word" >&5 break done @@ -2384,17 +2637,17 @@ fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - echo "$as_me:2387: result: $AWK" >&5 + echo "$as_me:2640: result: $AWK" >&5 echo "${ECHO_T}$AWK" >&6 else - echo "$as_me:2390: result: no" >&5 + echo "$as_me:2643: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$AWK" && break done -test -z "$AWK" && { { echo "$as_me:2397: error: No awk program found" >&5 +test -z "$AWK" && { { echo "$as_me:2650: error: No awk program found" >&5 echo "$as_me: error: No awk program found" >&2;} { (exit 1); exit 1; }; } @@ -2402,7 +2655,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:2405: checking for $ac_word" >&5 +echo "$as_me:2658: 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 @@ -2417,7 +2670,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:2420: found $ac_dir/$ac_word" >&5 +echo "$as_me:2673: found $ac_dir/$ac_word" >&5 break done @@ -2425,16 +2678,73 @@ fi fi LINT=$ac_cv_prog_LINT if test -n "$LINT"; then - echo "$as_me:2428: result: $LINT" >&5 + echo "$as_me:2681: result: $LINT" >&5 echo "${ECHO_T}$LINT" >&6 else - echo "$as_me:2431: result: no" >&5 + echo "$as_me:2684: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$LINT" && break done +case "x$LINT" in +(xcppcheck|x*/cppcheck) + test -z "$LINT_OPTS" && LINT_OPTS="--enable=all" + ;; +esac + +echo "$as_me:2697: 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 2704 "configure" +#include "confdefs.h" +#include +int +main (void) +{ + +#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \ + && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \ + && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \ + && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0) +#error conflicting symbols found +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2723: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2726: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2729: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2732: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cf_cv_posix_visible=no +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +cf_cv_posix_visible=yes +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:2743: result: $cf_cv_posix_visible" >&5 +echo "${ECHO_T}$cf_cv_posix_visible" >&6 + +if test "$cf_cv_posix_visible" = no; then + cf_XOPEN_SOURCE=500 cf_POSIX_C_SOURCE=199506L cf_xopen_source= @@ -2453,7 +2763,7 @@ case $host_os in cf_xopen_source="-D_DARWIN_C_SOURCE" cf_XOPEN_SOURCE= ;; -(freebsd*|dragonfly*) +(freebsd*|dragonfly*|midnightbsd*) # 5.x headers associate # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L @@ -2473,71 +2783,436 @@ case $host_os in ;; (linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin) -echo "$as_me:2476: checking if we must define _GNU_SOURCE" >&5 -echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6 -if test "${cf_cv_gnu_source+set}" = set; then +cf_gnu_xopen_source=$cf_XOPEN_SOURCE + +echo "$as_me:2788: checking if this is the GNU C library" >&5 +echo $ECHO_N "checking if this is the GNU C library... $ECHO_C" >&6 +if test "${cf_cv_gnu_library+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 2483 "configure" +#line 2795 "configure" #include "confdefs.h" #include int -main () +main (void) { -#ifndef _XOPEN_SOURCE -make an error -#endif + #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0 + return 0; + #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0 + return 0; + #else + # error not GNU C library + #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2498: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2814: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2501: \$? = $ac_status" >&5 + echo "$as_me:2817: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2504: \"$ac_try\"") >&5 + { (eval echo "$as_me:2820: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2507: \$? = $ac_status" >&5 + echo "$as_me:2823: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cf_cv_gnu_library=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +cf_cv_gnu_library=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:2834: result: $cf_cv_gnu_library" >&5 +echo "${ECHO_T}$cf_cv_gnu_library" >&6 + +if test x$cf_cv_gnu_library = xyes; then + + # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE + # was changed to help a little. newlib incorporated the change about 4 + # years later. + echo "$as_me:2842: checking if _DEFAULT_SOURCE can be used as a basis" >&5 +echo $ECHO_N "checking if _DEFAULT_SOURCE can be used as a basis... $ECHO_C" >&6 +if test "${cf_cv_gnu_library_219+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cf_save="$CPPFLAGS" + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}-D_DEFAULT_SOURCE" + + cat >conftest.$ac_ext <<_ACEOF +#line 2854 "configure" +#include "confdefs.h" +#include +int +main (void) +{ + + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2) + return 0; + #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3) + return 0; + #else + # error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old + #endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2873: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2876: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2879: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2882: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cf_cv_gnu_library_219=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +cf_cv_gnu_library_219=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + CPPFLAGS="$cf_save" + +fi +echo "$as_me:2894: result: $cf_cv_gnu_library_219" >&5 +echo "${ECHO_T}$cf_cv_gnu_library_219" >&6 + + if test "x$cf_cv_gnu_library_219" = xyes; then + cf_save="$CPPFLAGS" + echo "$as_me:2899: checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE" >&5 +echo $ECHO_N "checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE... $ECHO_C" >&6 +if test "${cf_cv_gnu_dftsrc_219+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +cf_fix_cppflags=no +cf_new_cflags= +cf_new_cppflags= +cf_new_extra_cppflags= + +for cf_add_cflags in -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source +do +case $cf_fix_cppflags in +(no) + case $cf_add_cflags in + (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) + case $cf_add_cflags in + (-D*) + cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=yes + + if test $cf_fix_cppflags = yes ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + elif test "${cf_tst_cflags}" = "\"'" ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + fi + ;; + esac + case "$CPPFLAGS" in + (*$cf_add_cflags) + ;; + (*) + case $cf_add_cflags in + (-D*) + cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` + +CPPFLAGS=`echo "$CPPFLAGS" | \ + sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ + -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` + + ;; + esac + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + + ;; + esac + ;; + (*) + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + + ;; + esac + ;; +(yes) + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=no + ;; +esac +done + +if test -n "$cf_new_cflags" ; then + + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + +fi + +if test -n "$cf_new_cppflags" ; then + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + +fi + +if test -n "$cf_new_extra_cppflags" ; then + + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + +fi + + cat >conftest.$ac_ext <<_ACEOF +#line 3004 "configure" +#include "confdefs.h" + + #include + #include + +int +main (void) +{ + + #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1) + return 0; + #else + # error GNU C library is too old + #endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3024: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3027: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3030: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3033: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cf_cv_gnu_dftsrc_219=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +cf_cv_gnu_dftsrc_219=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:3044: result: $cf_cv_gnu_dftsrc_219" >&5 +echo "${ECHO_T}$cf_cv_gnu_dftsrc_219" >&6 + test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save" + else + cf_cv_gnu_dftsrc_219=maybe + fi + + if test "x$cf_cv_gnu_dftsrc_219" != xyes; then + + echo "$as_me:3053: checking if we must define _GNU_SOURCE" >&5 +echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6 +if test "${cf_cv_gnu_source+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cat >conftest.$ac_ext <<_ACEOF +#line 3060 "configure" +#include "confdefs.h" +#include +int +main (void) +{ + + #ifndef _XOPEN_SOURCE + #error expected _XOPEN_SOURCE to be defined + #endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3075: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3078: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3081: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3084: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_gnu_source=no else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 cf_save="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" - cat >conftest.$ac_ext <<_ACEOF -#line 2516 "configure" + +cf_fix_cppflags=no +cf_new_cflags= +cf_new_cppflags= +cf_new_extra_cppflags= + +for cf_add_cflags in -D_GNU_SOURCE +do +case $cf_fix_cppflags in +(no) + case $cf_add_cflags in + (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) + case $cf_add_cflags in + (-D*) + cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=yes + + if test $cf_fix_cppflags = yes ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + elif test "${cf_tst_cflags}" = "\"'" ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + fi + ;; + esac + case "$CPPFLAGS" in + (*$cf_add_cflags) + ;; + (*) + case $cf_add_cflags in + (-D*) + cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` + +CPPFLAGS=`echo "$CPPFLAGS" | \ + sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ + -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` + + ;; + esac + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + + ;; + esac + ;; + (*) + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + + ;; + esac + ;; +(yes) + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=no + ;; +esac +done + +if test -n "$cf_new_cflags" ; then + + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + +fi + +if test -n "$cf_new_cppflags" ; then + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + +fi + +if test -n "$cf_new_extra_cppflags" ; then + + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + +fi + + cat >conftest.$ac_ext <<_ACEOF +#line 3191 "configure" #include "confdefs.h" #include int -main () +main (void) { -#ifdef _XOPEN_SOURCE -make an error -#endif + #ifdef _XOPEN_SOURCE + #error expected _XOPEN_SOURCE to be undefined + #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2531: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3206: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2534: \$? = $ac_status" >&5 + echo "$as_me:3209: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2537: \"$ac_try\"") >&5 + { (eval echo "$as_me:3212: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2540: \$? = $ac_status" >&5 + echo "$as_me:3215: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_gnu_source=no else @@ -2546,50 +3221,52 @@ cat conftest.$ac_ext >&5 cf_cv_gnu_source=yes fi rm -f conftest.$ac_objext conftest.$ac_ext - CPPFLAGS="$cf_save" + CPPFLAGS="$cf_save" fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2555: result: $cf_cv_gnu_source" >&5 +echo "$as_me:3230: result: $cf_cv_gnu_source" >&5 echo "${ECHO_T}$cf_cv_gnu_source" >&6 -if test "$cf_cv_gnu_source" = yes -then -echo "$as_me:2560: checking if we should also define _DEFAULT_SOURCE" >&5 + if test "$cf_cv_gnu_source" = yes + then + echo "$as_me:3235: checking if we should also define _DEFAULT_SOURCE" >&5 echo $ECHO_N "checking if we should also define _DEFAULT_SOURCE... $ECHO_C" >&6 if test "${cf_cv_default_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else -CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" - cat >conftest.$ac_ext <<_ACEOF -#line 2568 "configure" + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}-D_GNU_SOURCE" + + cat >conftest.$ac_ext <<_ACEOF +#line 3245 "configure" #include "confdefs.h" #include int -main () +main (void) { -#ifdef _DEFAULT_SOURCE -make an error -#endif + #ifdef _DEFAULT_SOURCE + #error expected _DEFAULT_SOURCE to be undefined + #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2583: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3260: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2586: \$? = $ac_status" >&5 + echo "$as_me:3263: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2589: \"$ac_try\"") >&5 + { (eval echo "$as_me:3266: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2592: \$? = $ac_status" >&5 + echo "$as_me:3269: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_default_source=no else @@ -2600,9 +3277,18 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2603: result: $cf_cv_default_source" >&5 +echo "$as_me:3280: result: $cf_cv_default_source" >&5 echo "${ECHO_T}$cf_cv_default_source" >&6 -test "$cf_cv_default_source" = yes && CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE" + if test "$cf_cv_default_source" = yes + then + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}-D_DEFAULT_SOURCE" + + fi + fi + fi + fi ;; @@ -2613,6 +3299,8 @@ fi # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks and other headers which use u_int / u_short types cf_XOPEN_SOURCE= +if test "$cf_cv_posix_visible" = no; then + cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE cf_save_CFLAGS="$CFLAGS" @@ -2626,20 +3314,20 @@ 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:2629: checking if we should define _POSIX_C_SOURCE" >&5 +echo "$as_me:3317: 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}:2635: testing if the symbol is already defined go no further ..." 1>&5 +echo "${as_me:-configure}:3323: testing if the symbol is already defined go no further ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 2638 "configure" +#line 3326 "configure" #include "confdefs.h" #include int -main () +main (void) { #ifndef _POSIX_C_SOURCE @@ -2650,16 +3338,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2653: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3341: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2656: \$? = $ac_status" >&5 + echo "$as_me:3344: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2659: \"$ac_try\"") >&5 + { (eval echo "$as_me:3347: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2662: \$? = $ac_status" >&5 + echo "$as_me:3350: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_posix_c_source=no else @@ -2680,11 +3368,11 @@ cf_want_posix_source=no esac if test "$cf_want_posix_source" = yes ; then cat >conftest.$ac_ext <<_ACEOF -#line 2683 "configure" +#line 3371 "configure" #include "confdefs.h" #include int -main () +main (void) { #ifdef _POSIX_SOURCE @@ -2695,16 +3383,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2698: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3386: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2701: \$? = $ac_status" >&5 + echo "$as_me:3389: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2704: \"$ac_try\"") >&5 + { (eval echo "$as_me:3392: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2707: \$? = $ac_status" >&5 + echo "$as_me:3395: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -2715,19 +3403,22 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "${as_me:-configure}:2718: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 +echo "${as_me:-configure}:3406: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" - CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" + CPPFLAGS="$cf_trim_CPPFLAGS" -echo "${as_me:-configure}:2723: testing if the second compile does not leave our definition intact error ..." 1>&5 + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_cv_posix_c_source" + +echo "${as_me:-configure}:3414: testing if the second compile does not leave our definition intact error ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 2726 "configure" +#line 3417 "configure" #include "confdefs.h" #include int -main () +main (void) { #ifndef _POSIX_C_SOURCE @@ -2738,16 +3429,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2741: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3432: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2744: \$? = $ac_status" >&5 + echo "$as_me:3435: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2747: \"$ac_try\"") >&5 + { (eval echo "$as_me:3438: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2750: \$? = $ac_status" >&5 + echo "$as_me:3441: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -2763,7 +3454,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2766: result: $cf_cv_posix_c_source" >&5 +echo "$as_me:3457: 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 @@ -2790,10 +3481,16 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue fi ;; @@ -2812,17 +3509,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \ ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` @@ -2835,21 +3540,29 @@ done if test -n "$cf_new_cflags" ; then - CFLAGS="$CFLAGS $cf_new_cflags" + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + fi if test -n "$cf_new_cppflags" ; then - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + fi if test -n "$cf_new_extra_cppflags" ; then - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + fi fi +fi # cf_cv_posix_visible + ;; (netbsd*) cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw @@ -2881,14 +3594,14 @@ fi ;; (*) -echo "$as_me:2884: checking if we should define _XOPEN_SOURCE" >&5 +echo "$as_me:3597: 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 2891 "configure" +#line 3604 "configure" #include "confdefs.h" #include @@ -2896,7 +3609,7 @@ else #include int -main () +main (void) { #ifndef _XOPEN_SOURCE @@ -2907,25 +3620,28 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2910: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3623: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2913: \$? = $ac_status" >&5 + echo "$as_me:3626: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2916: \"$ac_try\"") >&5 + { (eval echo "$as_me:3629: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2919: \$? = $ac_status" >&5 + echo "$as_me:3632: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 cf_save="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" + cat >conftest.$ac_ext <<_ACEOF -#line 2928 "configure" +#line 3644 "configure" #include "confdefs.h" #include @@ -2933,7 +3649,7 @@ cf_save="$CPPFLAGS" #include int -main () +main (void) { #ifdef _XOPEN_SOURCE @@ -2944,16 +3660,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2947: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3663: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2950: \$? = $ac_status" >&5 + echo "$as_me:3666: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2953: \"$ac_try\"") >&5 + { (eval echo "$as_me:3669: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2956: \$? = $ac_status" >&5 + echo "$as_me:3672: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -2968,7 +3684,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2971: result: $cf_cv_xopen_source" >&5 +echo "$as_me:3687: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then @@ -3003,10 +3719,16 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue fi ;; @@ -3025,17 +3747,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \ ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` @@ -3048,21 +3778,29 @@ done if test -n "$cf_new_cflags" ; then - CFLAGS="$CFLAGS $cf_new_cflags" + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + fi if test -n "$cf_new_cppflags" ; then - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + fi if test -n "$cf_new_extra_cppflags" ; then - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + fi fi +if test "$cf_cv_posix_visible" = no; then + cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE cf_save_CFLAGS="$CFLAGS" @@ -3076,20 +3814,20 @@ 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:3079: checking if we should define _POSIX_C_SOURCE" >&5 +echo "$as_me:3817: 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}:3085: testing if the symbol is already defined go no further ..." 1>&5 +echo "${as_me:-configure}:3823: testing if the symbol is already defined go no further ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 3088 "configure" +#line 3826 "configure" #include "confdefs.h" #include int -main () +main (void) { #ifndef _POSIX_C_SOURCE @@ -3100,16 +3838,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3103: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3841: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3106: \$? = $ac_status" >&5 + echo "$as_me:3844: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3109: \"$ac_try\"") >&5 + { (eval echo "$as_me:3847: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3112: \$? = $ac_status" >&5 + echo "$as_me:3850: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_posix_c_source=no else @@ -3130,11 +3868,11 @@ cf_want_posix_source=no esac if test "$cf_want_posix_source" = yes ; then cat >conftest.$ac_ext <<_ACEOF -#line 3133 "configure" +#line 3871 "configure" #include "confdefs.h" #include int -main () +main (void) { #ifdef _POSIX_SOURCE @@ -3145,16 +3883,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3148: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3886: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3151: \$? = $ac_status" >&5 + echo "$as_me:3889: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3154: \"$ac_try\"") >&5 + { (eval echo "$as_me:3892: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3157: \$? = $ac_status" >&5 + echo "$as_me:3895: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -3165,19 +3903,22 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "${as_me:-configure}:3168: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 +echo "${as_me:-configure}:3906: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" - CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" + CPPFLAGS="$cf_trim_CPPFLAGS" -echo "${as_me:-configure}:3173: testing if the second compile does not leave our definition intact error ..." 1>&5 + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_cv_posix_c_source" + +echo "${as_me:-configure}:3914: testing if the second compile does not leave our definition intact error ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 3176 "configure" +#line 3917 "configure" #include "confdefs.h" #include int -main () +main (void) { #ifndef _POSIX_C_SOURCE @@ -3188,16 +3929,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3191: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3932: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3194: \$? = $ac_status" >&5 + echo "$as_me:3935: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3197: \"$ac_try\"") >&5 + { (eval echo "$as_me:3938: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3200: \$? = $ac_status" >&5 + echo "$as_me:3941: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -3213,7 +3954,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:3216: result: $cf_cv_posix_c_source" >&5 +echo "$as_me:3957: 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 @@ -3240,10 +3981,16 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue fi ;; @@ -3262,17 +4009,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \ ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` @@ -3285,21 +4040,29 @@ done if test -n "$cf_new_cflags" ; then - CFLAGS="$CFLAGS $cf_new_cflags" + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + fi if test -n "$cf_new_cppflags" ; then - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + fi if test -n "$cf_new_extra_cppflags" ; then - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + fi fi +fi # cf_cv_posix_visible + ;; esac @@ -3325,10 +4088,16 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue fi ;; @@ -3347,17 +4116,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \ ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` @@ -3371,38 +4148,44 @@ done if test -n "$cf_new_cflags" ; then test -n "$verbose" && echo " add to \$CFLAGS $cf_new_cflags" 1>&6 -echo "${as_me:-configure}:3374: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5 +echo "${as_me:-configure}:4151: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5 + + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" - CFLAGS="$CFLAGS $cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$verbose" && echo " add to \$CPPFLAGS $cf_new_cppflags" 1>&6 -echo "${as_me:-configure}:3382: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5 +echo "${as_me:-configure}:4161: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5 + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" 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}:3390: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5 +echo "${as_me:-configure}:4171: 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" - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" fi fi if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then - echo "$as_me:3398: checking if _XOPEN_SOURCE really is set" >&5 + echo "$as_me:4181: 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 3401 "configure" +#line 4184 "configure" #include "confdefs.h" #include int -main () +main (void) { #ifndef _XOPEN_SOURCE @@ -3413,16 +4196,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3416: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4199: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3419: \$? = $ac_status" >&5 + echo "$as_me:4202: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3422: \"$ac_try\"") >&5 + { (eval echo "$as_me:4205: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3425: \$? = $ac_status" >&5 + echo "$as_me:4208: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_XOPEN_SOURCE_set=yes else @@ -3431,16 +4214,16 @@ cat conftest.$ac_ext >&5 cf_XOPEN_SOURCE_set=no fi rm -f conftest.$ac_objext conftest.$ac_ext - echo "$as_me:3434: result: $cf_XOPEN_SOURCE_set" >&5 + echo "$as_me:4217: 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 3439 "configure" +#line 4222 "configure" #include "confdefs.h" #include int -main () +main (void) { #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE @@ -3451,16 +4234,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3454: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4237: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3457: \$? = $ac_status" >&5 + echo "$as_me:4240: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3460: \"$ac_try\"") >&5 + { (eval echo "$as_me:4243: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3463: \$? = $ac_status" >&5 + echo "$as_me:4246: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_XOPEN_SOURCE_set_ok=yes else @@ -3471,19 +4254,19 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext if test $cf_XOPEN_SOURCE_set_ok = no then - { echo "$as_me:3474: WARNING: _XOPEN_SOURCE is lower than requested" >&5 + { echo "$as_me:4257: WARNING: _XOPEN_SOURCE is lower than requested" >&5 echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;} fi else -echo "$as_me:3479: checking if we should define _XOPEN_SOURCE" >&5 +echo "$as_me:4262: 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 3486 "configure" +#line 4269 "configure" #include "confdefs.h" #include @@ -3491,7 +4274,7 @@ else #include int -main () +main (void) { #ifndef _XOPEN_SOURCE @@ -3502,25 +4285,28 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3505: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4288: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3508: \$? = $ac_status" >&5 + echo "$as_me:4291: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3511: \"$ac_try\"") >&5 + { (eval echo "$as_me:4294: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3514: \$? = $ac_status" >&5 + echo "$as_me:4297: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 cf_save="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" + cat >conftest.$ac_ext <<_ACEOF -#line 3523 "configure" +#line 4309 "configure" #include "confdefs.h" #include @@ -3528,7 +4314,7 @@ cf_save="$CPPFLAGS" #include int -main () +main (void) { #ifdef _XOPEN_SOURCE @@ -3539,16 +4325,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3542: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4328: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3545: \$? = $ac_status" >&5 + echo "$as_me:4331: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3548: \"$ac_try\"") >&5 + { (eval echo "$as_me:4334: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3551: \$? = $ac_status" >&5 + echo "$as_me:4337: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -3563,7 +4349,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:3566: result: $cf_cv_xopen_source" >&5 +echo "$as_me:4352: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then @@ -3598,10 +4384,16 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue fi ;; @@ -3620,17 +4412,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \ ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` @@ -3643,23 +4443,30 @@ done if test -n "$cf_new_cflags" ; then - CFLAGS="$CFLAGS $cf_new_cflags" + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + fi if test -n "$cf_new_cppflags" ; then - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + fi if test -n "$cf_new_extra_cppflags" ; then - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + fi fi fi fi +fi # cf_cv_posix_visible ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3667,7 +4474,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:3670: checking how to run the C preprocessor" >&5 +echo "$as_me:4477: 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 @@ -3688,18 +4495,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 3691 "configure" +#line 4498 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:3696: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4503: \"$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:3702: \$? = $ac_status" >&5 + echo "$as_me:4509: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3722,17 +4529,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 3725 "configure" +#line 4532 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:3729: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4536: \"$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:3735: \$? = $ac_status" >&5 + echo "$as_me:4542: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3769,7 +4576,7 @@ fi else ac_cv_prog_CPP=$CPP fi -echo "$as_me:3772: result: $CPP" >&5 +echo "$as_me:4579: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -3779,18 +4586,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 3782 "configure" +#line 4589 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:3787: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4594: \"$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:3793: \$? = $ac_status" >&5 + echo "$as_me:4600: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3813,17 +4620,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 3816 "configure" +#line 4623 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:3820: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4627: \"$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:3826: \$? = $ac_status" >&5 + echo "$as_me:4633: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3851,7 +4658,7 @@ rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else - { { echo "$as_me:3854: error: C preprocessor \"$CPP\" fails sanity check" >&5 + { { echo "$as_me:4661: error: C preprocessor \"$CPP\" fails sanity check" >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi @@ -3866,23 +4673,23 @@ ac_main_return=return for ac_header in fcntl.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:3869: checking for $ac_header" >&5 +echo "$as_me:4676: 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 3875 "configure" +#line 4682 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:3879: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4686: \"$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:3885: \$? = $ac_status" >&5 + echo "$as_me:4692: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3901,7 +4708,7 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:3904: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:4711: 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:4726: 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 3925 "configure" +#line 4732 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:3929: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4736: \"$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:3935: \$? = $ac_status" >&5 + echo "$as_me:4742: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3951,7 +4758,7 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:3954: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:4761: 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:4771: 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 @@ -3972,7 +4779,7 @@ if test "$cross_compiling" = yes; then cf_cv_func_mkstemp=maybe else cat >conftest.$ac_ext <<_ACEOF -#line 3975 "configure" +#line 4782 "configure" #include "confdefs.h" #include @@ -4013,15 +4820,15 @@ int main(void) _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:4016: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4823: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4019: \$? = $ac_status" >&5 + echo "$as_me:4826: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:4021: \"$ac_try\"") >&5 + { (eval echo "$as_me:4828: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4024: \$? = $ac_status" >&5 + echo "$as_me:4831: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_func_mkstemp=yes @@ -4036,56 +4843,56 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -echo "$as_me:4039: result: $cf_cv_func_mkstemp" >&5 +echo "$as_me:4846: 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:4042: checking for mkstemp" >&5 + echo "$as_me:4849: 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 4048 "configure" +#line 4855 "configure" #include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char mkstemp (); below. */ -#include -/* Override any gcc2 internal prototype to avoid an error. */ +#define mkstemp autoconf_temporary +#include /* least-intrusive standard header which defines gcc2 __stub macros */ +#undef mkstemp + #ifdef __cplusplus extern "C" #endif + /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ -char mkstemp (); -char (*f) (); +char mkstemp (void); int -main () +main (void) { -/* The GNU C library defines this for functions which it implements + +/* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_mkstemp) || defined (__stub___mkstemp) -choke me -#else -f = mkstemp; /* workaround for ICC 12.0.3 */ if (f == 0) return 1; +#error found stub for mkstemp #endif + return mkstemp (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4079: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4886: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4082: \$? = $ac_status" >&5 + echo "$as_me:4889: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4085: \"$ac_try\"") >&5 + { (eval echo "$as_me:4892: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4088: \$? = $ac_status" >&5 + echo "$as_me:4895: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_mkstemp=yes else @@ -4095,7 +4902,7 @@ ac_cv_func_mkstemp=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:4098: result: $ac_cv_func_mkstemp" >&5 +echo "$as_me:4905: result: $ac_cv_func_mkstemp" >&5 echo "${ECHO_T}$ac_cv_func_mkstemp" >&6 fi @@ -4107,56 +4914,165 @@ EOF fi -for ac_func in vsnprintf +for ac_header in unistd.h getopt.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:4920: 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 4926 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:4930: \"$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:4936: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_ext +fi +echo "$as_me:4955: 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 $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 +else + +cf_cv_getopt_header=none +for cf_header in stdio.h stdlib.h unistd.h getopt.h +do +cat >conftest.$ac_ext <<_ACEOF +#line 4975 "configure" +#include "confdefs.h" + +#include <$cf_header> +int +main (void) +{ +int x = optind; char *y = optarg + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:4988: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4991: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4994: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4997: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cf_cv_getopt_header=$cf_header + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done + +fi +echo "$as_me:5009: result: $cf_cv_getopt_header" >&5 +echo "${ECHO_T}$cf_cv_getopt_header" >&6 +if test $cf_cv_getopt_header != none ; then + +cat >>confdefs.h <<\EOF +#define HAVE_GETOPT_HEADER 1 +EOF + +fi +if test $cf_cv_getopt_header = getopt.h ; then + +cat >>confdefs.h <<\EOF +#define NEED_GETOPT_H 1 +EOF + +fi + +for ac_func in getopt vsnprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:4113: checking for $ac_func" >&5 +echo "$as_me:5029: 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 4119 "configure" +#line 5035 "configure" #include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. */ -#include -/* Override any gcc2 internal prototype to avoid an error. */ +#define $ac_func autoconf_temporary +#include /* least-intrusive standard header which defines gcc2 __stub macros */ +#undef $ac_func + #ifdef __cplusplus extern "C" #endif + /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ -char $ac_func (); -char (*f) (); +char $ac_func (void); int -main () +main (void) { -/* The GNU C library defines this for functions which it implements + +/* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1; +#error found stub for $ac_func #endif + return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4150: \"$ac_link\"") >&5 +if { (eval echo "$as_me:5066: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4153: \$? = $ac_status" >&5 + echo "$as_me:5069: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4156: \"$ac_try\"") >&5 + { (eval echo "$as_me:5072: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4159: \$? = $ac_status" >&5 + echo "$as_me:5075: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else @@ -4166,7 +5082,7 @@ eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:4169: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "$as_me:5085: 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:5095: 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. @@ -4186,12 +5102,12 @@ if test "${with_max_table_size+set}" = set; then fi; if test -n "$with_max_table_size" then - echo "$as_me:4189: result: $with_max_table_size" >&5 + echo "$as_me:5105: 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:4194: error: invalid value for --with-max-table-size: $with_max_table_size" >&5 + { { echo "$as_me:5110: 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 @@ -4201,11 +5117,11 @@ cat >>confdefs.h <&5 + echo "$as_me:5120: result: default" >&5 echo "${ECHO_T}default" >&6 fi -echo "$as_me:4208: checking if backtracking extension is wanted" >&5 +echo "$as_me:5124: 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. @@ -4213,7 +5129,7 @@ if test "${enable_btyacc+set}" = set; then enableval="$enable_btyacc" fi; -echo "$as_me:4216: result: $enable_btyacc" >&5 +echo "$as_me:5132: result: $enable_btyacc" >&5 echo "${ECHO_T}$enable_btyacc" >&6 if test "$enable_btyacc" = "yes"; then @@ -4228,7 +5144,7 @@ fi if ( test "$GCC" = yes || test "$GXX" = yes ) then -echo "$as_me:4231: checking if you want to check for gcc warnings" >&5 +echo "$as_me:5147: checking if you want to check for gcc warnings" >&5 echo $ECHO_N "checking if you want to check for gcc warnings... $ECHO_C" >&6 # Check whether --with-warnings or --without-warnings was given. @@ -4238,7 +5154,7 @@ if test "${with_warnings+set}" = set; then else cf_opt_with_warnings=no fi; -echo "$as_me:4241: result: $cf_opt_with_warnings" >&5 +echo "$as_me:5157: result: $cf_opt_with_warnings" >&5 echo "${ECHO_T}$cf_opt_with_warnings" >&6 if test "$cf_opt_with_warnings" != no ; then @@ -4260,10 +5176,10 @@ cat > conftest.i <&5 + { echo "$as_me:5179: checking for $CC __attribute__ directives..." >&5 echo "$as_me: checking for $CC __attribute__ directives..." >&6;} cat > conftest.$ac_ext < conftest.$ac_ext <&5 + if { (eval echo "$as_me:5231: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4318: \$? = $ac_status" >&5 + echo "$as_me:5234: \$? = $ac_status" >&5 (exit $ac_status); }; then - test -n "$verbose" && echo "$as_me:4320: result: ... $cf_attribute" >&5 + test -n "$verbose" && echo "$as_me:5236: result: ... $cf_attribute" >&5 echo "${ECHO_T}... $cf_attribute" >&6 cat conftest.h >>confdefs.h case $cf_attribute in @@ -4376,113 +5292,11 @@ fi rm -rf conftest* fi -INTEL_COMPILER=no - -if test "$GCC" = yes ; then - case $host_os in - (linux*|gnu*) - echo "$as_me:4384: 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 4389 "configure" -#include "confdefs.h" - -int -main () -{ - -#ifdef __INTEL_COMPILER -#else -make an error -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:4406: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:4409: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4412: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:4415: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - INTEL_COMPILER=yes -cf_save_CFLAGS="$cf_save_CFLAGS -we147" - -else - echo "$as_me: failed program was:" >&5 -cat conftest.$ac_ext >&5 -fi -rm -f conftest.$ac_objext conftest.$ac_ext - CFLAGS="$cf_save_CFLAGS" - echo "$as_me:4426: result: $INTEL_COMPILER" >&5 -echo "${ECHO_T}$INTEL_COMPILER" >&6 - ;; - esac -fi - -CLANG_COMPILER=no - -if test "$GCC" = yes ; then - echo "$as_me:4435: checking if this is really Clang C compiler" >&5 -echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6 - cf_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Qunused-arguments" - cat >conftest.$ac_ext <<_ACEOF -#line 4440 "configure" -#include "confdefs.h" - -int -main () -{ - -#ifdef __clang__ -#else -make an error -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:4457: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:4460: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4463: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:4466: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - CLANG_COMPILER=yes -cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments" - -else - echo "$as_me: failed program was:" >&5 -cat conftest.$ac_ext >&5 -fi -rm -f conftest.$ac_objext conftest.$ac_ext - CFLAGS="$cf_save_CFLAGS" - echo "$as_me:4477: result: $CLANG_COMPILER" >&5 -echo "${ECHO_T}$CLANG_COMPILER" >&6 -fi - +if test "x$have_x" = xyes; then echo "skipping X-const check"; fi cat > conftest.$ac_ext <&5 + { echo "$as_me:5313: checking for $CC warning options..." >&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS="-Wall" @@ -4512,21 +5326,20 @@ echo "$as_me: checking for $CC warning options..." >&6;} wd981 do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" - if { (eval echo "$as_me:4515: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:5329: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4518: \$? = $ac_status" >&5 + echo "$as_me:5332: \$? = $ac_status" >&5 (exit $ac_status); }; then - test -n "$verbose" && echo "$as_me:4520: result: ... -$cf_opt" >&5 + test -n "$verbose" && echo "$as_me:5334: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" fi done CFLAGS="$cf_save_CFLAGS" - -elif test "$GCC" = yes +elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown" then - { echo "$as_me:4529: checking for $CC warning options..." >&5 + { echo "$as_me:5342: checking for $CC warning options..." >&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS= @@ -4547,26 +5360,23 @@ echo "$as_me: checking for $CC warning options..." >&6;} Wpointer-arith \ Wshadow \ Wstrict-prototypes \ - Wundef $cf_gcc_warnings $cf_warn_CONST Wwrite-strings + 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:4553: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:5366: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4556: \$? = $ac_status" >&5 + echo "$as_me:5369: \$? = $ac_status" >&5 (exit $ac_status); }; then - test -n "$verbose" && echo "$as_me:4558: result: ... -$cf_opt" >&5 + test -n "$verbose" && echo "$as_me:5371: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 case $cf_opt in - (Wcast-qual) - CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES" - ;; (Winline) case $GCC_VERSION in ([34].*) test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6 -echo "${as_me:-configure}:4569: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 +echo "${as_me:-configure}:5379: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac @@ -4576,7 +5386,7 @@ echo "${as_me:-configure}:4569: 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}:4579: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 +echo "${as_me:-configure}:5389: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac @@ -4592,7 +5402,7 @@ rm -rf conftest* fi fi -echo "$as_me:4595: checking if you want to see long compiling messages" >&5 +echo "$as_me:5405: 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. @@ -4626,10 +5436,10 @@ else ECHO_CC='' fi; -echo "$as_me:4629: result: $enableval" >&5 +echo "$as_me:5439: result: $enableval" >&5 echo "${ECHO_T}$enableval" >&6 -echo "$as_me:4632: checking if you want to use dmalloc for testing" >&5 +echo "$as_me:5442: 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. @@ -4646,7 +5456,7 @@ EOF else with_dmalloc= fi; -echo "$as_me:4649: result: ${with_dmalloc:-no}" >&5 +echo "$as_me:5459: result: ${with_dmalloc:-no}" >&5 echo "${ECHO_T}${with_dmalloc:-no}" >&6 case .$with_cflags in @@ -4676,10 +5486,16 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue fi ;; @@ -4698,17 +5514,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \ ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` @@ -4721,17 +5545,23 @@ done if test -n "$cf_new_cflags" ; then - CFLAGS="$CFLAGS $cf_new_cflags" + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + fi if test -n "$cf_new_cppflags" ; then - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + fi if test -n "$cf_new_extra_cppflags" ; then - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + fi ;; @@ -4740,23 +5570,23 @@ fi esac if test "$with_dmalloc" = yes ; then - echo "$as_me:4743: checking for dmalloc.h" >&5 + echo "$as_me:5573: 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 4749 "configure" +#line 5579 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4753: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:5583: \"$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:4759: \$? = $ac_status" >&5 + echo "$as_me:5589: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4775,11 +5605,11 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:4778: result: $ac_cv_header_dmalloc_h" >&5 +echo "$as_me:5608: 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:4782: checking for dmalloc_debug in -ldmalloc" >&5 +echo "$as_me:5612: 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 @@ -4787,7 +5617,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldmalloc $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 4790 "configure" +#line 5620 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -4798,7 +5628,7 @@ extern "C" builtin and then its argument prototype would still apply. */ char dmalloc_debug (); int -main () +main (void) { dmalloc_debug (); ; @@ -4806,16 +5636,16 @@ dmalloc_debug (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4809: \"$ac_link\"") >&5 +if { (eval echo "$as_me:5639: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4812: \$? = $ac_status" >&5 + echo "$as_me:5642: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4815: \"$ac_try\"") >&5 + { (eval echo "$as_me:5645: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4818: \$? = $ac_status" >&5 + echo "$as_me:5648: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dmalloc_dmalloc_debug=yes else @@ -4826,7 +5656,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:4829: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5 +echo "$as_me:5659: 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:5674: 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. @@ -4858,7 +5688,7 @@ EOF else with_dbmalloc= fi; -echo "$as_me:4861: result: ${with_dbmalloc:-no}" >&5 +echo "$as_me:5691: result: ${with_dbmalloc:-no}" >&5 echo "${ECHO_T}${with_dbmalloc:-no}" >&6 case .$with_cflags in @@ -4888,10 +5718,16 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue fi ;; @@ -4910,17 +5746,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \ ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` @@ -4933,17 +5777,23 @@ done if test -n "$cf_new_cflags" ; then - CFLAGS="$CFLAGS $cf_new_cflags" + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + fi if test -n "$cf_new_cppflags" ; then - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + fi if test -n "$cf_new_extra_cppflags" ; then - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + fi ;; @@ -4952,23 +5802,23 @@ fi esac if test "$with_dbmalloc" = yes ; then - echo "$as_me:4955: checking for dbmalloc.h" >&5 + echo "$as_me:5805: 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 4961 "configure" +#line 5811 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4965: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:5815: \"$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:4971: \$? = $ac_status" >&5 + echo "$as_me:5821: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4987,11 +5837,11 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:4990: result: $ac_cv_header_dbmalloc_h" >&5 +echo "$as_me:5840: 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:4994: checking for debug_malloc in -ldbmalloc" >&5 +echo "$as_me:5844: 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 @@ -4999,7 +5849,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldbmalloc $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 5002 "configure" +#line 5852 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -5010,7 +5860,7 @@ extern "C" builtin and then its argument prototype would still apply. */ char debug_malloc (); int -main () +main (void) { debug_malloc (); ; @@ -5018,16 +5868,16 @@ debug_malloc (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:5021: \"$ac_link\"") >&5 +if { (eval echo "$as_me:5871: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:5024: \$? = $ac_status" >&5 + echo "$as_me:5874: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:5027: \"$ac_try\"") >&5 + { (eval echo "$as_me:5877: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5030: \$? = $ac_status" >&5 + echo "$as_me:5880: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dbmalloc_debug_malloc=yes else @@ -5038,7 +5888,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:5041: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5 +echo "$as_me:5891: 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:5906: 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. @@ -5070,7 +5920,7 @@ EOF else with_valgrind= fi; -echo "$as_me:5073: result: ${with_valgrind:-no}" >&5 +echo "$as_me:5923: result: ${with_valgrind:-no}" >&5 echo "${ECHO_T}${with_valgrind:-no}" >&6 case .$with_cflags in @@ -5100,10 +5950,16 @@ case $cf_fix_cppflags in && cf_fix_cppflags=yes if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + continue fi ;; @@ -5122,17 +5978,25 @@ CPPFLAGS=`echo "$CPPFLAGS" | \ ;; esac - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; (*) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + ;; esac ;; (yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` @@ -5145,17 +6009,23 @@ done if test -n "$cf_new_cflags" ; then - CFLAGS="$CFLAGS $cf_new_cflags" + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + fi if test -n "$cf_new_cppflags" ; then - CPPFLAGS="$CPPFLAGS $cf_new_cppflags" + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + fi if test -n "$cf_new_extra_cppflags" ; then - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + fi ;; @@ -5163,7 +6033,7 @@ fi ;; esac -echo "$as_me:5166: checking if you want to perform memory-leak testing" >&5 +echo "$as_me:6036: 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. @@ -5173,7 +6043,7 @@ if test "${enable_leaks+set}" = set; then else : ${with_no_leaks:=no} fi; -echo "$as_me:5176: result: $with_no_leaks" >&5 +echo "$as_me:6046: result: $with_no_leaks" >&5 echo "${ECHO_T}$with_no_leaks" >&6 if test "$with_no_leaks" = yes ; then @@ -5190,7 +6060,7 @@ fi # Extract the first word of "groff", so it can be a program name with args. set dummy groff; ac_word=$2 -echo "$as_me:5193: checking for $ac_word" >&5 +echo "$as_me:6063: 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 @@ -5207,7 +6077,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:5210: found $ac_dir/$ac_word" >&5 + echo "$as_me:6080: found $ac_dir/$ac_word" >&5 break fi done @@ -5219,16 +6089,18 @@ fi GROFF_PATH=$ac_cv_path_GROFF_PATH if test -n "$GROFF_PATH"; then - echo "$as_me:5222: result: $GROFF_PATH" >&5 + echo "$as_me:6092: result: $GROFF_PATH" >&5 echo "${ECHO_T}$GROFF_PATH" >&6 else - echo "$as_me:5225: result: no" >&5 + echo "$as_me:6095: result: no" >&5 echo "${ECHO_T}no" >&6 fi -# Extract the first word of "nroff", so it can be a program name with args. -set dummy nroff; ac_word=$2 -echo "$as_me:5231: checking for $ac_word" >&5 +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:6103: 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 @@ -5245,22 +6117,63 @@ 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:5248: found $ac_dir/$ac_word" >&5 + echo "$as_me:6120: found $ac_dir/$ac_word" >&5 break fi done - test -z "$ac_cv_path_NROFF_PATH" && ac_cv_path_NROFF_PATH="no" ;; esac fi NROFF_PATH=$ac_cv_path_NROFF_PATH if test -n "$NROFF_PATH"; then - echo "$as_me:5260: result: $NROFF_PATH" >&5 + echo "$as_me:6131: result: $NROFF_PATH" >&5 echo "${ECHO_T}$NROFF_PATH" >&6 else - echo "$as_me:5263: result: no" >&5 + echo "$as_me:6134: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$NROFF_PATH" && break +done +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:6144: 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 +else + case $TBL_PATH in + [\\/]* | ?:[\\/]*) + ac_cv_path_TBL_PATH="$TBL_PATH" # Let the user override the test with a path. + ;; + *) + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + if $as_executable_p "$ac_dir/$ac_word"; then + ac_cv_path_TBL_PATH="$ac_dir/$ac_word" + echo "$as_me:6161: found $ac_dir/$ac_word" >&5 + break +fi +done + + test -z "$ac_cv_path_TBL_PATH" && ac_cv_path_TBL_PATH="cat" + ;; +esac +fi +TBL_PATH=$ac_cv_path_TBL_PATH + +if test -n "$TBL_PATH"; then + echo "$as_me:6173: result: $TBL_PATH" >&5 +echo "${ECHO_T}$TBL_PATH" >&6 +else + echo "$as_me:6176: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -5273,26 +6186,14 @@ else GROFF_NOTE= fi -echo "$as_me:5276: 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. -if test "${with_man2html+set}" = set; then - withval="$with_man2html" - cf_man2html=$withval -else - cf_man2html=$GROFF_PATH -fi; - -cf_with_groff=no - -case $cf_man2html in -(yes) - echo "$as_me:5291: result: man2html" >&5 -echo "${ECHO_T}man2html" >&6 +case "x${with_man2html}" in +(xno) + cf_man2html=no + ;; +(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:5295: checking for $ac_word" >&5 +echo "$as_me:6196: 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 @@ -5309,7 +6210,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:5312: found $ac_dir/$ac_word" >&5 + echo "$as_me:6213: found $ac_dir/$ac_word" >&5 break fi done @@ -5321,10 +6222,85 @@ fi cf_man2html=$ac_cv_path_cf_man2html if test -n "$cf_man2html"; then - echo "$as_me:5324: result: $cf_man2html" >&5 + echo "$as_me:6225: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 else - echo "$as_me:5327: result: no" >&5 + echo "$as_me:6228: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + case "x$cf_man2html" in + (x/*) + echo "$as_me:6234: 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 + cf_man2html_ok=yes + else + cf_man2html=no + cf_man2html_ok=no + fi + echo "$as_me:6243: result: $cf_man2html_ok" >&5 +echo "${ECHO_T}$cf_man2html_ok" >&6 + ;; + (*) + cf_man2html=no + ;; + esac +esac + +echo "$as_me:6252: 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. +if test "${with_man2html+set}" = set; then + withval="$with_man2html" + cf_man2html=$withval +else + cf_man2html=$cf_man2html +fi; + +cf_with_groff=no + +case $cf_man2html in +(yes) + echo "$as_me:6267: 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:6271: 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 +else + case $cf_man2html in + [\\/]* | ?:[\\/]*) + ac_cv_path_cf_man2html="$cf_man2html" # Let the user override the test with a path. + ;; + *) + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + if $as_executable_p "$ac_dir/$ac_word"; then + ac_cv_path_cf_man2html="$ac_dir/$ac_word" + echo "$as_me:6288: found $ac_dir/$ac_word" >&5 + break +fi +done + + test -z "$ac_cv_path_cf_man2html" && ac_cv_path_cf_man2html="no" + ;; +esac +fi +cf_man2html=$ac_cv_path_cf_man2html + +if test -n "$cf_man2html"; then + echo "$as_me:6300: result: $cf_man2html" >&5 +echo "${ECHO_T}$cf_man2html" >&6 +else + echo "$as_me:6303: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -5332,11 +6308,11 @@ fi (no|groff|*/groff*) cf_with_groff=yes cf_man2html=$GROFF_PATH - echo "$as_me:5335: result: $cf_man2html" >&5 + echo "$as_me:6311: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 ;; (*) - echo "$as_me:5339: result: $cf_man2html" >&5 + echo "$as_me:6315: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 ;; esac @@ -5370,7 +6346,7 @@ then MAN2HTML_NOTE="$GROFF_NOTE" MAN2HTML_PATH="$GROFF_PATH" cat >>$MAN2HTML_TEMP <&5 + { { echo "$as_me:6379: 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:5410: checking for $cf_man2html top/bottom margins" >&5 + echo "$as_me:6386: 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 @@ -5417,7 +6393,7 @@ echo $ECHO_N "checking for $cf_man2html top/bottom margins... $ECHO_C" >&6 MARKER CF_EOF - LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out + LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[^0-9]*://' -e 's/:.*//'` cf_man2html_top=`expr $cf_man2html_1st - 2` @@ -5425,10 +6401,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:5428: result: $cf_man2html_top_bot" >&5 + echo "$as_me:6404: result: $cf_man2html_top_bot" >&5 echo "${ECHO_T}$cf_man2html_top_bot" >&6 - echo "$as_me:5431: checking for pagesize to use" >&5 + echo "$as_me:6407: 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 @@ -5447,13 +6423,13 @@ echo $ECHO_N "checking for pagesize to use... $ECHO_C" >&6 CF_EOF done - LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out - cf_man2html_page=`fgrep -n HEAD1 conftest.out |tail -n 1 |sed -e 's/^[^0-9]*://' -e 's/:.*//'` + LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out + cf_man2html_page=`fgrep -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[^0-9]*://' -e 's/:.*//'` test -z "$cf_man2html_page" && cf_man2html_page=99999 test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999 rm -rf conftest* - echo "$as_me:5456: result: $cf_man2html_page" >&5 + echo "$as_me:6432: result: $cf_man2html_page" >&5 echo "${ECHO_T}$cf_man2html_page" >&6 cat >>$MAN2HTML_TEMP <&6 MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page" case \${TYPE} in (ms) - tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS + $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS ;; (*) - tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS + $TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS ;; esac CF_EOF @@ -5472,13 +6448,13 @@ fi chmod 700 $MAN2HTML_TEMP -echo "$as_me:5475: checking for ANSI C header files" >&5 +echo "$as_me:6451: 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 5481 "configure" +#line 6457 "configure" #include "confdefs.h" #include #include @@ -5486,13 +6462,13 @@ else #include _ACEOF -if { (eval echo "$as_me:5489: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:6465: \"$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:6471: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -5514,7 +6490,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 5517 "configure" +#line 6493 "configure" #include "confdefs.h" #include @@ -5532,7 +6508,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 5535 "configure" +#line 6511 "configure" #include "confdefs.h" #include @@ -5553,7 +6529,7 @@ if test $ac_cv_header_stdc = yes; then : else cat >conftest.$ac_ext <<_ACEOF -#line 5556 "configure" +#line 6532 "configure" #include "confdefs.h" #include #if ((' ' & 0x0FF) == 0x020) @@ -5568,7 +6544,7 @@ else #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int -main () +main (void) { int i; for (i = 0; i < 256; i++) @@ -5579,15 +6555,15 @@ main () } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:5582: \"$ac_link\"") >&5 +if { (eval echo "$as_me:6558: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:5585: \$? = $ac_status" >&5 + echo "$as_me:6561: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:5587: \"$ac_try\"") >&5 + { (eval echo "$as_me:6563: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5590: \$? = $ac_status" >&5 + echo "$as_me:6566: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -5600,7 +6576,7 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi -echo "$as_me:5603: result: $ac_cv_header_stdc" >&5 +echo "$as_me:6579: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then @@ -5616,28 +6592,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:5619: checking for $ac_header" >&5 +echo "$as_me:6595: 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 5625 "configure" +#line 6601 "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:5631: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:6607: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:5634: \$? = $ac_status" >&5 + echo "$as_me:6610: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:5637: \"$ac_try\"") >&5 + { (eval echo "$as_me:6613: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5640: \$? = $ac_status" >&5 + echo "$as_me:6616: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else @@ -5647,7 +6623,7 @@ eval "$as_ac_Header=no" fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:5650: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:6626: 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:6636: 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 5666 "configure" +#line 6642 "configure" #include "confdefs.h" $ac_includes_default int -main () +main (void) { if ((mode_t *) 0) return 0; @@ -5678,16 +6654,16 @@ if (sizeof (mode_t)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:5681: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:6657: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:5684: \$? = $ac_status" >&5 + echo "$as_me:6660: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:5687: \"$ac_try\"") >&5 + { (eval echo "$as_me:6663: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5690: \$? = $ac_status" >&5 + echo "$as_me:6666: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_mode_t=yes else @@ -5697,7 +6673,7 @@ ac_cv_type_mode_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:5700: result: $ac_cv_type_mode_t" >&5 +echo "$as_me:6676: 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 : @@ -5790,7 +6766,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:5793: creating $CONFIG_STATUS" >&5 +{ echo "$as_me:6769: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL @@ -5919,7 +6895,7 @@ EOF cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header - { { echo "$as_me:5966: error: ambiguous option: $1 + { { echo "$as_me:6942: 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;} @@ -5982,7 +6958,7 @@ Try \`$0 --help' for more information." >&2;} ac_need_defaults=false;; # This is an error. - -*) { { echo "$as_me:5985: error: unrecognized option: $1 + -*) { { echo "$as_me:6961: 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;} @@ -6001,7 +6977,7 @@ cat >&5 << _ACEOF ## Running config.status. ## ## ----------------------- ## -This file was extended by $as_me 2.52.20150926, executed with +This file was extended by $as_me 2.52.20200111, executed with CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS @@ -6019,7 +6995,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:6022: error: invalid argument: $ac_config_target" >&5 + *) { { echo "$as_me:6998: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac @@ -6082,6 +7058,7 @@ s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t +s,@runstatedir@,$runstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t @@ -6142,6 +7119,7 @@ s,@SHOW_CC@,$SHOW_CC,;t t s,@ECHO_CC@,$ECHO_CC,;t t s,@GROFF_PATH@,$GROFF_PATH,;t t s,@NROFF_PATH@,$NROFF_PATH,;t t +s,@TBL_PATH@,$TBL_PATH,;t t s,@GROFF_NOTE@,$GROFF_NOTE,;t t s,@NROFF_NOTE@,$NROFF_NOTE,;t t s,@cf_man2html@,$cf_man2html,;t t @@ -6280,7 +7258,7 @@ done; } esac if test x"$ac_file" != x-; then - { echo "$as_me:6283: creating $ac_file" >&5 + { echo "$as_me:7261: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi @@ -6298,7 +7276,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:6301: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:7279: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -6311,7 +7289,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:6314: error: cannot find input file: $f" >&5 + { { echo "$as_me:7292: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -6327,7 +7305,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:6330: WARNING: datarootdir was used implicitly but not set: + { echo "$as_me:7308: 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;} @@ -6336,7 +7314,7 @@ $ac_seen" >&2;} fi ac_seen=`grep '${datarootdir}' $ac_item` if test -n "$ac_seen"; then - { echo "$as_me:6339: WARNING: datarootdir was used explicitly but not set: + { echo "$as_me:7317: 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;} @@ -6373,7 +7351,7 @@ s,@INSTALL@,$ac_INSTALL,;t t ac_init=`egrep '[ ]*'$ac_name'[ ]*=' $ac_file` if test -z "$ac_init"; then ac_seen=`echo "$ac_seen" |sed -e 's,^,'$ac_file':,'` - { echo "$as_me:6376: WARNING: Variable $ac_name is used but was not set: + { echo "$as_me:7354: 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;} @@ -6384,7 +7362,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:6387: WARNING: Some variables may not be substituted: + { echo "$as_me:7365: WARNING: Some variables may not be substituted: $ac_seen" >&5 echo "$as_me: WARNING: Some variables may not be substituted: $ac_seen" >&2;} @@ -6433,7 +7411,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:6436: creating $ac_file" >&5 + test x"$ac_file" != x- && { echo "$as_me:7414: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the @@ -6444,7 +7422,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:6447: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:7425: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -6457,7 +7435,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:6460: error: cannot find input file: $f" >&5 + { { echo "$as_me:7438: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -6575,7 +7553,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:6578: $ac_file is unchanged" >&5 + { echo "$as_me:7556: $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/contrib/byacc/configure.in b/contrib/byacc/configure.in index 6602180d317c..7a719ca1596c 100644 --- a/contrib/byacc/configure.in +++ b/contrib/byacc/configure.in @@ -1,7 +1,7 @@ dnl Process this file with 'autoconf' to produce a 'configure' script -dnl $Id: configure.in,v 1.21 2015/07/05 22:07:36 tom Exp $ -AC_PREREQ(2.52.20011201) -AC_REVISION($Revision: 1.21 $) +dnl $Id: configure.in,v 1.23 2020/03/10 22:53:47 tom Exp $ +AC_PREREQ(2.52.20200111) +AC_REVISION($Revision: 1.23 $) AC_INIT(main.c) AC_CONFIG_HEADER(config.h:config_h.in) @@ -15,10 +15,13 @@ CF_MAKE_TAGS CF_PROG_AWK CF_PROG_LINT +CF_WITHOUT_X + CF_XOPEN_SOURCE AC_CHECK_HEADERS(fcntl.h) CF_MKSTEMP -AC_HAVE_FUNCS(vsnprintf) +CF_GETOPT_HEADER +AC_HAVE_FUNCS(getopt vsnprintf) AC_MSG_CHECKING(for maximum table size) AC_ARG_WITH([max-table-size], diff --git a/contrib/byacc/defs.h b/contrib/byacc/defs.h index 75e142ef931e..db4dec937ade 100644 --- a/contrib/byacc/defs.h +++ b/contrib/byacc/defs.h @@ -1,4 +1,4 @@ -/* $Id: defs.h,v 1.57 2017/04/30 23:29:11 tom Exp $ */ +/* $Id: defs.h,v 1.65 2019/11/19 23:47:49 tom Exp $ */ #ifdef HAVE_CONFIG_H #include @@ -101,39 +101,48 @@ /* keyword codes */ -#define TOKEN 0 -#define LEFT 1 -#define RIGHT 2 -#define NONASSOC 3 -#define MARK 4 -#define TEXT 5 -#define TYPE 6 -#define START 7 -#define UNION 8 -#define IDENT 9 -#define EXPECT 10 -#define EXPECT_RR 11 -#define PURE_PARSER 12 -#define PARSE_PARAM 13 -#define LEX_PARAM 14 -#define POSIX_YACC 15 -#define TOKEN_TABLE 16 -#define ERROR_VERBOSE 17 -#define XXXDEBUG 18 +typedef enum +{ + TOKEN = 0 + ,LEFT + ,RIGHT + ,NONASSOC + ,MARK + ,TEXT + ,TYPE + ,START + ,UNION + ,IDENT + ,EXPECT + ,EXPECT_RR + ,PURE_PARSER + ,PARSE_PARAM + ,LEX_PARAM + ,POSIX_YACC + ,TOKEN_TABLE + ,ERROR_VERBOSE + ,XXXDEBUG + ,XCODE #if defined(YYBTYACC) -#define LOCATIONS 19 -#define DESTRUCTOR 20 -#define INITIAL_ACTION 21 + ,LOCATIONS + ,DESTRUCTOR + ,INITIAL_ACTION #endif +} +KEY_CASES; /* symbol classes */ -#define UNKNOWN 0 -#define TERM 1 -#define NONTERM 2 -#define ACTION 3 -#define ARGUMENT 4 +typedef enum +{ + UNKNOWN = 0 + ,TERM + ,NONTERM + ,ACTION + ,ARGUMENT +} +SYM_CASES; /* the undefined value */ @@ -146,9 +155,10 @@ /* character macros */ -#define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$') +#define IS_NAME1(c) (isalpha(UCH(c)) || (c) == '_' || (c) == '$') +#define IS_NAME2(c) (isalnum(UCH(c)) || (c) == '_' || (c) == '$') +#define IS_IDENT(c) (isalnum(UCH(c)) || (c) == '_' || (c) == '.' || (c) == '$') #define IS_OCTAL(c) ((c) >= '0' && (c) <= '7') -#define NUMERIC_VALUE(c) ((c) - '0') /* symbol macros */ @@ -272,6 +282,7 @@ struct param /* global variables */ +extern char dflag2; extern char dflag; extern char gflag; extern char iflag; @@ -411,6 +422,21 @@ extern param *parse_param; #endif #endif +#ifdef __GNUC__ +#define ATTRIBUTE_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define ATTRIBUTE_NORETURN __declspec(noreturn) +#else +#define ATTRIBUTE_NORETURN +#endif + +#if defined(NDEBUG) && defined(_MSC_VER) +#define NODEFAULT __assume(0); +#else +#define NODEFAULT +#endif +#define NOTREACHED NODEFAULT + #ifndef GCC_UNUSED #if defined(__unused) #define GCC_UNUSED __unused @@ -438,20 +464,31 @@ struct ainfo 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); +ATTRIBUTE_NORETURN extern void at_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void at_warning(int a_lineno, int i); +ATTRIBUTE_NORETURN extern void bad_formals(void) GCC_NORETURN; extern void default_action_warning(char *s); extern void destructor_redeclared_warning(const struct ainfo *); +ATTRIBUTE_NORETURN extern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void dollar_warning(int a_lineno, int i); +ATTRIBUTE_NORETURN extern void fatal(const char *msg) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void illegal_character(char *c_cptr) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void illegal_tag(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void missing_brace(void) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void no_grammar(void) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void no_space(void) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void open_error(const char *filename) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void over_unionized(char *u_cptr) GCC_NORETURN; extern void prec_redeclared(void); extern void reprec_warning(char *s); @@ -459,25 +496,43 @@ 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); +ATTRIBUTE_NORETURN extern void syntax_error(int st_lineno, char *st_line, char *st_cptr) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void terminal_lhs(int s_lineno) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void terminal_start(char *s) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void tokenized_start(char *s) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void undefined_goal(char *s) GCC_NORETURN; extern void undefined_symbol_warning(char *s); +ATTRIBUTE_NORETURN extern void unexpected_EOF(void) GCC_NORETURN; -extern void unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char *d_line, const char *d_cptr); +extern void unknown_arg_warning(int d_lineno, const char *dlr_opt, + const char *d_arg, const char *d_line, + const char *d_cptr); +ATTRIBUTE_NORETURN extern void unknown_rhs(int i) GCC_NORETURN; extern void unsupported_flag_warning(const char *flag, const char *details); +ATTRIBUTE_NORETURN extern void unterminated_action(const struct ainfo *) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void unterminated_comment(const struct ainfo *) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void unterminated_string(const struct ainfo *) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void unterminated_text(const struct ainfo *) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void unterminated_union(const struct ainfo *) GCC_NORETURN; extern void untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name); +ATTRIBUTE_NORETURN extern void untyped_lhs(void) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void untyped_rhs(int i, char *s) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void used_reserved(char *s) GCC_NORETURN; +ATTRIBUTE_NORETURN extern void unterminated_arglist(const struct ainfo *) GCC_NORETURN; extern void wrong_number_args_warning(const char *which, const char *a_name); extern void wrong_type_for_arg_warning(int i, char *a_name); @@ -497,6 +552,7 @@ extern void show_shifts(void); /* main.c */ extern void *allocate(size_t n); +ATTRIBUTE_NORETURN extern void done(int k) GCC_NORETURN; /* mkpar.c */ @@ -512,6 +568,7 @@ struct mstring extern void msprintf(struct mstring *, const char *, ...) GCC_PRINTFLIKE(2,3); extern int mputchar(struct mstring *, int); extern struct mstring *msnew(void); +extern struct mstring *msrenew(char *); extern char *msdone(struct mstring *); extern int strnscmp(const char *, const char *); extern unsigned int strnshash(const char *); @@ -526,6 +583,24 @@ extern void output(void); /* reader.c */ extern void reader(void); +typedef enum +{ + CODE_HEADER = 0 + ,CODE_REQUIRES + ,CODE_PROVIDES + ,CODE_TOP + ,CODE_IMPORTS + ,CODE_MAX /* this must be last */ +} +CODE_CASES; +extern struct code_lines +{ + const char *name; + char *lines; + size_t num; +} +code_lines[CODE_MAX]; + /* skeleton.c (generated by skel2c) */ extern void write_section(FILE * fp, const char *const section[]); diff --git a/contrib/byacc/main.c b/contrib/byacc/main.c index 9a8099c5ec2e..20a93c26bbd2 100644 --- a/contrib/byacc/main.c +++ b/contrib/byacc/main.c @@ -1,7 +1,7 @@ -/* $Id: main.c,v 1.60 2017/04/30 20:57:56 Julien.Ramseier Exp $ */ +/* $Id: main.c,v 1.69 2019/11/25 23:24:36 Tom.Shields Exp $ */ #include -#ifndef _WIN32 +#if !defined(_WIN32) || defined(__MINGW32__) #include /* for _exit() */ #else #include /* for _exit() */ @@ -33,6 +33,7 @@ static MY_TMPFILES *my_tmpfiles; #endif /* USE_MKSTEMP */ char dflag; +char dflag2; char gflag; char iflag; char lflag; @@ -150,7 +151,7 @@ done(int k) if (rflag) DO_FREE(code_file_name); - if (dflag) + if (dflag && !dflag2) DO_FREE(defines_file_name); if (iflag) @@ -210,6 +211,7 @@ usage(void) ," -b file_prefix set filename prefix (default \"y.\")" ," -B create a backtracking parser" ," -d write definitions (" DEFINES_SUFFIX ")" + ," -H defines_file write definitions to defines_file" ," -i write interface (y.tab.i)" ," -g write a graphical description" ," -l suppress #line directives" @@ -230,7 +232,7 @@ usage(void) for (n = 0; n < sizeof(msg) / sizeof(msg[0]); ++n) fprintf(stderr, "%s\n", msg[n]); - exit(1); + exit(EXIT_FAILURE); } static void @@ -248,6 +250,7 @@ setflag(int ch) case 'd': dflag = 1; + dflag2 = 0; break; case 'g': @@ -308,6 +311,46 @@ static void getargs(int argc, char *argv[]) { int i; +#ifdef HAVE_GETOPT + int ch; + + if (argc > 0) + myname = argv[0]; + + while ((ch = getopt(argc, argv, "Bb:dgH:ilLo:Pp:rstVvy")) != -1) + { + switch (ch) + { + case 'b': + file_prefix = optarg; + break; + case 'H': + dflag = dflag2 = 1; + defines_file_name = optarg; + break; + case 'o': + output_file_name = optarg; + break; + case 'p': + symbol_prefix = optarg; + break; + default: + setflag(ch); + break; + } + } + if ((i = optind) < argc) + { + /* getopt handles "--" specially, while we handle "-" specially */ + if (!strcmp(argv[i], "-")) + { + if ((i + 1) < argc) + usage(); + input_file = stdin; + return; + } + } +#else char *s; int ch; @@ -340,6 +383,16 @@ getargs(int argc, char *argv[]) usage(); continue; + case 'H': + dflag = dflag2 = 1; + if (*++s) + defines_file_name = s; + else if (++i < argc) + defines_file_name = argv[i]; + else + usage(); + continue; + case 'o': if (*++s) output_file_name = s; @@ -378,7 +431,9 @@ getargs(int argc, char *argv[]) end_of_option:; } - no_more_options:; + no_more_options: + +#endif /* HAVE_GETOPT */ if (i + 1 != argc) usage(); input_file_name_len = strlen(argv[i]); @@ -476,7 +531,7 @@ create_file_names(void) else code_file_name = output_file_name; - if (dflag) + if (dflag && !dflag2) { CREATE_FILE_NAME(defines_file_name, defines_suffix); } @@ -578,7 +633,8 @@ open_tmpfile(const char *label) char *name; const char *mark; - if ((tmpdir = getenv("TMPDIR")) == 0 || access(tmpdir, W_OK) != 0) + if (((tmpdir = getenv("TMPDIR")) == 0 || access(tmpdir, W_OK) != 0) || + ((tmpdir = getenv("TEMP")) == 0 || access(tmpdir, W_OK) != 0)) { #ifdef P_tmpdir tmpdir = P_tmpdir; @@ -605,27 +661,28 @@ open_tmpfile(const char *label) sprintf(name, MY_FMT, tmpdir, (int)(mark - label), label); fd = mkstemp(name); - if (fd >= 0) + if (fd >= 0 + && (result = fdopen(fd, "w+")) != 0) { - result = fdopen(fd, "w+"); - if (result != 0) + MY_TMPFILES *item; + + if (my_tmpfiles == 0) { - MY_TMPFILES *item; - - if (my_tmpfiles == 0) - { - atexit(close_tmpfiles); - } - - item = NEW(MY_TMPFILES); - NO_SPACE(item); - - item->name = name; - NO_SPACE(item->name); - - item->next = my_tmpfiles; - my_tmpfiles = item; + atexit(close_tmpfiles); } + + item = NEW(MY_TMPFILES); + NO_SPACE(item); + + item->name = name; + NO_SPACE(item->name); + + item->next = my_tmpfiles; + my_tmpfiles = item; + } + else + { + FREE(name); } (void)umask(save_umask); } @@ -678,7 +735,7 @@ open_files(void) fprintf(graph_file, "\t*/\n"); } - if (dflag) + if (dflag || dflag2) { defines_file = fopen(defines_file_name, "w"); if (defines_file == 0) diff --git a/contrib/byacc/mkpar.c b/contrib/byacc/mkpar.c index 759cb7e73b99..9fedc7ca8d66 100644 --- a/contrib/byacc/mkpar.c +++ b/contrib/byacc/mkpar.c @@ -1,4 +1,4 @@ -/* $Id: mkpar.c,v 1.15 2016/06/07 00:22:12 tom Exp $ */ +/* $Id: mkpar.c,v 1.16 2019/11/04 01:23:02 tom Exp $ */ #include "defs.h" @@ -174,14 +174,16 @@ find_final_state(void) Value_t *to_state2; shifts *p; - p = shift_table[0]; - to_state2 = p->shift; - goal = ritem[1]; - for (i = p->nshifts - 1; i >= 0; --i) + if ((p = shift_table[0]) != 0) { - final_state = to_state2[i]; - if (accessing_symbol[final_state] == goal) - break; + to_state2 = p->shift; + goal = ritem[1]; + for (i = p->nshifts - 1; i >= 0; --i) + { + final_state = to_state2[i]; + if (accessing_symbol[final_state] == goal) + break; + } } } diff --git a/contrib/byacc/mstring.c b/contrib/byacc/mstring.c index 3bdb122973a4..1110a7b89f39 100644 --- a/contrib/byacc/mstring.c +++ b/contrib/byacc/mstring.c @@ -1,4 +1,4 @@ -/* $Id: mstring.c,v 1.7 2016/12/02 17:57:21 tom Exp $ */ +/* $Id: mstring.c,v 1.9 2019/11/19 23:54:53 tom Exp $ */ #include #include @@ -12,13 +12,11 @@ #define HEAD 24 #define TAIL 8 -#if defined(YYBTYACC) - static char *buf_ptr; static size_t buf_len; void -msprintf(struct mstring *s, const char *fmt,...) +msprintf(struct mstring *s, const char *fmt, ...) { va_list args; size_t len; @@ -91,7 +89,6 @@ msprintf(struct mstring *s, const char *fmt,...) memcpy(s->ptr, buf_ptr, len); s->ptr += len; } -#endif int mputchar(struct mstring *s, int ch) @@ -136,6 +133,20 @@ msnew(void) return n; } +struct mstring * +msrenew(char *value) +{ + struct mstring *r = 0; + if (value != 0) + { + r = msnew(); + r->base = value; + r->end = value + strlen(value); + r->ptr = r->end; + } + return r; +} + char * msdone(struct mstring *s) { @@ -198,10 +209,8 @@ strnshash(const char *s) void mstring_leaks(void) { -#if defined(YYBTYACC) free(buf_ptr); buf_ptr = 0; buf_len = 0; -#endif } #endif diff --git a/contrib/byacc/output.c b/contrib/byacc/output.c index d52d920b53ae..d849ceb264e4 100644 --- a/contrib/byacc/output.c +++ b/contrib/byacc/output.c @@ -1,4 +1,4 @@ -/* $Id: output.c,v 1.81 2017/04/30 23:23:32 tom Exp $ */ +/* $Id: output.c,v 1.92 2019/11/20 00:55:05 tom Exp $ */ #include "defs.h" @@ -185,6 +185,27 @@ output_prefix(FILE * fp) fprintf(fp, "#define YYPREFIX \"%s\"\n", symbol_prefix); } +static void +output_code_lines(FILE * fp, int cl) +{ + if (code_lines[cl].lines != NULL) + { + if (fp == code_file) + { + outline += (int)code_lines[cl].num; + outline += 3; + fprintf(fp, "\n"); + } + fprintf(fp, "/* %%code \"%s\" block start */\n", code_lines[cl].name); + fputs(code_lines[cl].lines, fp); + fprintf(fp, "/* %%code \"%s\" block end */\n", code_lines[cl].name); + if (fp == code_file) + { + write_code_lineno(fp); + } + } +} + static void output_newline(void) { @@ -1162,21 +1183,21 @@ is_C_identifier(char *name) if (c == '"') { c = *++s; - if (!isalpha(c) && c != '_' && c != '$') + if (!IS_NAME1(c)) return (0); while ((c = *++s) != '"') { - if (!isalnum(c) && c != '_' && c != '$') + if (!IS_NAME2(c)) return (0); } return (1); } - if (!isalpha(c) && c != '_' && c != '$') + if (!IS_NAME1(c)) return (0); while ((c = *++s) != 0) { - if (!isalnum(c) && c != '_' && c != '$') + if (!IS_NAME2(c)) return (0); } return (1); @@ -1206,6 +1227,11 @@ output_defines(FILE * fp) int c, i; char *s; + if (fp == defines_file) + { + output_code_lines(fp, CODE_REQUIRES); + } + for (i = 2; i < ntokens; ++i) { s = symbol_name[i]; @@ -1239,6 +1265,11 @@ output_defines(FILE * fp) if (fp != defines_file || iflag) fprintf(fp, "#define YYERRCODE %d\n", symbol_value[1]); + if (fp == defines_file) + { + output_code_lines(fp, CODE_PROVIDES); + } + if (token_table && rflag && fp != externs_file) { if (fp == code_file) @@ -1259,11 +1290,15 @@ output_defines(FILE * fp) while ((c = getc(union_file)) != EOF) putc_code(fp, c); } - fprintf(fp, "extern YYSTYPE %slval;\n", symbol_prefix); + if (!pure_parser) + fprintf(fp, "extern YYSTYPE %slval;\n", symbol_prefix); } #if defined(YYBTYACC) if (locations) + { output_ltype(fp); + fprintf(fp, "extern YYLTYPE %slloc;\n", symbol_prefix); + } #endif } } @@ -1274,9 +1309,9 @@ output_stored_text(FILE * fp) int c; FILE *in; - rewind(text_file); if (text_file == NULL) open_error("text_file"); + rewind(text_file); in = text_file; if ((c = getc(in)) == EOF) return; @@ -1288,6 +1323,15 @@ output_stored_text(FILE * fp) write_code_lineno(fp); } +static int +output_yydebug(FILE * fp) +{ + fprintf(fp, "#ifndef YYDEBUG\n"); + fprintf(fp, "#define YYDEBUG %d\n", tflag); + fprintf(fp, "#endif\n"); + return 3; +} + static void output_debug(void) { @@ -1298,16 +1342,11 @@ output_debug(void) ++outline; fprintf(code_file, "#define YYFINAL %d\n", final_state); - putl_code(code_file, "#ifndef YYDEBUG\n"); - ++outline; - fprintf(code_file, "#define YYDEBUG %d\n", tflag); - putl_code(code_file, "#endif\n"); + outline += output_yydebug(code_file); if (rflag) { - fprintf(output_file, "#ifndef YYDEBUG\n"); - fprintf(output_file, "#define YYDEBUG %d\n", tflag); - fprintf(output_file, "#endif\n"); + output_yydebug(output_file); } maxtok = 0; @@ -1793,6 +1832,23 @@ output_lex_decl(FILE * fp) putl_code(fp, "# define YYLEX yylex()\n"); } putl_code(fp, "#endif\n"); + + /* + * Provide a prototype for yylex for the simplest case. This is done for + * better compatibility with older yacc's, but can be a problem if someone + * uses "static int yylex(void);" + */ + if (!pure_parser +#if defined(YYBTYACC) + && !backtrack +#endif + && !strcmp(symbol_prefix, "yy")) + { + putl_code(fp, "\n"); + putl_code(fp, "#if !(defined(yylex) || defined(YYSTATE))\n"); + putl_code(fp, "int YYLEX_DECL();\n"); + putl_code(fp, "#endif\n"); + } } static void @@ -1980,6 +2036,7 @@ output(void) free_shifts(); free_reductions(); + output_code_lines(code_file, CODE_TOP); #if defined(YYBTYACC) output_backtracking_parser(output_file); if (rflag) @@ -2021,13 +2078,11 @@ output(void) if (iflag) { + fprintf(externs_file, "\n"); + output_yydebug(externs_file); output_externs(externs_file, global_vars); if (!pure_parser) output_externs(externs_file, impure_vars); - } - - if (iflag) - { if (dflag) { ++outline; @@ -2057,22 +2112,30 @@ output(void) output_actions(); free_parser(); output_debug(); + if (rflag) { write_section(code_file, xdecls); output_YYINT_typedef(code_file); write_section(code_file, tables); } + write_section(code_file, global_vars); if (!pure_parser) { write_section(code_file, impure_vars); } + output_code_lines(code_file, CODE_REQUIRES); + write_section(code_file, hdr_defs); if (!pure_parser) { write_section(code_file, hdr_vars); } + + output_code_lines(code_file, CODE_PROVIDES); + output_code_lines(code_file, CODE_HEADER); + output_trailing_text(); #if defined(YYBTYACC) if (destructor) diff --git a/contrib/byacc/package/byacc.spec b/contrib/byacc/package/byacc.spec index e8355d81487a..64fea872c68b 100644 --- a/contrib/byacc/package/byacc.spec +++ b/contrib/byacc/package/byacc.spec @@ -1,8 +1,9 @@ Summary: byacc - public domain Berkeley LALR Yacc parser generator %define AppProgram byacc -%define AppVersion 20170430 +%define AltProgram btyacc +%define AppVersion 20200330 %define UseProgram yacc -# $XTermId: byacc.spec,v 1.34 2017/04/30 20:55:15 tom Exp $ +# $Id: byacc.spec,v 1.49 2020/03/30 23:31:42 tom Exp $ Name: %{AppProgram} Version: %{AppVersion} Release: 1 @@ -10,7 +11,7 @@ License: Public Domain, MIT Group: Applications/Development URL: ftp://invisible-island.net/%{AppProgram} Source0: %{AppProgram}-%{AppVersion}.tgz -Packager: Thomas Dickey +Packager: Thomas E. Dickey %description This package provides a parser generator utility that reads a grammar @@ -19,30 +20,69 @@ 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 btyacc +Summary: Curses library with POSIX thread support. + +%description -n btyacc +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 +%define debug_package %{nil} + %setup -q -n %{AppProgram}-%{AppVersion} %build +%define my_srcdir .. +%define CFG_OPTS \\\ + --verbose \\\ + --disable-echo \\\ + --target %{_target_platform} \\\ + --prefix=%{_prefix} \\\ + --srcdir=%{my_srcdir} \\\ + --bindir=%{_bindir} \\\ + --libdir=%{_libdir} \\\ + --mandir=%{_mandir} -INSTALL_PROGRAM='${INSTALL}' \ - ./configure \ - --program-prefix=b \ - --target %{_target_platform} \ - --prefix=%{_prefix} \ - --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 \ + --program-transform-name='s,\^,b,' make +popd + +mkdir BUILD-btyacc +pushd BUILD-btyacc +CONFIGURE_TOP=%{my_srcdir} \ +%configure %{CFG_OPTS} \ + --enable-btyacc \ + --program-prefix=bt \ + --with-max-table-size=18000 \ + --program-transform-name='s,\^,bt,' +make +popd %install [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT -( cd $RPM_BUILD_ROOT%{_bindir} && ln -s %{AppProgram} %{UseProgram} ) +pushd BUILD-byacc +make install DESTDIR=$RPM_BUILD_ROOT +( cd $RPM_BUILD_ROOT%{_bindir} && ln -vs %{AppProgram} %{UseProgram} ) +popd -strip $RPM_BUILD_ROOT%{_bindir}/%{AppProgram} +pushd BUILD-btyacc +make install DESTDIR=$RPM_BUILD_ROOT +popd %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT @@ -53,8 +93,19 @@ strip $RPM_BUILD_ROOT%{_bindir}/%{AppProgram} %{_prefix}/bin/%{UseProgram} %{_mandir}/man1/%{AppProgram}.* +%files -n btyacc +%defattr(-,root,root) +%{_prefix}/bin/%{AltProgram} +%{_mandir}/man1/%{AltProgram}.* + %changelog # each patch should add its ChangeLog entries here +* Fri May 25 2018 Thomas Dickey +- add btyacc package + +* Sun Jul 09 2017 Thomas Dickey +- use predefined "configure" + * Sun Jun 06 2010 Thomas Dickey - initial version diff --git a/contrib/byacc/package/debian/changelog b/contrib/byacc/package/debian/changelog index 6ee5c0e90dd7..6342bcfe79f5 100644 --- a/contrib/byacc/package/debian/changelog +++ b/contrib/byacc/package/debian/changelog @@ -1,3 +1,75 @@ +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 diff --git a/contrib/byacc/package/debian/control b/contrib/byacc/package/debian/control index 720aadab6fe9..fccd90738fa4 100644 --- a/contrib/byacc/package/debian/control +++ b/contrib/byacc/package/debian/control @@ -1,7 +1,7 @@ Source: byacc -Maintainer: Dave Beckett +Maintainer: Thomas E. Dickey Section: devel -Priority: extra +Priority: optional Standards-Version: 3.8.4 Build-Depends: debhelper (>= 5) Homepage: http://invisible-island.net/byacc/ @@ -15,3 +15,15 @@ Description: public domain Berkeley LALR Yacc parser generator 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: btyacc +Architecture: any +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. diff --git a/contrib/byacc/package/debian/copyright b/contrib/byacc/package/debian/copyright index 91cbe855ef88..d2e49e9efdec 100644 --- a/contrib/byacc/package/debian/copyright +++ b/contrib/byacc/package/debian/copyright @@ -36,7 +36,7 @@ skeleton.c with the bug report. Do not expect rapid responses. Files: aclocal.m4 Licence: other-BSD -Copyright: 2004-2016,2017 by Thomas E. Dickey +Copyright: 2004-2019,2020 by Thomas E. Dickey 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 diff --git a/contrib/byacc/package/debian/rules b/contrib/byacc/package/debian/rules index f9424ac909fa..3db7e86c6135 100755 --- a/contrib/byacc/package/debian/rules +++ b/contrib/byacc/package/debian/rules @@ -1,8 +1,6 @@ #!/usr/bin/make -f -# MAde with the aid of dh_make, by Craig Small -# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. -# Some lines taken from debmake, by Cristoph Lameter. - +# $Id: rules,v 1.3 2018/05/25 20:03:37 tom Exp $ +# # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 @@ -11,7 +9,11 @@ DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) -CFLAGS = +PACKAGES.arch = byacc btyacc + +CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS) +CFLAGS := $(shell dpkg-buildflags --get CFLAGS) +LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 @@ -22,12 +24,19 @@ ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif +BYACC_DIR = $(CURDIR)/debian/byacc +BTYACC_DIR = $(CURDIR)/debian/btyacc -configure: configure-stamp -configure-stamp: - dh_testdir +BYACC_TMP = t/byacc +BTYACC_TMP = t/btyacc - CFLAGS="$(CFLAGS)" ./configure \ +verbose = # -v + +configure = \ + CPPFLAGS="$(CPPFLAGS)" \ + CFLAGS="$(CFLAGS)" \ + LDFLAGS="$(LDFLAGS)" \ + ../../configure \ --host=$(DEB_HOST_GNU_TYPE) \ --build=$(DEB_BUILD_GNU_TYPE) \ --prefix=/usr \ @@ -35,59 +44,96 @@ configure-stamp: --sysconfdir=/etc \ --program-transform-name='s,^,b,' - touch configure-stamp +all: build -build: build-stamp -build-stamp: configure-stamp +config: config-arch +build: build-arch +install: install-arch +binary: binary-arch + +config-arch: $(PACKAGES.arch:%=config-%-stamp) +build-arch: $(PACKAGES.arch:%=build-%-stamp) +install-arch: $(PACKAGES.arch:%=install-%-stamp) + +config-byacc-stamp: dh_testdir - $(MAKE) + rm -rf $(BYACC_TMP) + mkdir -p $(BYACC_TMP) + cd $(BYACC_TMP); $(configure) - touch build-stamp + touch $@ + +config-btyacc-stamp: + dh_testdir + + rm -rf $(BTYACC_TMP) + mkdir -p $(BTYACC_TMP) + cd $(BTYACC_TMP); $(configure) \ + --enable-btyacc \ + --with-max-table-size=18000 \ + --program-transform-name='s,^,bt,' + + touch $@ + +build-byacc-stamp: config-byacc-stamp + dh_testdir + + cd $(BYACC_TMP); $(MAKE) + + touch $@ + +build-btyacc-stamp: config-btyacc-stamp + dh_testdir + + cd $(BTYACC_TMP); $(MAKE) + + touch $@ + +install-byacc-stamp: build-byacc-stamp + dh_testdir + dh_testroot + dh_installdirs + + cd $(BYACC_TMP); $(MAKE) install DESTDIR=$(BYACC_DIR) + + touch $@ + +install-btyacc-stamp: build-btyacc-stamp + dh_testdir + dh_testroot + dh_installdirs + + cd $(BTYACC_TMP); $(MAKE) install DESTDIR=$(BTYACC_DIR) + + touch $@ clean: dh_testdir dh_testroot - [ ! -f Makefile ] || $(MAKE) clean + dh_clean $(verbose) - rm -f configure-stamp build-stamp install-stamp \ - config.cache config.h config.status config.log makefile - - rm -f *.o yacc - - dh_clean - -install: install-stamp -install-stamp: build-stamp - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - $(MAKE) install DESTDIR=$(CURDIR)/debian/byacc - - touch install-stamp - -# Build architecture-independent files here. -binary-indep: build install -# No binary-indep target. + rm -rf t # Build architecture-dependent files here. binary-arch: build install +ifneq ($(PACKAGES.arch),) + rm -f $(PACKAGES.arch:%=install-%-stamp) dh_testdir dh_testroot - dh_installdocs - dh_installexamples - dh_installchangelogs CHANGES - dh_strip - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb + dh_lintian $(verbose) $(PACKAGES.arch:%=-p%) + dh_installdocs $(verbose) $(PACKAGES.arch:%=-p%) + dh_installexamples $(verbose) $(PACKAGES.arch:%=-p%) + dh_installchangelogs $(verbose) $(PACKAGES.arch:%=-p%) CHANGES + dh_strip $(verbose) $(PACKAGES.arch:%=-p%) + dh_compress $(verbose) $(PACKAGES.arch:%=-p%) + dh_fixperms $(verbose) $(PACKAGES.arch:%=-p%) + dh_installdeb $(verbose) $(PACKAGES.arch:%=-p%) + dh_shlibdeps $(verbose) $(PACKAGES.arch:%=-p%) + dh_gencontrol $(verbose) $(PACKAGES.arch:%=-p%) + dh_md5sums $(verbose) $(PACKAGES.arch:%=-p%) + dh_builddeb $(verbose) $(PACKAGES.arch:%=-p%) +endif -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install install-stamp +.PHONY: build clean config config-arch binary binary-arch install install-arch diff --git a/contrib/byacc/package/debian/watch b/contrib/byacc/package/debian/watch index de083b06a198..2cc2e1536cee 100644 --- a/contrib/byacc/package/debian/watch +++ b/contrib/byacc/package/debian/watch @@ -1,4 +1,4 @@ version=3 -opts=passive ftp://invisible-island.net/byacc/byacc-(\d+)\.tgz \ +opts=passive ftp://ftp.invisible-island.net/byacc/byacc-(\d+)\.tgz \ debian uupdate diff --git a/contrib/byacc/package/mingw-byacc.spec b/contrib/byacc/package/mingw-byacc.spec index 2c6de287d054..ad107d5e488e 100644 --- a/contrib/byacc/package/mingw-byacc.spec +++ b/contrib/byacc/package/mingw-byacc.spec @@ -1,8 +1,8 @@ Summary: byacc - public domain Berkeley LALR Yacc parser generator %define AppProgram byacc -%define AppVersion 20170430 +%define AppVersion 20200330 %define UseProgram yacc -# $XTermId: mingw-byacc.spec,v 1.16 2017/04/30 20:55:15 tom Exp $ +# $Id: mingw-byacc.spec,v 1.29 2020/03/30 23:31:42 tom Exp $ Name: %{AppProgram} Version: %{AppVersion} Release: 1 @@ -21,12 +21,12 @@ license which includes the generated C. %prep +%define debug_package %{nil} + %setup -q -n %{AppProgram}-%{AppVersion} %build - -INSTALL_PROGRAM='${INSTALL}' \ - ./configure \ +%configure --verbose \ --program-prefix=b \ --target %{_target_platform} \ --prefix=%{_prefix} \ @@ -56,5 +56,8 @@ strip $RPM_BUILD_ROOT%{_bindir}/%{AppProgram} %changelog # each patch should add its ChangeLog entries here +* Sun Jul 09 2017 Thomas Dickey +- use predefined "configure" + * Wed Sep 25 2013 Thomas Dickey - cloned from byacc.spec diff --git a/contrib/byacc/package/pkgsrc/Makefile b/contrib/byacc/package/pkgsrc/Makefile index 2a47c9ce00a2..90936e691398 100644 --- a/contrib/byacc/package/pkgsrc/Makefile +++ b/contrib/byacc/package/pkgsrc/Makefile @@ -1,10 +1,10 @@ # $NetBSD: Makefile,v 1.9 2008/07/24 17:13:00 tonnerre Exp $ # -DISTNAME= byacc-20170430 +DISTNAME= byacc-20200330 PKGREVISION= 1 CATEGORIES= devel -MASTER_SITES= ftp://invisible-island.net/byacc/ +MASTER_SITES= ftp://ftp.invisible-island.net/byacc/ EXTRACT_SUFX= .tgz MAINTAINER= pkgsrc-users@NetBSD.org diff --git a/contrib/byacc/reader.c b/contrib/byacc/reader.c index efcbaa53bdfb..3bbf9a79c187 100644 --- a/contrib/byacc/reader.c +++ b/contrib/byacc/reader.c @@ -1,11 +1,11 @@ -/* $Id: reader.c,v 1.68 2017/02/02 01:05:36 tom Exp $ */ +/* $Id: reader.c,v 1.79 2020/03/30 23:54:13 tom Exp $ */ #include "defs.h" /* The line size must be a positive integer. One hundred was chosen */ /* because few lines in Yacc input grammars exceed 100 characters. */ /* Note that if a line exceeds LINESIZE characters, the line buffer */ -/* will be expanded to accomodate it. */ +/* will be expanded to accommodate it. */ #define LINESIZE 100 @@ -62,6 +62,13 @@ char line_format[] = "#line %d \"%s\"\n"; param *lex_param; param *parse_param; +static const char *code_keys[] = +{ + "", "requires", "provides", "top", "imports", +}; + +struct code_lines code_lines[CODE_MAX]; + #if defined(YYBTYACC) int destructor = 0; /* =1 if at least one %destructor */ @@ -144,7 +151,7 @@ line_directive(void) switch (ld) { case ldSPC1: - if (isspace(ch)) + if (isspace(UCH(ch))) { break; } @@ -153,7 +160,7 @@ line_directive(void) ld = ldSPC2; break; case ldSPC2: - if (isspace(ch)) + if (isspace(UCH(ch))) { break; } @@ -171,26 +178,26 @@ line_directive(void) ld = ldSPC3; break; case ldSPC3: - if (isspace(ch)) + if (isspace(UCH(ch))) { break; } else - UNLESS(!isdigit(ch)); + UNLESS(!isdigit(UCH(ch))); line_1st = n; ld = ldNUM; /* FALLTHRU */ case ldNUM: - if (isdigit(ch)) + if (isdigit(UCH(ch))) { break; } else - UNLESS(!isspace(ch)); + UNLESS(!isspace(UCH(ch))); ld = ldSPC4; break; case ldSPC4: - if (isspace(ch)) + if (isspace(UCH(ch))) { break; } @@ -217,19 +224,33 @@ line_directive(void) if (ld == ldOK) { size_t need = (size_t) (name_end - name_1st); - if (need > input_file_name_len) + if ((long)need > (long)input_file_name_len) { - input_file_name_len = need; - input_file_name = TREALLOC(char, input_file_name, need + 1); + input_file_name_len = ((need + 1) * 3) / 2; + input_file_name = TREALLOC(char, input_file_name, input_file_name_len); NO_SPACE(input_file_name); } - memcpy(input_file_name, line + name_1st + 1, need - 1); - input_file_name[need - 1] = '\0'; + if ((long)need > 0) + { + memcpy(input_file_name, line + name_1st + 1, need - 1); + input_file_name[need - 1] = '\0'; + } + else + { + input_file_name[0] = '\0'; + } } if (ld >= ldNUM && ld < ldERR) { - lineno = (int)strtol(line + line_1st, NULL, 10) - 1; + if (line_1st >= 0) + { + lineno = (int)strtol(line + line_1st, NULL, 10) - 1; + } + else + { + lineno = 0; + } } return (ld == ldOK); @@ -423,11 +444,12 @@ nextc(void) /* *INDENT-OFF* */ static struct keyword { - char name[14]; + char name[16]; int token; } keywords[] = { { "binary", NONASSOC }, + { "code", XCODE }, { "debug", XXXDEBUG }, #if defined(YYBTYACC) { "destructor", DESTRUCTOR }, @@ -435,7 +457,7 @@ keywords[] = { { "error-verbose",ERROR_VERBOSE }, { "expect", EXPECT }, { "expect-rr", EXPECT_RR }, - { "ident", IDENT }, + { "ident", IDENT }, #if defined(YYBTYACC) { "initial-action", INITIAL_ACTION }, #endif @@ -447,11 +469,11 @@ keywords[] = { { "nonassoc", NONASSOC }, { "parse-param", PARSE_PARAM }, { "pure-parser", PURE_PARSER }, - { "right", RIGHT }, + { "right", RIGHT }, { "start", START }, { "term", TOKEN }, { "token", TOKEN }, - { "token-table", TOKEN_TABLE }, + { "token-table", TOKEN_TABLE }, { "type", TYPE }, { "union", UNION }, { "yacc", POSIX_YACC }, @@ -474,18 +496,18 @@ keyword(void) struct keyword *key; c = *++cptr; - if (isalpha(c)) + if (isalpha(UCH(c))) { cinc = 0; for (;;) { - if (isalpha(c)) + if (isalpha(UCH(c))) { - if (isupper(c)) + if (isupper(UCH(c))) c = tolower(c); cachec(c); } - else if (isdigit(c) + else if (isdigit(UCH(c)) || c == '-' || c == '.' || c == '$') @@ -646,6 +668,127 @@ copy_comment(void) return msdone(temp); } +static int +check_key(int pos) +{ + const char *key = code_keys[pos]; + while (*cptr && *key) + if (*key++ != *cptr++) + return 0; + if (*key || (!isspace(UCH(*cptr)) && *cptr != L_CURL)) + return 0; + cptr--; + return 1; +} + +static void +copy_code(void) +{ + int c; + int curl; + int cline; + int on_line = 0; + int pos = CODE_HEADER; + struct mstring *code_mstr; + + /* read %code { */ + for (;;) + { + c = *++cptr; + if (c == EOF) + unexpected_EOF(); + if (isspace(UCH(c))) + continue; + + if (c == L_CURL) + break; + + if (pos == CODE_HEADER) + { + switch (UCH(c)) + { + case 'r': + pos = CODE_REQUIRES; + break; + case 'p': + pos = CODE_PROVIDES; + break; + case 't': + pos = CODE_TOP; + break; + case 'i': + pos = CODE_IMPORTS; + break; + default: + break; + } + + if (pos == -1 || !check_key(pos)) + { + syntax_error(lineno, line, cptr); + return; + } + } + } + + cptr++; /* skip initial curl */ + while (*cptr && isspace(UCH(*cptr))) /* skip space */ + cptr++; + curl = 1; /* nesting count */ + + /* gather text */ + code_lines[pos].name = code_keys[pos]; + if ((cline = (int)code_lines[pos].num) != 0) + { + code_mstr = msrenew(code_lines[pos].lines); + } + else + { + code_mstr = msnew(); + } + cline++; + msprintf(code_mstr, line_format, lineno, input_file_name); + for (;;) + { + c = *cptr++; + switch (c) + { + case '\0': + get_line(); + if (line == NULL) + { + unexpected_EOF(); + return; + } + continue; + case '\n': + cline++; + on_line = 0; + break; + case L_CURL: + curl++; + break; + case R_CURL: + if (--curl == 0) + { + if (on_line > 1) + { + mputc(code_mstr, '\n'); + cline++; + } + code_lines[pos].lines = msdone(code_mstr); + code_lines[pos].num = (size_t) cline; + return; + } + break; + default: + break; + } + mputc(code_mstr, c); + on_line++; + } +} + static void copy_text(void) { @@ -1235,7 +1378,7 @@ get_literal(void) cachec('\\'); cachec(c); } - else if (isprint(c)) + else if (isprint(UCH(c))) cachec(c); else { @@ -1329,13 +1472,21 @@ static Value_t get_number(void) { int c; - Value_t n; + long n; + char *base = cptr; n = 0; - for (c = *cptr; isdigit(c); c = *++cptr) - n = (Value_t)(10 * n + (c - '0')); + for (c = *cptr; isdigit(UCH(c)); c = *++cptr) + { + n = (10 * n + (c - '0')); + if (n > MAXYYINT) + { + syntax_error(lineno, line, base); + /*NOTREACHED */ + } + } - return (n); + return (Value_t)(n); } static char * @@ -1382,7 +1533,7 @@ get_tag(void) c = nextc(); if (c == EOF) unexpected_EOF(); - if (!isalpha(c) && c != '_' && c != '$') + if (!IS_NAME1(c)) illegal_tag(t_lineno, t_line, t_cptr); cinc = 0; @@ -1412,7 +1563,7 @@ scan_id(void) { char *b = cptr; - while (isalnum(UCH(*cptr)) || *cptr == '_' || *cptr == '$') + while (IS_NAME2(UCH(*cptr))) cptr++; return cache_tag(b, (size_t) (cptr - b)); } @@ -1442,7 +1593,7 @@ declare_tokens(int assoc) for (;;) { - if (isalpha(c) || c == '_' || c == '.' || c == '$') + if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$') bp = get_name(); else if (c == '\'' || c == '"') bp = get_literal(); @@ -1472,8 +1623,7 @@ declare_tokens(int assoc) if (c == EOF) unexpected_EOF(); - value = UNDEFINED; - if (isdigit(c)) + if (isdigit(UCH(c))) { value = get_number(); if (bp->value != UNDEFINED && value != bp->value) @@ -1509,7 +1659,7 @@ declare_expect(int assoc) for (;;) { - if (isdigit(c)) + if (isdigit(UCH(c))) { if (assoc == EXPECT) SRexpect = get_number(); @@ -1522,7 +1672,7 @@ declare_expect(int assoc) * Spaces, tabs, and numbers are ok, * words, punc., etc. are syntax errors. */ - else if (c == '\n' || isalpha(c) || !isspace(c)) + else if (c == '\n' || isalpha(UCH(c)) || !isspace(UCH(c))) { syntax_error(lineno, line, cptr); } @@ -1591,7 +1741,7 @@ declare_types(void) c = nextc(); if (c == EOF) unexpected_EOF(); - if (isalpha(c) || c == '_' || c == '.' || c == '$') + if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$') { bp = get_name(); #if defined(YYBTYACC) @@ -1629,7 +1779,7 @@ declare_start(void) c = nextc(); if (c == EOF) unexpected_EOF(); - if (!isalpha(c) && c != '_' && c != '.' && c != '$') + if (!isalpha(UCH(c)) && c != '_' && c != '.' && c != '$') syntax_error(lineno, line, cptr); bp = get_name(); if (bp->class == TERM) @@ -1664,6 +1814,10 @@ read_declarations(void) copy_ident(); break; + case XCODE: + copy_code(); + break; + case TEXT: copy_text(); break; @@ -1871,7 +2025,7 @@ parse_id(char *p, char **save) if (!isalpha(UCH(*p)) && *p != '_') return NULL; b = p; - while (isalnum(UCH(*p)) || *p == '_' || *p == '$') + while (IS_NAME2(UCH(*p))) p++; if (save) { @@ -2129,7 +2283,10 @@ can_elide_arg(char **theptr, char *yyvaltag) { char *arg; if (!(p = parse_id(p, &arg))) + { + FREE(offsets); return 0; + } for (i = plhs[nrules]->args - 1; i >= 0; i--) if (arg == plhs[nrules]->argnames[i]) break; @@ -2149,7 +2306,7 @@ can_elide_arg(char **theptr, char *yyvaltag) rv = 0; if (maxoffset > 0) FREE(offsets); - if (*p || rv <= 0) + if (p == 0 || *p || rv <= 0) return 0; *theptr = p + 1; return rv; @@ -2228,6 +2385,10 @@ advance_to_start(void) s_cptr = cptr; switch (keyword()) { + case XCODE: + copy_code(); + break; + case MARK: no_grammar(); @@ -2245,7 +2406,7 @@ advance_to_start(void) } c = nextc(); - if (!isalpha(c) && c != '_' && c != '.' && c != '_') + if (!isalpha(UCH(c)) && c != '_' && c != '.' && c != '_') syntax_error(lineno, line, cptr); bp = get_name(); if (goal == 0) @@ -2572,7 +2733,7 @@ copy_action(void) FREE(d_line); goto loop; } - else if (isdigit(c)) + else if (isdigit(UCH(c))) { i = get_number(); if (i == 0) @@ -2596,7 +2757,7 @@ copy_action(void) goto loop; } #if defined(YYBTYACC) - else if (isalpha(c) || c == '_') + else if (isalpha(UCH(c)) || c == '_') { char *arg = scan_id(); for (i = plhs[nrules]->args - 1; i >= 0; i--) @@ -2727,14 +2888,14 @@ copy_action(void) } } #endif - if (isalpha(c) || c == '_' || c == '$') + if (IS_NAME1(c)) { do { putc(c, f); c = *++cptr; } - while (isalnum(c) || c == '_' || c == '$'); + while (IS_NAME2(c)); goto loop; } ++cptr; @@ -2923,14 +3084,14 @@ get_code(struct ainfo *a, const char *loc) cptr += 2; goto loop; } - if (isalpha(c) || c == '_' || c == '$') + if (IS_NAME1(c)) { do { mputc(code_mstr, c); c = *++cptr; } - while (isalnum(c) || c == '_' || c == '$'); + while (IS_NAME2(c)); goto loop; } ++cptr; @@ -3049,7 +3210,7 @@ copy_destructor(void) bp->destructor = process_destructor_XX(code_text, tag); } } - else if (isalpha(c) || c == '_' || c == '.' || c == '$') + else if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$') { /* "symbol" destructor */ bp = get_name(); if (bp->destructor != NULL) @@ -3090,14 +3251,14 @@ process_destructor_XX(char *code, char *tag) msprintf(new_code, "(*val).%s", tag); goto loop; } - if (isalpha(c) || c == '_' || c == '$') + if (IS_NAME1(c)) { do { mputc(new_code, c); c = *++codeptr; } - while (isalnum(c) || c == '_' || c == '$'); + while (IS_NAME2(c)); goto loop; } ++codeptr; @@ -3180,7 +3341,7 @@ mark_symbol(void) syntax_error(lineno, line, cptr); c = nextc(); - if (isalpha(c) || c == '_' || c == '.' || c == '$') + if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$') bp = get_name(); else if (c == '\'' || c == '"') bp = get_literal(); @@ -3211,7 +3372,7 @@ read_grammar(void) c = nextc(); if (c == EOF) break; - if (isalpha(c) + if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$' diff --git a/contrib/byacc/test/btyacc/big_b.error b/contrib/byacc/test/btyacc/big_b.error index e69de29bb2d1..67101620d2c1 100644 --- a/contrib/byacc/test/btyacc/big_b.error +++ b/contrib/byacc/test/btyacc/big_b.error @@ -0,0 +1,19 @@ +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/btyacc/big_b.output b/contrib/byacc/test/btyacc/big_b.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/big_b.output +++ b/contrib/byacc/test/btyacc/big_b.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/btyacc/big_l.error b/contrib/byacc/test/btyacc/big_l.error index e69de29bb2d1..67101620d2c1 100644 --- a/contrib/byacc/test/btyacc/big_l.error +++ b/contrib/byacc/test/btyacc/big_l.error @@ -0,0 +1,19 @@ +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/btyacc/big_l.output b/contrib/byacc/test/btyacc/big_l.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/big_l.output +++ b/contrib/byacc/test/btyacc/big_l.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/btyacc/btyacc_calc1.tab.c b/contrib/byacc/test/btyacc/btyacc_calc1.tab.c index 6142a131ca37..a1368f2c72f5 100644 --- a/contrib/byacc/test/btyacc/btyacc_calc1.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_calc1.tab.c @@ -196,7 +196,7 @@ extern int YYPARSE_DECL(); #define CONST 259 #define UMINUS 260 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -389,8 +389,9 @@ static const char *const calc1_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT @@ -399,17 +400,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -615,7 +616,7 @@ vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } -#line 619 "btyacc_calc1.tab.c" +#line 620 "btyacc_calc1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -752,6 +753,8 @@ YYPARSE_DECL() int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -804,7 +807,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -880,10 +883,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -994,7 +997,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1204,7 +1207,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1233,7 +1236,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1249,7 +1252,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1335,10 +1338,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1537,7 +1540,7 @@ case 28: yyval.vval = yystack.l_mark[-1].vval; } break; -#line 1541 "btyacc_calc1.tab.c" +#line 1544 "btyacc_calc1.tab.c" default: break; } @@ -1592,12 +1595,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/btyacc_calc1.tab.h b/contrib/byacc/test/btyacc/btyacc_calc1.tab.h index 1802350b0d2a..9cf4e75ba38a 100644 --- a/contrib/byacc/test/btyacc/btyacc_calc1.tab.h +++ b/contrib/byacc/test/btyacc/btyacc_calc1.tab.h @@ -18,6 +18,5 @@ typedef union INTERVAL vval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE calc1_lval; #endif /* _calc1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/btyacc_demo.tab.c b/contrib/byacc/test/btyacc/btyacc_demo.tab.c index eff738cfd5b2..3493ee7555db 100644 --- a/contrib/byacc/test/btyacc/btyacc_demo.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_demo.tab.c @@ -231,7 +231,7 @@ extern int YYPARSE_DECL(); #define ELSE 268 #define CLCL 269 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -508,13 +508,16 @@ static const char *const demo_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -527,17 +530,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -660,7 +663,7 @@ extern Expr * var_expr(Scope *scope, char *id); extern Code * build_expr_code(Expr *expr); extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt); extern Code * code_append(Code *stmt_list, Code *stmt); -#line 664 "btyacc_demo.tab.c" +#line 667 "btyacc_demo.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -677,7 +680,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 681 "btyacc_demo.tab.c" +#line 684 "btyacc_demo.tab.c" case 45: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -686,7 +689,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 690 "btyacc_demo.tab.c" +#line 693 "btyacc_demo.tab.c" case 42: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -695,7 +698,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 699 "btyacc_demo.tab.c" +#line 702 "btyacc_demo.tab.c" case 47: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -704,7 +707,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 708 "btyacc_demo.tab.c" +#line 711 "btyacc_demo.tab.c" case 37: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -713,7 +716,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 717 "btyacc_demo.tab.c" +#line 720 "btyacc_demo.tab.c" case 257: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -722,7 +725,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 726 "btyacc_demo.tab.c" +#line 729 "btyacc_demo.tab.c" case 258: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -731,7 +734,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 735 "btyacc_demo.tab.c" +#line 738 "btyacc_demo.tab.c" case 40: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -740,7 +743,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 744 "btyacc_demo.tab.c" +#line 747 "btyacc_demo.tab.c" case 91: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -749,7 +752,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 753 "btyacc_demo.tab.c" +#line 756 "btyacc_demo.tab.c" case 46: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -758,7 +761,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 762 "btyacc_demo.tab.c" +#line 765 "btyacc_demo.tab.c" case 259: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -767,7 +770,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).id); } break; -#line 771 "btyacc_demo.tab.c" +#line 774 "btyacc_demo.tab.c" case 260: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -776,7 +779,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).expr); } break; -#line 780 "btyacc_demo.tab.c" +#line 783 "btyacc_demo.tab.c" case 261: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -785,7 +788,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 789 "btyacc_demo.tab.c" +#line 792 "btyacc_demo.tab.c" case 262: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -794,7 +797,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 798 "btyacc_demo.tab.c" +#line 801 "btyacc_demo.tab.c" case 263: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -803,7 +806,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 807 "btyacc_demo.tab.c" +#line 810 "btyacc_demo.tab.c" case 264: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -812,7 +815,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 816 "btyacc_demo.tab.c" +#line 819 "btyacc_demo.tab.c" case 265: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -821,7 +824,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 825 "btyacc_demo.tab.c" +#line 828 "btyacc_demo.tab.c" case 266: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -830,7 +833,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 834 "btyacc_demo.tab.c" +#line 837 "btyacc_demo.tab.c" case 267: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -839,7 +842,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 843 "btyacc_demo.tab.c" +#line 846 "btyacc_demo.tab.c" case 268: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -848,7 +851,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 852 "btyacc_demo.tab.c" +#line 855 "btyacc_demo.tab.c" case 269: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -857,7 +860,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 861 "btyacc_demo.tab.c" +#line 864 "btyacc_demo.tab.c" case 59: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -866,7 +869,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 870 "btyacc_demo.tab.c" +#line 873 "btyacc_demo.tab.c" case 44: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -875,7 +878,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 879 "btyacc_demo.tab.c" +#line 882 "btyacc_demo.tab.c" case 41: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -884,7 +887,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 888 "btyacc_demo.tab.c" +#line 891 "btyacc_demo.tab.c" case 93: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -893,7 +896,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 897 "btyacc_demo.tab.c" +#line 900 "btyacc_demo.tab.c" case 123: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -902,7 +905,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 906 "btyacc_demo.tab.c" +#line 909 "btyacc_demo.tab.c" case 125: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -911,7 +914,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 915 "btyacc_demo.tab.c" +#line 918 "btyacc_demo.tab.c" case 270: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -920,7 +923,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 924 "btyacc_demo.tab.c" +#line 927 "btyacc_demo.tab.c" case 271: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -929,7 +932,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 933 "btyacc_demo.tab.c" +#line 936 "btyacc_demo.tab.c" case 272: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -938,7 +941,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).expr); } break; -#line 942 "btyacc_demo.tab.c" +#line 945 "btyacc_demo.tab.c" case 273: #line 67 "btyacc_demo.y" { /* 'msg' is a 'char *' indicating the context of destructor invocation*/ @@ -948,7 +951,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).decl->scope); free((*val).decl->type); } break; -#line 952 "btyacc_demo.tab.c" +#line 955 "btyacc_demo.tab.c" case 274: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -957,7 +960,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 961 "btyacc_demo.tab.c" +#line 964 "btyacc_demo.tab.c" case 275: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -966,7 +969,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 970 "btyacc_demo.tab.c" +#line 973 "btyacc_demo.tab.c" case 276: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -975,7 +978,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).code); } break; -#line 979 "btyacc_demo.tab.c" +#line 982 "btyacc_demo.tab.c" case 277: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -984,7 +987,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).code); } break; -#line 988 "btyacc_demo.tab.c" +#line 991 "btyacc_demo.tab.c" case 278: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -993,7 +996,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).code); } break; -#line 997 "btyacc_demo.tab.c" +#line 1000 "btyacc_demo.tab.c" case 279: #line 73 "btyacc_demo.y" { printf("%s accessed by symbol with type (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", @@ -1002,7 +1005,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).decl); } break; -#line 1006 "btyacc_demo.tab.c" +#line 1009 "btyacc_demo.tab.c" case 280: #line 73 "btyacc_demo.y" { printf("%s accessed by symbol with type (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", @@ -1011,7 +1014,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).decl); } break; -#line 1015 "btyacc_demo.tab.c" +#line 1018 "btyacc_demo.tab.c" case 281: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1020,7 +1023,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1024 "btyacc_demo.tab.c" +#line 1027 "btyacc_demo.tab.c" case 282: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1029,7 +1032,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1033 "btyacc_demo.tab.c" +#line 1036 "btyacc_demo.tab.c" case 283: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1038,7 +1041,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1042 "btyacc_demo.tab.c" +#line 1045 "btyacc_demo.tab.c" case 284: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1047,7 +1050,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1051 "btyacc_demo.tab.c" +#line 1054 "btyacc_demo.tab.c" case 285: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1056,7 +1059,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1060 "btyacc_demo.tab.c" +#line 1063 "btyacc_demo.tab.c" case 286: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1065,7 +1068,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1069 "btyacc_demo.tab.c" +#line 1072 "btyacc_demo.tab.c" case 287: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1074,7 +1077,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).dlist); } break; -#line 1078 "btyacc_demo.tab.c" +#line 1081 "btyacc_demo.tab.c" case 288: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1083,7 +1086,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).dlist); } break; -#line 1087 "btyacc_demo.tab.c" +#line 1090 "btyacc_demo.tab.c" case 289: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1092,7 +1095,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1096 "btyacc_demo.tab.c" +#line 1099 "btyacc_demo.tab.c" case 290: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1101,7 +1104,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1105 "btyacc_demo.tab.c" +#line 1108 "btyacc_demo.tab.c" case 291: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1110,7 +1113,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1114 "btyacc_demo.tab.c" +#line 1117 "btyacc_demo.tab.c" case 292: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1119,7 +1122,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1123 "btyacc_demo.tab.c" +#line 1126 "btyacc_demo.tab.c" case 293: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1128,7 +1131,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1132 "btyacc_demo.tab.c" +#line 1135 "btyacc_demo.tab.c" case 294: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1137,7 +1140,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1141 "btyacc_demo.tab.c" +#line 1144 "btyacc_demo.tab.c" case 295: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1146,7 +1149,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1150 "btyacc_demo.tab.c" +#line 1153 "btyacc_demo.tab.c" case 296: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1155,7 +1158,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1159 "btyacc_demo.tab.c" +#line 1162 "btyacc_demo.tab.c" case 297: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1164,7 +1167,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1168 "btyacc_demo.tab.c" +#line 1171 "btyacc_demo.tab.c" case 298: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1173,7 +1176,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1177 "btyacc_demo.tab.c" +#line 1180 "btyacc_demo.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -1316,7 +1319,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -1383,10 +1386,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -1497,7 +1500,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1707,7 +1710,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1736,7 +1739,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1752,7 +1755,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1838,10 +1841,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -2106,7 +2109,7 @@ case 59: #line 197 "btyacc_demo.y" { yyval.code = yystack.l_mark[-1].code; } break; -#line 2110 "btyacc_demo.tab.c" +#line 2113 "btyacc_demo.tab.c" default: break; } @@ -2161,12 +2164,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/btyacc_demo.tab.h b/contrib/byacc/test/btyacc/btyacc_demo.tab.h index c219fb1fae97..5c2b96cf3310 100644 --- a/contrib/byacc/test/btyacc/btyacc_demo.tab.h +++ b/contrib/byacc/test/btyacc/btyacc_demo.tab.h @@ -46,5 +46,6 @@ typedef struct YYLTYPE #define YYLTYPE_IS_DECLARED 1 #endif #define YYRHSLOC(rhs, k) ((rhs)[k]) +extern YYLTYPE demo_lloc; #endif /* _demo__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/btyacc_demo2.error b/contrib/byacc/test/btyacc/btyacc_demo2.error deleted file mode 100644 index 554dd5acb0aa..000000000000 --- a/contrib/byacc/test/btyacc/btyacc_demo2.error +++ /dev/null @@ -1 +0,0 @@ -YACC: e - line 82 of "./btyacc_demo2.y", $$ is untyped diff --git a/contrib/byacc/test/btyacc/btyacc_demo2.tab.c b/contrib/byacc/test/btyacc/btyacc_demo2.tab.c deleted file mode 100644 index 6c35f23329b5..000000000000 --- a/contrib/byacc/test/btyacc/btyacc_demo2.tab.c +++ /dev/null @@ -1,15 +0,0 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ - -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define YYCHECK "yyyymmdd" - -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 diff --git a/contrib/byacc/test/btyacc/btyacc_destroy1.tab.c b/contrib/byacc/test/btyacc/btyacc_destroy1.tab.c index 74c32b10326c..2ddb0cdba988 100644 --- a/contrib/byacc/test/btyacc/btyacc_destroy1.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_destroy1.tab.c @@ -202,7 +202,7 @@ extern int YYPARSE_DECL(); #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT destroy1_lhs[] = { -1, 0, 0, 2, 2, 3, 3, 4, 4, 1, }; @@ -357,13 +357,16 @@ static const char *const destroy1_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -376,17 +379,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -485,7 +488,7 @@ static YYINT *yylexemes = 0; extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 489 "btyacc_destroy1.tab.c" +#line 492 "btyacc_destroy1.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -505,7 +508,7 @@ YYDESTRUCT_DECL() } } break; -#line 509 "btyacc_destroy1.tab.c" +#line 512 "btyacc_destroy1.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -648,7 +651,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -715,10 +718,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -829,7 +832,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1039,7 +1042,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1068,7 +1071,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1084,7 +1087,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1170,10 +1173,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1228,7 +1231,7 @@ case 9: #line 86 "btyacc_destroy1.y" { yyval.nlist = yystack.l_mark[-5].nlist; } break; -#line 1232 "btyacc_destroy1.tab.c" +#line 1235 "btyacc_destroy1.tab.c" default: break; } @@ -1283,12 +1286,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/btyacc_destroy2.tab.c b/contrib/byacc/test/btyacc/btyacc_destroy2.tab.c index 55705eecebc3..7833f8532907 100644 --- a/contrib/byacc/test/btyacc/btyacc_destroy2.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_destroy2.tab.c @@ -202,7 +202,7 @@ extern int YYPARSE_DECL(); #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT destroy2_lhs[] = { -1, 0, 0, 2, 2, 3, 3, 4, 4, 1, }; @@ -357,13 +357,16 @@ static const char *const destroy2_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -376,17 +379,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -485,7 +488,7 @@ static YYINT *yylexemes = 0; extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 489 "btyacc_destroy2.tab.c" +#line 492 "btyacc_destroy2.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -505,7 +508,7 @@ YYDESTRUCT_DECL() } } break; -#line 509 "btyacc_destroy2.tab.c" +#line 512 "btyacc_destroy2.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -648,7 +651,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -715,10 +718,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -829,7 +832,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1039,7 +1042,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1068,7 +1071,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1084,7 +1087,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1170,10 +1173,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1228,7 +1231,7 @@ case 9: #line 86 "btyacc_destroy2.y" { yyval.nlist = yystack.l_mark[-5].nlist; } break; -#line 1232 "btyacc_destroy2.tab.c" +#line 1235 "btyacc_destroy2.tab.c" default: break; } @@ -1283,12 +1286,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/btyacc_destroy3.tab.c b/contrib/byacc/test/btyacc/btyacc_destroy3.tab.c index c6b08b8be232..28a6c94a9c8b 100644 --- a/contrib/byacc/test/btyacc/btyacc_destroy3.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_destroy3.tab.c @@ -202,7 +202,7 @@ extern int YYPARSE_DECL(); #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT destroy3_lhs[] = { -1, 0, 0, 2, 2, 3, 3, 4, 4, 1, }; @@ -357,13 +357,16 @@ static const char *const destroy3_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -376,17 +379,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -485,7 +488,7 @@ static YYINT *yylexemes = 0; extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 489 "btyacc_destroy3.tab.c" +#line 492 "btyacc_destroy3.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -505,7 +508,7 @@ YYDESTRUCT_DECL() } } break; -#line 509 "btyacc_destroy3.tab.c" +#line 512 "btyacc_destroy3.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -648,7 +651,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -715,10 +718,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -829,7 +832,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1039,7 +1042,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1068,7 +1071,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1084,7 +1087,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1170,10 +1173,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1228,7 +1231,7 @@ case 9: #line 89 "btyacc_destroy3.y" { yyval.nlist = yystack.l_mark[-5].nlist; } break; -#line 1232 "btyacc_destroy3.tab.c" +#line 1235 "btyacc_destroy3.tab.c" default: break; } @@ -1283,12 +1286,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/calc.tab.c b/contrib/byacc/test/btyacc/calc.tab.c index 052c7ade4f17..e171ee9eb7ed 100644 --- a/contrib/byacc/test/btyacc/calc.tab.c +++ b/contrib/byacc/test/btyacc/calc.tab.c @@ -170,7 +170,7 @@ extern int YYPARSE_DECL(); #define LETTER 258 #define UMINUS 259 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -338,13 +338,16 @@ static const char *const calc_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -357,17 +360,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -504,7 +507,7 @@ yylex(void) } return( c ); } -#line 508 "calc.tab.c" +#line 511 "calc.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -643,7 +646,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -710,10 +713,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -824,7 +827,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1034,7 +1037,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1063,7 +1066,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1079,7 +1082,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1165,10 +1168,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1234,7 +1237,7 @@ case 18: #line 63 "calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1238 "calc.tab.c" +#line 1241 "calc.tab.c" default: break; } @@ -1289,12 +1292,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/calc1.tab.c b/contrib/byacc/test/btyacc/calc1.tab.c index 27731448cb88..298a0600121b 100644 --- a/contrib/byacc/test/btyacc/calc1.tab.c +++ b/contrib/byacc/test/btyacc/calc1.tab.c @@ -195,7 +195,7 @@ extern int YYPARSE_DECL(); #define CONST 259 #define UMINUS 260 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -393,13 +393,16 @@ static const char *const calc1_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -412,17 +415,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -648,7 +651,7 @@ vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } -#line 652 "calc1.tab.c" +#line 655 "calc1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -787,7 +790,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -854,10 +857,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -968,7 +971,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1178,7 +1181,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1207,7 +1210,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1223,7 +1226,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1309,10 +1312,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1481,7 +1484,7 @@ case 28: yyval.vval = yystack.l_mark[-1].vval; } break; -#line 1485 "calc1.tab.c" +#line 1488 "calc1.tab.c" default: break; } @@ -1536,12 +1539,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/calc2.tab.c b/contrib/byacc/test/btyacc/calc2.tab.c index 4b4550d577db..cb2a4d92196d 100644 --- a/contrib/byacc/test/btyacc/calc2.tab.c +++ b/contrib/byacc/test/btyacc/calc2.tab.c @@ -172,7 +172,7 @@ extern int YYPARSE_DECL(); #define LETTER 258 #define UMINUS 259 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -340,13 +340,16 @@ static const char *const calc2_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -359,17 +362,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -517,7 +520,7 @@ YYLEX_DECL() } return( c ); } -#line 521 "calc2.tab.c" +#line 524 "calc2.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -656,7 +659,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -723,10 +726,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -837,7 +840,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1047,7 +1050,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1076,7 +1079,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1092,7 +1095,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1178,10 +1181,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1247,7 +1250,7 @@ case 18: #line 70 "calc2.y" { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1251 "calc2.tab.c" +#line 1254 "calc2.tab.c" default: break; } @@ -1302,12 +1305,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/calc3.tab.c b/contrib/byacc/test/btyacc/calc3.tab.c index 199c245361a2..5dc48f1c4fb5 100644 --- a/contrib/byacc/test/btyacc/calc3.tab.c +++ b/contrib/byacc/test/btyacc/calc3.tab.c @@ -177,7 +177,7 @@ extern int YYPARSE_DECL(); #define LETTER 258 #define UMINUS 259 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -345,8 +345,9 @@ static const char *const calc3_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT @@ -355,17 +356,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -472,7 +473,7 @@ YYLEX_DECL() } return( c ); } -#line 476 "calc3.tab.c" +#line 477 "calc3.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -609,6 +610,8 @@ YYPARSE_DECL() int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -661,7 +664,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -737,10 +740,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -851,7 +854,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1061,7 +1064,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1090,7 +1093,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1106,7 +1109,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1192,10 +1195,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1261,7 +1264,7 @@ case 18: #line 73 "calc3.y" { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1265 "calc3.tab.c" +#line 1268 "calc3.tab.c" default: break; } @@ -1316,12 +1319,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/btyacc_demo2.output b/contrib/byacc/test/btyacc/calc_code_all.error similarity index 100% rename from contrib/byacc/test/btyacc/btyacc_demo2.output rename to contrib/byacc/test/btyacc/calc_code_all.error diff --git a/contrib/byacc/test/btyacc/calc_code_all.output b/contrib/byacc/test/btyacc/calc_code_all.output new file mode 100644 index 000000000000..c689eec0535a --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/calc_code_all.tab.c b/contrib/byacc/test/btyacc/calc_code_all.tab.c new file mode 100644 index 000000000000..92d4d63886e3 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc_code_all.tab.c @@ -0,0 +1,1502 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +/* %code "top" block start */ +#line 5 "calc_code_all.y" +/* CODE-TOP */ +/* %code "top" block end */ +#line 22 "calc_code_all.tab.c" +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_all_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_all_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_all_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_all_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_all_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_all_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_all_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_all_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_all_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_all_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_all_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_all_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_all_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_all_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_all_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_all_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_all_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_all_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_all_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_all_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_all_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_all_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_all_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_all_" + +#define YYPURE 0 + +#line 9 "calc_code_all.y" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 35 "calc_code_all.y" + { yyerrok ; } +break; +case 4: +#line 39 "calc_code_all.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "calc_code_all.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "calc_code_all.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "calc_code_all.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "calc_code_all.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "calc_code_all.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "calc_code_all.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "calc_code_all.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "calc_code_all.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "calc_code_all.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "calc_code_all.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "calc_code_all.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "calc_code_all.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "calc_code_all.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1269 "calc_code_all.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/calc_code_all.tab.h b/contrib/byacc/test/btyacc/calc_code_all.tab.h new file mode 100644 index 000000000000..e79ea7ab9300 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/btyacc_demo2.tab.h b/contrib/byacc/test/btyacc/calc_code_default.error similarity index 100% rename from contrib/byacc/test/btyacc/btyacc_demo2.tab.h rename to contrib/byacc/test/btyacc/calc_code_default.error diff --git a/contrib/byacc/test/btyacc/calc_code_default.output b/contrib/byacc/test/btyacc/calc_code_default.output new file mode 100644 index 000000000000..c689eec0535a --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/calc_code_default.tab.c b/contrib/byacc/test/btyacc/calc_code_default.tab.c new file mode 100644 index 000000000000..3ba5e5b4d274 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc_code_default.tab.c @@ -0,0 +1,1482 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_default_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_default_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_default_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_default_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_default_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_default_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_default_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_default_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_default_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_default_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_default_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_default_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_default_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_default_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_default_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_default_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_default_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_default_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_default_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_default_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_default_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_default_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_default_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_default_" + +#define YYPURE 0 + +#line 5 "calc_code_default.y" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_default.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_default.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_default.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_default.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_default.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_default.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_default.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_default.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_default.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_default.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_default.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_default.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_default.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_default.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_default.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1249 "calc_code_default.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/calc_code_default.tab.h b/contrib/byacc/test/btyacc/calc_code_default.tab.h new file mode 100644 index 000000000000..6f673cc8bc16 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/code_debug.error b/contrib/byacc/test/btyacc/calc_code_imports.error similarity index 100% rename from contrib/byacc/test/btyacc/code_debug.error rename to contrib/byacc/test/btyacc/calc_code_imports.error diff --git a/contrib/byacc/test/btyacc/calc_code_imports.output b/contrib/byacc/test/btyacc/calc_code_imports.output new file mode 100644 index 000000000000..c689eec0535a --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/calc_code_imports.tab.c b/contrib/byacc/test/btyacc/calc_code_imports.tab.c new file mode 100644 index 000000000000..6bc36a29b683 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc_code_imports.tab.c @@ -0,0 +1,1474 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_imports_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_imports_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_imports_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_imports_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_imports_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_imports_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_imports_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_imports_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_imports_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_imports_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_imports_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_imports_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_imports_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_imports_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_imports_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_imports_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_imports_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_imports_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_imports_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_imports_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_imports_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_imports_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_imports_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_imports_" + +#define YYPURE 0 + +#line 5 "calc_code_imports.y" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_imports.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_imports.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_imports.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_imports.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_imports.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_imports.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_imports.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_imports.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1241 "calc_code_imports.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/calc_code_imports.tab.h b/contrib/byacc/test/btyacc/calc_code_imports.tab.h new file mode 100644 index 000000000000..eb8e7bc73390 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/calc_code_provides.error b/contrib/byacc/test/btyacc/calc_code_provides.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/calc_code_provides.output b/contrib/byacc/test/btyacc/calc_code_provides.output new file mode 100644 index 000000000000..c689eec0535a --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/calc_code_provides.tab.c b/contrib/byacc/test/btyacc/calc_code_provides.tab.c new file mode 100644 index 000000000000..6ee06f34d2ae --- /dev/null +++ b/contrib/byacc/test/btyacc/calc_code_provides.tab.c @@ -0,0 +1,1482 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_provides_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_provides_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_provides_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_provides_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_provides_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_provides_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_provides_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_provides_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_provides_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_provides_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_provides_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_provides_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_provides_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_provides_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_provides_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_provides_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_provides_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_provides_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_provides_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_provides_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_provides_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_provides_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_provides_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_provides_" + +#define YYPURE 0 + +#line 5 "calc_code_provides.y" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_provides.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_provides.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_provides.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_provides.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_provides.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_provides.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_provides.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_provides.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1249 "calc_code_provides.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/calc_code_provides.tab.h b/contrib/byacc/test/btyacc/calc_code_provides.tab.h new file mode 100644 index 000000000000..1ca968af458c --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/calc_code_requires.error b/contrib/byacc/test/btyacc/calc_code_requires.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/calc_code_requires.output b/contrib/byacc/test/btyacc/calc_code_requires.output new file mode 100644 index 000000000000..c689eec0535a --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/calc_code_requires.tab.c b/contrib/byacc/test/btyacc/calc_code_requires.tab.c new file mode 100644 index 000000000000..086e6b7bd1af --- /dev/null +++ b/contrib/byacc/test/btyacc/calc_code_requires.tab.c @@ -0,0 +1,1482 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_requires_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_requires_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_requires_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_requires_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_requires_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_requires_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_requires_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_requires_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_requires_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_requires_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_requires_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_requires_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_requires_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_requires_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_requires_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_requires_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_requires_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_requires_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_requires_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_requires_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_requires_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_requires_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_requires_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_requires_" + +#define YYPURE 0 + +#line 5 "calc_code_requires.y" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_requires.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_requires.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_requires.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_requires.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_requires.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_requires.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_requires.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_requires.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1249 "calc_code_requires.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/calc_code_requires.tab.h b/contrib/byacc/test/btyacc/calc_code_requires.tab.h new file mode 100644 index 000000000000..d5b711b534aa --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/calc_code_top.error b/contrib/byacc/test/btyacc/calc_code_top.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/calc_code_top.output b/contrib/byacc/test/btyacc/calc_code_top.output new file mode 100644 index 000000000000..c689eec0535a --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/calc_code_top.tab.c b/contrib/byacc/test/btyacc/calc_code_top.tab.c new file mode 100644 index 000000000000..6e6ce04adfc7 --- /dev/null +++ b/contrib/byacc/test/btyacc/calc_code_top.tab.c @@ -0,0 +1,1482 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +/* %code "top" block start */ +#line 1 "calc_code_top.y" +/* CODE-TOP */ +#line 2 "calc_code_top.y" +/* CODE-TOP2 */ +/* %code "top" block end */ +#line 24 "calc_code_top.tab.c" +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" + +#ifndef yyparse +#define yyparse calc_code_top_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_top_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_top_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_top_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_top_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_top_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_top_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_top_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_top_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_top_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_top_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_top_defred +#endif /* yydefred */ + +#ifndef yystos +#define yystos calc_code_top_stos +#endif /* yystos */ + +#ifndef yydgoto +#define yydgoto calc_code_top_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_top_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_top_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_top_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_top_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_top_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_top_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_top_rule +#endif /* yyrule */ + +#if YYBTYACC + +#ifndef yycindex +#define yycindex calc_code_top_cindex +#endif /* yycindex */ + +#ifndef yyctable +#define yyctable calc_code_top_ctable +#endif /* yyctable */ + +#endif /* YYBTYACC */ + +#define YYPREFIX "calc_code_top_" + +#define YYPURE 0 + +#line 5 "calc_code_top.y" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 31 "calc_code_top.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_top.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_top.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_top.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_top.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_top.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_top.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_top.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_top.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_top.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_top.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_top.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_top.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_top.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_top.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1249 "calc_code_top.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/calc_code_top.tab.h b/contrib/byacc/test/btyacc/calc_code_top.tab.h new file mode 100644 index 000000000000..8be78b276e36 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/code_calc.code.c b/contrib/byacc/test/btyacc/code_calc.code.c index e2e4c1245472..4434a187ead9 100644 --- a/contrib/byacc/test/btyacc/code_calc.code.c +++ b/contrib/byacc/test/btyacc/code_calc.code.c @@ -182,7 +182,7 @@ typedef int YYSTYPE; #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) extern int YYPARSE_DECL(); -typedef short YYINT; +typedef int YYINT; extern const YYINT yylhs[]; extern const YYINT yylen[]; extern const YYINT yydefred[]; @@ -207,13 +207,16 @@ extern const char *const yyname[]; extern const char *const yyrule[]; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -226,17 +229,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -377,7 +380,7 @@ yylex(void) } return( c ); } -#line 381 "code_calc.code.c" +#line 384 "code_calc.code.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -516,7 +519,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -583,10 +586,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -697,7 +700,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -907,7 +910,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -936,7 +939,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -952,7 +955,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1038,10 +1041,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1107,7 +1110,7 @@ case 18: #line 67 "code_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1111 "code_calc.code.c" +#line 1114 "code_calc.code.c" default: break; } @@ -1162,12 +1165,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/code_calc.tab.c b/contrib/byacc/test/btyacc/code_calc.tab.c index 6486b83667ec..c6c5048a40d6 100644 --- a/contrib/byacc/test/btyacc/code_calc.tab.c +++ b/contrib/byacc/test/btyacc/code_calc.tab.c @@ -1,7 +1,7 @@ #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" -typedef short YYINT; +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, diff --git a/contrib/byacc/test/btyacc/code_debug.i b/contrib/byacc/test/btyacc/code_debug.i deleted file mode 100644 index b8f2144e197f..000000000000 --- a/contrib/byacc/test/btyacc/code_debug.i +++ /dev/null @@ -1,60 +0,0 @@ -#define YYPREFIX "yy" - -#define YYPURE 0 - -#line 2 "code_debug.y" - -#ifdef YYBISON -int yylex(void); -static void yyerror(const char *); -#endif - - -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif - -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) -# endif -#else -# define YYPARSE_DECL() yyparse(void) -#endif - -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() -#endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - -extern int yydebug; -extern int yynerrs; - -extern int yyerrflag; -extern int yychar; -extern YYSTYPE yyval; -extern YYSTYPE yylval; -#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) -extern YYLTYPE yyloc; /* position returned by actions */ -extern YYLTYPE yylloc; /* position from the lexer */ -#endif diff --git a/contrib/byacc/test/btyacc/code_debug.output b/contrib/byacc/test/btyacc/code_debug.output deleted file mode 100644 index 1e56c214a6cc..000000000000 --- a/contrib/byacc/test/btyacc/code_debug.output +++ /dev/null @@ -1,34 +0,0 @@ - 0 $accept : S $end - - 1 S : error - -state 0 - $accept : . S $end (0) - - error shift 1 - . error - - S goto 2 - - -state 1 - S : error . (1) - - . reduce 1 - - -state 2 - $accept : S . $end (0) - - $end accept - - -2 terminals, 2 nonterminals -2 grammar rules, 3 states - -grammar parser grammar -symbol# value# symbol - 0 0 $end - 1 256 error - 2 257 $accept - 3 258 S diff --git a/contrib/byacc/test/btyacc/code_error.code.c b/contrib/byacc/test/btyacc/code_error.code.c index 6169071c835d..5b4130f4cd85 100644 --- a/contrib/byacc/test/btyacc/code_error.code.c +++ b/contrib/byacc/test/btyacc/code_error.code.c @@ -172,7 +172,7 @@ typedef int YYSTYPE; #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) extern int YYPARSE_DECL(); -typedef short YYINT; +typedef int YYINT; extern const YYINT yylhs[]; extern const YYINT yylen[]; extern const YYINT yydefred[]; @@ -197,13 +197,16 @@ extern const char *const yyname[]; extern const char *const yyrule[]; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -216,17 +219,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -347,7 +350,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 351 "code_error.code.c" +#line 354 "code_error.code.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -486,7 +489,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -553,10 +556,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -667,7 +670,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -877,7 +880,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -906,7 +909,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -922,7 +925,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1008,10 +1011,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1071,12 +1074,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/code_error.tab.c b/contrib/byacc/test/btyacc/code_error.tab.c index 88cff35909a2..1037951653ea 100644 --- a/contrib/byacc/test/btyacc/code_error.tab.c +++ b/contrib/byacc/test/btyacc/code_error.tab.c @@ -1,7 +1,7 @@ #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" -typedef short YYINT; +typedef int YYINT; const YYINT error_lhs[] = { -1, 0, }; diff --git a/contrib/byacc/test/btyacc/code_debug.c b/contrib/byacc/test/btyacc/defines1.calc.c similarity index 67% rename from contrib/byacc/test/btyacc/code_debug.c rename to contrib/byacc/test/btyacc/defines1.calc.c index bf002572304b..606ad414f571 100644 --- a/contrib/byacc/test/btyacc/code_debug.c +++ b/contrib/byacc/test/btyacc/defines1.calc.c @@ -16,78 +16,245 @@ #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" -#line 20 "code_debug.c" -#include "rename_debug.i" -#include "rename_debug.h" -typedef short YYINT; +#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, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, }; static const YYINT yylen[] = { 2, - 1, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, }; -static const YYINT yydefred[] = { 0, - 1, 0, +static const YYINT yydefred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT yystos[] = { 0, - 256, 258, + 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, + 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, + 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, + 263, 263, }; -static const YYINT yydgoto[] = { 2, +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ +static const YYINT yydgoto[] = { 1, + 7, 8, 9, }; -static const YYINT yysindex[] = { -256, +static const YYINT yysindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, 0, 0, }; static const YYINT yyrindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, 0, 0, }; #if YYBTYACC static const YYINT yycindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT yygindex[] = { 0, + 0, 65, 0, }; -#define YYTABLESIZE 0 -static const YYINT yytable[] = { 1, +#define YYTABLESIZE 220 +static const YYINT yytable[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, }; -static const YYINT yycheck[] = { 256, +static const YYINT yycheck[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, }; #if YYBTYACC -static const YYINT yyctable[] = { 0, +static const YYINT yyctable[] = { -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif -#define YYFINAL 2 +#define YYFINAL 1 #ifndef YYDEBUG -#define YYDEBUG 1 +#define YYDEBUG 0 #endif -#define YYMAXTOKEN 256 -#define YYUNDFTOKEN 259 +#define YYMAXTOKEN 259 +#define YYUNDFTOKEN 265 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const yyname[] = { -"$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","$accept","S","illegal-symbol", +0,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", +"illegal-symbol", }; static const char *const yyrule[] = { -"$accept : S", -"S : error", +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -100,17 +267,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -141,9 +308,9 @@ do \ typedef struct { unsigned stacksize; - short *s_base; - short *s_mark; - short *s_last; + YYINT *s_base; + YYINT *s_mark; + YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -201,37 +368,53 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ -#line 12 "code_debug.y" - -#include - -#ifdef YYBYACC -extern int YYLEX_DECL(); -#endif +#line 66 "calc.y" + /* start of programs */ int -main(void) +main (void) { - printf("yyparse() = %d\n", yyparse()); + while(!feof(stdin)) { + yyparse(); + } return 0; } +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + int yylex(void) { - return -1; -} + /* 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 */ -static void -yyerror(const char* s) -{ - printf("%s\n", s); + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); } -#line 236 "code_debug.c" +#line 418 "y.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -240,7 +423,7 @@ yyerror(const char* s) #endif /* YYBTYACC */ #if YYDEBUG -#include /* needed for printf */ +#include /* needed for printf */ #endif #include /* needed for malloc, etc */ @@ -251,7 +434,7 @@ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; - short *newss; + YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; @@ -265,7 +448,7 @@ static int yygrowstack(YYSTACKDATA *data) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); - newss = (short *)realloc(data->s_base, newsize * sizeof(*newss)); + newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == 0) return YYENOMEM; @@ -329,7 +512,7 @@ yyNewState(unsigned size) #endif return p; } - p->yystack.s_base = (short *) malloc(size * sizeof(short)); + p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; @@ -370,7 +553,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -384,11 +567,16 @@ YYPARSE_DECL() if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); +#endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ + yym = 0; + yyn = 0; yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; @@ -428,14 +616,14 @@ YYPARSE_DECL() /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ - int p = yylvp - yylvals; - int s = yylvlim - yylvals; + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -445,7 +633,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -462,11 +650,10 @@ YYPARSE_DECL() } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; - /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ #if YYDEBUG if (yydebug) { - yys = yyname[YYTRANSLATE(yychar)]; + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING @@ -525,12 +712,12 @@ YYPARSE_DECL() save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) @@ -547,7 +734,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -571,7 +758,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -585,7 +772,7 @@ YYPARSE_DECL() yylexp--; yychar = YYEMPTY; } - save->lexeme = yylvp - yylvals; + save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) @@ -606,7 +793,7 @@ YYPARSE_DECL() if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; - *++yystack.s_mark = (short) yystate; + *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; @@ -652,9 +839,18 @@ YYPARSE_DECL() yynewerrflag = 1; goto yyerrhandler; - goto yyerrlab; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yynewerrflag = 0; yyerrhandler: while (yyps->save) @@ -679,14 +875,14 @@ YYPARSE_DECL() yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); - memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); - memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); - memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif - yyerrctx->lexeme = yylvp - yylvals; + yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -695,12 +891,12 @@ YYPARSE_DECL() yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); - memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); - memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); - memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; @@ -730,12 +926,12 @@ YYPARSE_DECL() yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); - memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); - memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); - memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); @@ -748,11 +944,11 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC - goto yyerrlab; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; @@ -777,7 +973,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -793,7 +989,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -821,7 +1017,7 @@ YYPARSE_DECL() #if YYDEBUG if (yydebug) { - yys = yyname[YYTRANSLATE(yychar)]; + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } @@ -879,15 +1075,76 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { +case 3: +#line 28 "calc.y" + { yyerrok ; } +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1148 "y.tab.c" default: break; } @@ -938,16 +1195,16 @@ YYPARSE_DECL() /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ - int p = yylvp - yylvals; - int s = yylvlim - yylvals; + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -958,7 +1215,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -975,12 +1232,11 @@ YYPARSE_DECL() } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; - /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ #if YYDEBUG if (yydebug) { - yys = yyname[YYTRANSLATE(yychar)]; - fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n", + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif @@ -1007,7 +1263,7 @@ YYPARSE_DECL() } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - *++yystack.s_mark = (short) yystate; + *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; @@ -1042,12 +1298,12 @@ YYPARSE_DECL() yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); - memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); - memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); - memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; diff --git a/contrib/byacc/test/btyacc/code_debug.h b/contrib/byacc/test/btyacc/defines1.calc.h similarity index 57% rename from contrib/byacc/test/btyacc/code_debug.h rename to contrib/byacc/test/btyacc/defines1.calc.h index ba44e7d75a77..64c392589c06 100644 --- a/contrib/byacc/test/btyacc/code_debug.h +++ b/contrib/byacc/test/btyacc/defines1.calc.h @@ -1,6 +1,8 @@ #ifndef _yy_defines_h_ #define _yy_defines_h_ -#define YYERRCODE 256 +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 #endif /* _yy_defines_h_ */ diff --git a/contrib/byacc/test/btyacc/defines1.error b/contrib/byacc/test/btyacc/defines1.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/defines1.output b/contrib/byacc/test/btyacc/defines1.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/defines2.calc.c b/contrib/byacc/test/btyacc/defines2.calc.c new file mode 100644 index 000000000000..606ad414f571 --- /dev/null +++ b/contrib/byacc/test/btyacc/defines2.calc.c @@ -0,0 +1,1381 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1148 "y.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/defines2.calc.h b/contrib/byacc/test/btyacc/defines2.calc.h new file mode 100644 index 000000000000..64c392589c06 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/defines2.error b/contrib/byacc/test/btyacc/defines2.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/defines2.output b/contrib/byacc/test/btyacc/defines2.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/defines3.calc.c b/contrib/byacc/test/btyacc/defines3.calc.c new file mode 100644 index 000000000000..34473f73b66a --- /dev/null +++ b/contrib/byacc/test/btyacc/defines3.calc.c @@ -0,0 +1,1381 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1148 "prefix.tab.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/defines3.calc.h b/contrib/byacc/test/btyacc/defines3.calc.h new file mode 100644 index 000000000000..64c392589c06 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/btyacc/defines3.error b/contrib/byacc/test/btyacc/defines3.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/defines3.output b/contrib/byacc/test/btyacc/defines3.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/empty.tab.c b/contrib/byacc/test/btyacc/empty.tab.c index 11c252d1b1c3..8ec7d2d9d386 100644 --- a/contrib/byacc/test/btyacc/empty.tab.c +++ b/contrib/byacc/test/btyacc/empty.tab.c @@ -164,7 +164,7 @@ typedef int YYSTYPE; extern int YYPARSE_DECL(); #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT empty_lhs[] = { -1, 0, }; @@ -229,13 +229,16 @@ static const char *const empty_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -248,17 +251,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -366,7 +369,7 @@ static void YYERROR_DECL() { printf("%s\n",s); } -#line 370 "empty.tab.c" +#line 373 "empty.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -505,7 +508,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -572,10 +575,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -686,7 +689,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -896,7 +899,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -925,7 +928,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -941,7 +944,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1027,10 +1030,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1090,12 +1093,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/err_inherit3.tab.c b/contrib/byacc/test/btyacc/err_inherit3.tab.c index 9ccaa5bd1baf..790d9c5eaf66 100644 --- a/contrib/byacc/test/btyacc/err_inherit3.tab.c +++ b/contrib/byacc/test/btyacc/err_inherit3.tab.c @@ -197,7 +197,7 @@ extern int YYPARSE_DECL(); #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT err_inherit3_lhs[] = { -1, 5, 6, 0, 0, 3, 3, 4, 4, 7, 1, 1, 8, 2, @@ -290,13 +290,16 @@ static const char *const err_inherit3_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -309,17 +312,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -418,7 +421,7 @@ static YYINT *yylexemes = 0; extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 422 "err_inherit3.tab.c" +#line 425 "err_inherit3.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -438,7 +441,7 @@ YYDESTRUCT_DECL() } } break; -#line 442 "err_inherit3.tab.c" +#line 445 "err_inherit3.tab.c" case 264: #line 30 "err_inherit3.y" { @@ -450,7 +453,7 @@ YYDESTRUCT_DECL() } } break; -#line 454 "err_inherit3.tab.c" +#line 457 "err_inherit3.tab.c" case 265: #line 30 "err_inherit3.y" { @@ -462,7 +465,7 @@ YYDESTRUCT_DECL() } } break; -#line 466 "err_inherit3.tab.c" +#line 469 "err_inherit3.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -605,7 +608,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -672,10 +675,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -786,7 +789,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -996,7 +999,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1025,7 +1028,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1041,7 +1044,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1127,10 +1130,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1192,7 +1195,7 @@ case 13: #line 75 "err_inherit3.y" { yyval.nlist = yystack.l_mark[0].nlist; } break; -#line 1196 "err_inherit3.tab.c" +#line 1199 "err_inherit3.tab.c" default: break; } @@ -1247,12 +1250,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/err_inherit4.tab.c b/contrib/byacc/test/btyacc/err_inherit4.tab.c index 6c553b86c8c7..9e101f8370b1 100644 --- a/contrib/byacc/test/btyacc/err_inherit4.tab.c +++ b/contrib/byacc/test/btyacc/err_inherit4.tab.c @@ -219,7 +219,7 @@ extern int YYPARSE_DECL(); #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT err_inherit4_lhs[] = { -1, 5, 6, 0, 0, 3, 3, 4, 4, 1, 1, 2, @@ -309,13 +309,16 @@ static const char *const err_inherit4_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -328,17 +331,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -437,7 +440,7 @@ static YYINT *yylexemes = 0; extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 441 "err_inherit4.tab.c" +#line 444 "err_inherit4.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -450,17 +453,17 @@ YYDESTRUCT_DECL() #line 28 "err_inherit4.y" { } break; -#line 454 "err_inherit4.tab.c" +#line 457 "err_inherit4.tab.c" case 264: #line 28 "err_inherit4.y" { } break; -#line 459 "err_inherit4.tab.c" +#line 462 "err_inherit4.tab.c" case 265: #line 28 "err_inherit4.y" { } break; -#line 464 "err_inherit4.tab.c" +#line 467 "err_inherit4.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -603,7 +606,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -670,10 +673,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -784,7 +787,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -994,7 +997,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1023,7 +1026,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1039,7 +1042,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1125,10 +1128,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1182,7 +1185,7 @@ case 11: #line 77 "err_inherit4.y" { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[1]; } break; -#line 1186 "err_inherit4.tab.c" +#line 1189 "err_inherit4.tab.c" default: break; } @@ -1237,12 +1240,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/err_inherit4.tab.h b/contrib/byacc/test/btyacc/err_inherit4.tab.h index 758d426b54f5..657f87f078fa 100644 --- a/contrib/byacc/test/btyacc/err_inherit4.tab.h +++ b/contrib/byacc/test/btyacc/err_inherit4.tab.h @@ -35,5 +35,6 @@ typedef struct YYLTYPE #define YYLTYPE_IS_DECLARED 1 #endif #define YYRHSLOC(rhs, k) ((rhs)[k]) +extern YYLTYPE err_inherit4_lloc; #endif /* _err_inherit4__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_syntax10.tab.c b/contrib/byacc/test/btyacc/err_syntax10.tab.c index ef93d6d84315..c004a0790438 100644 --- a/contrib/byacc/test/btyacc/err_syntax10.tab.c +++ b/contrib/byacc/test/btyacc/err_syntax10.tab.c @@ -154,7 +154,7 @@ static void yyerror(const char *); extern int YYPARSE_DECL(); #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT err_syntax10_lhs[] = { -1, 0, }; @@ -219,13 +219,16 @@ static const char *const err_syntax10_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -238,17 +241,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -365,7 +368,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 369 "err_syntax10.tab.c" +#line 372 "err_syntax10.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -504,7 +507,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -571,10 +574,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -685,7 +688,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -895,7 +898,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -924,7 +927,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -940,7 +943,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1026,10 +1029,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1089,12 +1092,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/err_syntax11.tab.c b/contrib/byacc/test/btyacc/err_syntax11.tab.c index a6a618bbaf05..e4b3af6144a1 100644 --- a/contrib/byacc/test/btyacc/err_syntax11.tab.c +++ b/contrib/byacc/test/btyacc/err_syntax11.tab.c @@ -160,7 +160,7 @@ typedef int YYSTYPE; extern int YYPARSE_DECL(); #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT err_syntax11_lhs[] = { -1, 0, }; @@ -225,13 +225,16 @@ static const char *const err_syntax11_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -244,17 +247,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -371,7 +374,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 375 "err_syntax11.tab.c" +#line 378 "err_syntax11.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -510,7 +513,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -577,10 +580,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -691,7 +694,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -901,7 +904,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -930,7 +933,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -946,7 +949,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1032,10 +1035,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1095,12 +1098,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/err_syntax12.tab.c b/contrib/byacc/test/btyacc/err_syntax12.tab.c index 5cef02b2ce98..f27d1413e94f 100644 --- a/contrib/byacc/test/btyacc/err_syntax12.tab.c +++ b/contrib/byacc/test/btyacc/err_syntax12.tab.c @@ -161,7 +161,7 @@ extern int YYPARSE_DECL(); #define text 456 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT err_syntax12_lhs[] = { -1, 0, }; @@ -231,13 +231,16 @@ static const char *const err_syntax12_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -250,17 +253,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -377,7 +380,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 381 "err_syntax12.tab.c" +#line 384 "err_syntax12.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -516,7 +519,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -583,10 +586,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -697,7 +700,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -907,7 +910,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -936,7 +939,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -952,7 +955,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1038,10 +1041,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1101,12 +1104,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/err_syntax18.tab.c b/contrib/byacc/test/btyacc/err_syntax18.tab.c index 8c81319c3a77..f79b911c4b58 100644 --- a/contrib/byacc/test/btyacc/err_syntax18.tab.c +++ b/contrib/byacc/test/btyacc/err_syntax18.tab.c @@ -160,7 +160,7 @@ typedef int YYSTYPE; extern int YYPARSE_DECL(); #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT err_syntax18_lhs[] = { -1, 0, }; @@ -228,13 +228,16 @@ static const char *const err_syntax18_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -247,17 +250,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -374,7 +377,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 378 "err_syntax18.tab.c" +#line 381 "err_syntax18.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -513,7 +516,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -580,10 +583,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -694,7 +697,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -904,7 +907,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -933,7 +936,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -949,7 +952,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1035,10 +1038,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1048,7 +1051,7 @@ case 1: #line 9 "err_syntax18.y" { yyval = yystack.l_mark[1]; } break; -#line 1052 "err_syntax18.tab.c" +#line 1055 "err_syntax18.tab.c" default: break; } @@ -1103,12 +1106,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/err_syntax20.tab.c b/contrib/byacc/test/btyacc/err_syntax20.tab.c index f9ccc2a9b603..1a81604d809c 100644 --- a/contrib/byacc/test/btyacc/err_syntax20.tab.c +++ b/contrib/byacc/test/btyacc/err_syntax20.tab.c @@ -155,7 +155,7 @@ extern int YYPARSE_DECL(); #define recur 257 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT err_syntax20_lhs[] = { -1, 0, }; @@ -223,13 +223,16 @@ static const char *const err_syntax20_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -242,17 +245,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -369,7 +372,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 373 "err_syntax20.tab.c" +#line 376 "err_syntax20.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -508,7 +511,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -575,10 +578,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -689,7 +692,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -899,7 +902,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -928,7 +931,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -944,7 +947,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1030,10 +1033,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1043,7 +1046,7 @@ case 1: #line 12 "err_syntax20.y" { yystack.l_mark[-1].rechk = 3; } break; -#line 1047 "err_syntax20.tab.c" +#line 1050 "err_syntax20.tab.c" default: break; } @@ -1098,12 +1101,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/error.tab.c b/contrib/byacc/test/btyacc/error.tab.c index 051f78eca0e4..03770d0c5b4e 100644 --- a/contrib/byacc/test/btyacc/error.tab.c +++ b/contrib/byacc/test/btyacc/error.tab.c @@ -160,7 +160,7 @@ typedef int YYSTYPE; extern int YYPARSE_DECL(); #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT error_lhs[] = { -1, 0, }; @@ -224,13 +224,16 @@ static const char *const error_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -243,17 +246,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -370,7 +373,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 374 "error.tab.c" +#line 377 "error.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -509,7 +512,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -576,10 +579,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -690,7 +693,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -900,7 +903,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -929,7 +932,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -945,7 +948,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1031,10 +1034,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1094,12 +1097,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/expr.oxout.tab.c b/contrib/byacc/test/btyacc/expr.oxout.tab.c index 64857175c39c..8f2ca41e2f2a 100644 --- a/contrib/byacc/test/btyacc/expr.oxout.tab.c +++ b/contrib/byacc/test/btyacc/expr.oxout.tab.c @@ -198,7 +198,7 @@ extern int YYPARSE_DECL(); #define ID 257 #define CONST 258 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT expr.oxout_lhs[] = { -1, 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, }; @@ -345,13 +345,16 @@ static const char *const expr.oxout_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -364,17 +367,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -1790,7 +1793,7 @@ void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) -#line 1794 "expr.oxout.tab.c" +#line 1797 "expr.oxout.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -1929,7 +1932,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -1996,10 +1999,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -2110,7 +2113,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -2320,7 +2323,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -2349,7 +2352,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -2365,7 +2368,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -2451,10 +2454,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -2518,7 +2521,7 @@ case 10: yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} break; -#line 2522 "expr.oxout.tab.c" +#line 2525 "expr.oxout.tab.c" default: break; } @@ -2573,12 +2576,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/grammar.tab.c b/contrib/byacc/test/btyacc/grammar.tab.c index d28354db6534..951d8bbcb6b4 100644 --- a/contrib/byacc/test/btyacc/grammar.tab.c +++ b/contrib/byacc/test/btyacc/grammar.tab.c @@ -144,6 +144,7 @@ static void yyerror(const char *s); /* #include "cproto.h" */ #define MAX_TEXT_SIZE 1024 +#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3) /* Prototype styles */ #if OPT_LINTLIBRARY @@ -404,7 +405,7 @@ haveAnsiParam (void) } return FALSE; } -#line 408 "grammar.tab.c" +#line 409 "grammar.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM @@ -473,7 +474,7 @@ extern int YYPARSE_DECL(); #define T_ASMARG 290 #define T_VA_DCL 291 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -1048,13 +1049,16 @@ static const char *const grammar_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -1067,17 +1071,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -1172,7 +1176,7 @@ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ -#line 1014 "grammar.y" +#line 1015 "grammar.y" /* lex.yy.c */ #define BEGIN yy_start = 1 + 2 * @@ -1189,7 +1193,7 @@ extern char *yytext; extern FILE *yyin, *yyout; static int curly; /* number of curly brace nesting levels */ -static int ly_count; /* number of occurances of %% */ +static int ly_count; /* number of occurrences of %% */ static int inc_depth; /* include nesting level */ static SymbolTable *included_files; /* files already included */ static int yy_start = 0; /* start state number */ @@ -1343,7 +1347,7 @@ free_parser(void) #endif } #endif -#line 1347 "grammar.tab.c" +#line 1351 "grammar.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -1482,7 +1486,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -1549,10 +1553,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -1663,7 +1667,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1873,7 +1877,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1902,7 +1906,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1918,7 +1922,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -2004,29 +2008,29 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 10: -#line 377 "grammar.y" +#line 378 "grammar.y" { yyerrok; } break; case 11: -#line 381 "grammar.y" +#line 382 "grammar.y" { yyerrok; } break; case 13: -#line 392 "grammar.y" +#line 393 "grammar.y" { /* Provide an empty action here so bison will not complain about * incompatible types in the default action it normally would @@ -2035,13 +2039,13 @@ case 13: } break; case 14: -#line 399 "grammar.y" +#line 400 "grammar.y" { /* empty */ } break; case 15: -#line 406 "grammar.y" +#line 407 "grammar.y" { #if OPT_LINTLIBRARY if (types_out && want_typedef()) { @@ -2054,7 +2058,7 @@ case 15: } break; case 16: -#line 417 "grammar.y" +#line 418 "grammar.y" { if (func_params != NULL) { set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); @@ -2070,32 +2074,32 @@ case 16: } break; case 17: -#line 431 "grammar.y" +#line 432 "grammar.y" { cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags; free_decl_spec(&yystack.l_mark[0].decl_spec); } break; case 18: -#line 436 "grammar.y" +#line 437 "grammar.y" { end_typedef(); } break; case 19: -#line 443 "grammar.y" +#line 444 "grammar.y" { begin_typedef(); } break; case 20: -#line 447 "grammar.y" +#line 448 "grammar.y" { begin_typedef(); } break; case 23: -#line 459 "grammar.y" +#line 460 "grammar.y" { int flags = cur_decl_spec_flags; @@ -2109,7 +2113,7 @@ case 23: } break; case 24: -#line 471 "grammar.y" +#line 472 "grammar.y" { int flags = cur_decl_spec_flags; @@ -2120,7 +2124,7 @@ case 24: } break; case 25: -#line 483 "grammar.y" +#line 484 "grammar.y" { check_untagged(&yystack.l_mark[-1].decl_spec); if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) { @@ -2133,7 +2137,7 @@ case 25: } break; case 26: -#line 494 "grammar.y" +#line 495 "grammar.y" { /* If we're converting to K&R and we've got a nominally K&R * function which has a parameter which is ANSI (i.e., a prototyped @@ -2159,7 +2163,7 @@ case 26: } break; case 28: -#line 519 "grammar.y" +#line 520 "grammar.y" { if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) { yyerror("syntax error"); @@ -2171,7 +2175,7 @@ case 28: } break; case 29: -#line 529 "grammar.y" +#line 530 "grammar.y" { DeclSpec decl_spec; @@ -2189,7 +2193,7 @@ case 29: } break; case 36: -#line 560 "grammar.y" +#line 561 "grammar.y" { join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec); free(yystack.l_mark[-1].decl_spec.text); @@ -2197,115 +2201,115 @@ case 36: } break; case 40: -#line 575 "grammar.y" +#line 576 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 41: -#line 579 "grammar.y" +#line 580 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN); } break; case 42: -#line 583 "grammar.y" +#line 584 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 43: -#line 587 "grammar.y" +#line 588 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC); } break; case 44: -#line 591 "grammar.y" +#line 592 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE); } break; case 45: -#line 595 "grammar.y" +#line 596 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK); } break; case 46: -#line 602 "grammar.y" +#line 603 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); } break; case 47: -#line 606 "grammar.y" +#line 607 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 48: -#line 610 "grammar.y" +#line 611 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT); } break; case 49: -#line 614 "grammar.y" +#line 615 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 50: -#line 618 "grammar.y" +#line 619 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 51: -#line 622 "grammar.y" +#line 623 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT); } break; case 52: -#line 626 "grammar.y" +#line 627 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 53: -#line 630 "grammar.y" +#line 631 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 54: -#line 634 "grammar.y" +#line 635 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 55: -#line 638 "grammar.y" +#line 639 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); } break; case 56: -#line 642 "grammar.y" +#line 643 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 57: -#line 646 "grammar.y" +#line 647 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 58: -#line 650 "grammar.y" +#line 651 "grammar.y" { Symbol *s; s = find_symbol(typedef_names, yystack.l_mark[0].text.text); @@ -2314,13 +2318,13 @@ case 58: } break; case 61: -#line 662 "grammar.y" +#line 663 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 62: -#line 666 "grammar.y" +#line 667 "grammar.y" { /* This rule allows the nonterminal to scan #define * names as if they were type modifiers. @@ -2332,56 +2336,56 @@ case 62: } break; case 63: -#line 679 "grammar.y" +#line 680 "grammar.y" { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text); + (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-2].text.text, TEXT_LEN, yystack.l_mark[-1].text.text); new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); } break; case 64: -#line 686 "grammar.y" +#line 687 "grammar.y" { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text); + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); } break; case 65: -#line 693 "grammar.y" +#line 694 "grammar.y" { - (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text); + (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); } break; case 66: -#line 701 "grammar.y" +#line 702 "grammar.y" { imply_typedef(yyval.text.text); } break; case 67: -#line 705 "grammar.y" +#line 706 "grammar.y" { imply_typedef(yyval.text.text); } break; case 68: -#line 712 "grammar.y" +#line 713 "grammar.y" { new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator); } break; case 69: -#line 716 "grammar.y" +#line 717 "grammar.y" { add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator); } break; case 70: -#line 723 "grammar.y" +#line 724 "grammar.y" { if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL && func_style == FUNC_TRADITIONAL && cur_file->convert) { @@ -2392,7 +2396,7 @@ case 70: } break; case 71: -#line 732 "grammar.y" +#line 733 "grammar.y" { if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL && func_style == FUNC_TRADITIONAL && cur_file->convert) { @@ -2402,42 +2406,42 @@ case 71: } break; case 73: -#line 744 "grammar.y" +#line 745 "grammar.y" { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text); + (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, yystack.l_mark[-1].text.text); new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); } break; case 74: -#line 751 "grammar.y" +#line 752 "grammar.y" { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text); + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); } break; case 75: -#line 758 "grammar.y" +#line 759 "grammar.y" { - (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text); + (void)sprintf(buf, "enum %.*s", TEXT_LEN, yystack.l_mark[0].text.text); new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); } break; case 76: -#line 766 "grammar.y" +#line 767 "grammar.y" { imply_typedef("enum"); yyval.text = yystack.l_mark[0].text; } break; case 79: -#line 779 "grammar.y" +#line 780 "grammar.y" { yyval.declarator = yystack.l_mark[0].declarator; - (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); yyval.declarator->begin = yystack.l_mark[-1].text.begin; @@ -2445,32 +2449,32 @@ case 79: } break; case 81: -#line 792 "grammar.y" +#line 793 "grammar.y" { yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin); } break; case 82: -#line 796 "grammar.y" +#line 797 "grammar.y" { yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "(%s)", yyval.declarator->text); + (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); yyval.declarator->begin = yystack.l_mark[-2].text.begin; } break; case 83: -#line 804 "grammar.y" +#line 805 "grammar.y" { yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); } break; case 84: -#line 811 "grammar.y" +#line 812 "grammar.y" { yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); yyval.declarator->params = yystack.l_mark[-1].param_list; @@ -2480,7 +2484,7 @@ case 84: } break; case 85: -#line 819 "grammar.y" +#line 820 "grammar.y" { yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); yyval.declarator->params = yystack.l_mark[-1].param_list; @@ -2490,28 +2494,28 @@ case 85: } break; case 86: -#line 830 "grammar.y" +#line 831 "grammar.y" { - (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text); + (void)sprintf(yyval.text.text, "*%.*s", TEXT_LEN, yystack.l_mark[0].text.text); yyval.text.begin = yystack.l_mark[-1].text.begin; } break; case 87: -#line 835 "grammar.y" +#line 836 "grammar.y" { - (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text); + (void)sprintf(yyval.text.text, "*%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); yyval.text.begin = yystack.l_mark[-2].text.begin; } break; case 88: -#line 843 "grammar.y" +#line 844 "grammar.y" { strcpy(yyval.text.text, ""); yyval.text.begin = 0L; } break; case 90: -#line 852 "grammar.y" +#line 853 "grammar.y" { (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text); yyval.text.begin = yystack.l_mark[0].decl_spec.begin; @@ -2519,132 +2523,132 @@ case 90: } break; case 91: -#line 858 "grammar.y" +#line 859 "grammar.y" { - (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text); + (void)sprintf(yyval.text.text, "%.*s%.*s ", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].decl_spec.text); yyval.text.begin = yystack.l_mark[-1].text.begin; free(yystack.l_mark[0].decl_spec.text); } break; case 93: -#line 868 "grammar.y" +#line 869 "grammar.y" { add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "..."); } break; case 94: -#line 875 "grammar.y" +#line 876 "grammar.y" { new_param_list(&yyval.param_list, yystack.l_mark[0].parameter); } break; case 95: -#line 879 "grammar.y" +#line 880 "grammar.y" { add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter); } break; case 96: -#line 886 "grammar.y" +#line 887 "grammar.y" { check_untagged(&yystack.l_mark[-1].decl_spec); yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); } break; case 97: -#line 891 "grammar.y" +#line 892 "grammar.y" { check_untagged(&yystack.l_mark[-1].decl_spec); yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); } break; case 98: -#line 896 "grammar.y" +#line 897 "grammar.y" { check_untagged(&yystack.l_mark[0].decl_spec); yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0); } break; case 99: -#line 904 "grammar.y" +#line 905 "grammar.y" { new_ident_list(&yyval.param_list); } break; case 101: -#line 912 "grammar.y" +#line 913 "grammar.y" { new_ident_list(&yyval.param_list); add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text); } break; case 102: -#line 917 "grammar.y" +#line 918 "grammar.y" { add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text); } break; case 103: -#line 924 "grammar.y" +#line 925 "grammar.y" { yyval.text = yystack.l_mark[0].text; } break; case 104: -#line 928 "grammar.y" +#line 929 "grammar.y" { #if OPT_LINTLIBRARY if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */ yyval.text = yystack.l_mark[0].text; } else #endif - (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text); + (void)sprintf(yyval.text.text, "&%.*s", TEXT_LEN, yystack.l_mark[0].text.text); yyval.text.begin = yystack.l_mark[-1].text.begin; } break; case 105: -#line 941 "grammar.y" +#line 942 "grammar.y" { yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); } break; case 106: -#line 945 "grammar.y" +#line 946 "grammar.y" { yyval.declarator = yystack.l_mark[0].declarator; - (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); yyval.declarator->begin = yystack.l_mark[-1].text.begin; } break; case 108: -#line 957 "grammar.y" +#line 958 "grammar.y" { yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "(%s)", yyval.declarator->text); + (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); yyval.declarator->begin = yystack.l_mark[-2].text.begin; } break; case 109: -#line 965 "grammar.y" +#line 966 "grammar.y" { yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); } break; case 110: -#line 972 "grammar.y" +#line 973 "grammar.y" { yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); } break; case 111: -#line 976 "grammar.y" +#line 977 "grammar.y" { yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin); yyval.declarator->params = yystack.l_mark[-1].param_list; @@ -2654,7 +2658,7 @@ case 111: } break; case 112: -#line 984 "grammar.y" +#line 985 "grammar.y" { yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin); yyval.declarator->func_stack = yystack.l_mark[-2].declarator; @@ -2663,7 +2667,7 @@ case 112: } break; case 113: -#line 991 "grammar.y" +#line 992 "grammar.y" { Declarator *d; @@ -2676,7 +2680,7 @@ case 113: } break; case 114: -#line 1002 "grammar.y" +#line 1003 "grammar.y" { Declarator *d; @@ -2687,7 +2691,7 @@ case 114: yyval.declarator->func_def = FUNC_ANSI; } break; -#line 2691 "grammar.tab.c" +#line 2695 "grammar.tab.c" default: break; } @@ -2742,12 +2746,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/help.error b/contrib/byacc/test/btyacc/help.error index e69de29bb2d1..f69a74a93091 100644 --- a/contrib/byacc/test/btyacc/help.error +++ b/contrib/byacc/test/btyacc/help.error @@ -0,0 +1,20 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/btyacc/help.output b/contrib/byacc/test/btyacc/help.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/help.output +++ b/contrib/byacc/test/btyacc/help.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/btyacc/inherit0.tab.c b/contrib/byacc/test/btyacc/inherit0.tab.c index 058f6238dd3f..4ab2829be0bc 100644 --- a/contrib/byacc/test/btyacc/inherit0.tab.c +++ b/contrib/byacc/test/btyacc/inherit0.tab.c @@ -171,7 +171,7 @@ extern int YYPARSE_DECL(); #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT inherit0_lhs[] = { -1, 0, 0, 1, 1, 2, 2, 3, 3, 5, 6, 4, @@ -261,13 +261,16 @@ static const char *const inherit0_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -280,17 +283,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -389,7 +392,7 @@ static YYINT *yylexemes = 0; extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 393 "inherit0.tab.c" +#line 396 "inherit0.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -528,7 +531,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -595,10 +598,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -709,7 +712,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -919,7 +922,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -948,7 +951,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -964,7 +967,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1050,10 +1053,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1103,7 +1106,7 @@ case 11: #line 43 "inherit0.y" { yyval = yystack.l_mark[0]; } break; -#line 1107 "inherit0.tab.c" +#line 1110 "inherit0.tab.c" default: break; } @@ -1158,12 +1161,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/inherit1.tab.c b/contrib/byacc/test/btyacc/inherit1.tab.c index 5ff8f34bd22f..eec47f618ad1 100644 --- a/contrib/byacc/test/btyacc/inherit1.tab.c +++ b/contrib/byacc/test/btyacc/inherit1.tab.c @@ -192,7 +192,7 @@ extern int YYPARSE_DECL(); #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT inherit1_lhs[] = { -1, 0, 0, 3, 3, 4, 4, 1, 1, 5, 6, 2, @@ -282,13 +282,16 @@ static const char *const inherit1_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -301,17 +304,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -410,7 +413,7 @@ static YYINT *yylexemes = 0; extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 414 "inherit1.tab.c" +#line 417 "inherit1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -549,7 +552,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -616,10 +619,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -730,7 +733,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -940,7 +943,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -969,7 +972,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -985,7 +988,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1071,10 +1074,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1128,7 +1131,7 @@ case 11: #line 71 "inherit1.y" { yyval.nlist = yystack.l_mark[0].nlist; } break; -#line 1132 "inherit1.tab.c" +#line 1135 "inherit1.tab.c" default: break; } @@ -1183,12 +1186,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/inherit2.tab.c b/contrib/byacc/test/btyacc/inherit2.tab.c index f06dda4d0130..1c1573bfedeb 100644 --- a/contrib/byacc/test/btyacc/inherit2.tab.c +++ b/contrib/byacc/test/btyacc/inherit2.tab.c @@ -197,7 +197,7 @@ extern int YYPARSE_DECL(); #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT inherit2_lhs[] = { -1, 5, 6, 0, 0, 3, 3, 4, 4, 1, 1, 7, 2, @@ -289,13 +289,16 @@ static const char *const inherit2_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -308,17 +311,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -417,7 +420,7 @@ static YYINT *yylexemes = 0; extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 421 "inherit2.tab.c" +#line 424 "inherit2.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -437,7 +440,7 @@ YYDESTRUCT_DECL() } } break; -#line 441 "inherit2.tab.c" +#line 444 "inherit2.tab.c" case 264: #line 30 "inherit2.y" { @@ -449,7 +452,7 @@ YYDESTRUCT_DECL() } } break; -#line 453 "inherit2.tab.c" +#line 456 "inherit2.tab.c" case 265: #line 30 "inherit2.y" { @@ -461,7 +464,7 @@ YYDESTRUCT_DECL() } } break; -#line 465 "inherit2.tab.c" +#line 468 "inherit2.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -604,7 +607,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -671,10 +674,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -785,7 +788,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -995,7 +998,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1024,7 +1027,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1040,7 +1043,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1126,10 +1129,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1187,7 +1190,7 @@ case 12: #line 75 "inherit2.y" { yyval.nlist = yystack.l_mark[0].nlist; } break; -#line 1191 "inherit2.tab.c" +#line 1194 "inherit2.tab.c" default: break; } @@ -1242,12 +1245,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/no_b_opt.error b/contrib/byacc/test/btyacc/no_b_opt.error index e69de29bb2d1..f69a74a93091 100644 --- a/contrib/byacc/test/btyacc/no_b_opt.error +++ b/contrib/byacc/test/btyacc/no_b_opt.error @@ -0,0 +1,20 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/btyacc/no_b_opt.output b/contrib/byacc/test/btyacc/no_b_opt.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_b_opt.output +++ b/contrib/byacc/test/btyacc/no_b_opt.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/btyacc/no_b_opt1.error b/contrib/byacc/test/btyacc/no_b_opt1.error index e69de29bb2d1..87286c2661e6 100644 --- a/contrib/byacc/test/btyacc/no_b_opt1.error +++ b/contrib/byacc/test/btyacc/no_b_opt1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/btyacc/no_b_opt1.output b/contrib/byacc/test/btyacc/no_b_opt1.output index 87286c2661e6..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_b_opt1.output +++ b/contrib/byacc/test/btyacc/no_b_opt1.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/btyacc/no_code_c.error b/contrib/byacc/test/btyacc/no_code_c.error index e69de29bb2d1..87286c2661e6 100644 --- a/contrib/byacc/test/btyacc/no_code_c.error +++ b/contrib/byacc/test/btyacc/no_code_c.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/btyacc/no_code_c.output b/contrib/byacc/test/btyacc/no_code_c.output index 87286c2661e6..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_code_c.output +++ b/contrib/byacc/test/btyacc/no_code_c.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/btyacc/no_defines.error b/contrib/byacc/test/btyacc/no_defines.error index e69de29bb2d1..773985d66f33 100644 --- a/contrib/byacc/test/btyacc/no_defines.error +++ b/contrib/byacc/test/btyacc/no_defines.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.h" diff --git a/contrib/byacc/test/btyacc/no_defines.output b/contrib/byacc/test/btyacc/no_defines.output index 773985d66f33..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_defines.output +++ b/contrib/byacc/test/btyacc/no_defines.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.h" diff --git a/contrib/byacc/test/btyacc/no_graph.error b/contrib/byacc/test/btyacc/no_graph.error index e69de29bb2d1..d5575f400421 100644 --- a/contrib/byacc/test/btyacc/no_graph.error +++ b/contrib/byacc/test/btyacc/no_graph.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.dot" diff --git a/contrib/byacc/test/btyacc/no_graph.output b/contrib/byacc/test/btyacc/no_graph.output index d5575f400421..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_graph.output +++ b/contrib/byacc/test/btyacc/no_graph.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.dot" diff --git a/contrib/byacc/test/btyacc/no_include.error b/contrib/byacc/test/btyacc/no_include.error index e69de29bb2d1..3ece4a454e39 100644 --- a/contrib/byacc/test/btyacc/no_include.error +++ b/contrib/byacc/test/btyacc/no_include.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.i" diff --git a/contrib/byacc/test/btyacc/no_include.output b/contrib/byacc/test/btyacc/no_include.output index 3ece4a454e39..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_include.output +++ b/contrib/byacc/test/btyacc/no_include.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.i" diff --git a/contrib/byacc/test/btyacc/no_opts.error b/contrib/byacc/test/btyacc/no_opts.error index e69de29bb2d1..ad3131a69ab6 100644 --- a/contrib/byacc/test/btyacc/no_opts.error +++ b/contrib/byacc/test/btyacc/no_opts.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.y" diff --git a/contrib/byacc/test/btyacc/no_opts.output b/contrib/byacc/test/btyacc/no_opts.output index ad3131a69ab6..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_opts.output +++ b/contrib/byacc/test/btyacc/no_opts.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.y" diff --git a/contrib/byacc/test/btyacc/no_output.error b/contrib/byacc/test/btyacc/no_output.error index e69de29bb2d1..a2f142a9d531 100644 --- a/contrib/byacc/test/btyacc/no_output.error +++ b/contrib/byacc/test/btyacc/no_output.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/btyacc/no_output.output b/contrib/byacc/test/btyacc/no_output.output index a2f142a9d531..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_output.output +++ b/contrib/byacc/test/btyacc/no_output.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/btyacc/no_output1.error b/contrib/byacc/test/btyacc/no_output1.error index e69de29bb2d1..a2f142a9d531 100644 --- a/contrib/byacc/test/btyacc/no_output1.error +++ b/contrib/byacc/test/btyacc/no_output1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/btyacc/no_output1.output b/contrib/byacc/test/btyacc/no_output1.output index a2f142a9d531..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_output1.output +++ b/contrib/byacc/test/btyacc/no_output1.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/btyacc/no_output2.error b/contrib/byacc/test/btyacc/no_output2.error index e69de29bb2d1..f69a74a93091 100644 --- a/contrib/byacc/test/btyacc/no_output2.error +++ b/contrib/byacc/test/btyacc/no_output2.error @@ -0,0 +1,20 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/btyacc/no_output2.output b/contrib/byacc/test/btyacc/no_output2.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_output2.output +++ b/contrib/byacc/test/btyacc/no_output2.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/btyacc/no_p_opt.error b/contrib/byacc/test/btyacc/no_p_opt.error index e69de29bb2d1..f69a74a93091 100644 --- a/contrib/byacc/test/btyacc/no_p_opt.error +++ b/contrib/byacc/test/btyacc/no_p_opt.error @@ -0,0 +1,20 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/btyacc/no_p_opt.output b/contrib/byacc/test/btyacc/no_p_opt.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_p_opt.output +++ b/contrib/byacc/test/btyacc/no_p_opt.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/btyacc/no_p_opt1.error b/contrib/byacc/test/btyacc/no_p_opt1.error index e69de29bb2d1..87286c2661e6 100644 --- a/contrib/byacc/test/btyacc/no_p_opt1.error +++ b/contrib/byacc/test/btyacc/no_p_opt1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/btyacc/no_p_opt1.output b/contrib/byacc/test/btyacc/no_p_opt1.output index 87286c2661e6..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_p_opt1.output +++ b/contrib/byacc/test/btyacc/no_p_opt1.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/btyacc/no_verbose.error b/contrib/byacc/test/btyacc/no_verbose.error index e69de29bb2d1..a2f142a9d531 100644 --- a/contrib/byacc/test/btyacc/no_verbose.error +++ b/contrib/byacc/test/btyacc/no_verbose.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/btyacc/no_verbose.output b/contrib/byacc/test/btyacc/no_verbose.output index a2f142a9d531..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/no_verbose.output +++ b/contrib/byacc/test/btyacc/no_verbose.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/btyacc/nostdin.error b/contrib/byacc/test/btyacc/nostdin.error index e69de29bb2d1..67101620d2c1 100644 --- a/contrib/byacc/test/btyacc/nostdin.error +++ b/contrib/byacc/test/btyacc/nostdin.error @@ -0,0 +1,19 @@ +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/btyacc/nostdin.output b/contrib/byacc/test/btyacc/nostdin.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/btyacc/nostdin.output +++ b/contrib/byacc/test/btyacc/nostdin.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/btyacc/ok_syntax1.tab.c b/contrib/byacc/test/btyacc/ok_syntax1.tab.c index 087a3d0c505c..cf6cc111ca6e 100644 --- a/contrib/byacc/test/btyacc/ok_syntax1.tab.c +++ b/contrib/byacc/test/btyacc/ok_syntax1.tab.c @@ -198,7 +198,7 @@ extern int YYPARSE_DECL(); #define VT 272 #define UMINUS 273 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -368,8 +368,9 @@ static const char *const ok_syntax1_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT @@ -378,17 +379,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -495,7 +496,7 @@ YYLEX_DECL() } return( c ); } -#line 499 "ok_syntax1.tab.c" +#line 500 "ok_syntax1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -632,6 +633,8 @@ YYPARSE_DECL() int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -684,7 +687,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -760,10 +763,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -874,7 +877,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1084,7 +1087,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1113,7 +1116,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1129,7 +1132,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1215,10 +1218,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1284,7 +1287,7 @@ case 18: #line 101 "ok_syntax1.y" { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } break; -#line 1288 "ok_syntax1.tab.c" +#line 1291 "ok_syntax1.tab.c" default: break; } @@ -1339,12 +1342,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/ok_syntax1.tab.h b/contrib/byacc/test/btyacc/ok_syntax1.tab.h index 75e9a96c9bf9..44b8dc3e95d3 100644 --- a/contrib/byacc/test/btyacc/ok_syntax1.tab.h +++ b/contrib/byacc/test/btyacc/ok_syntax1.tab.h @@ -30,6 +30,5 @@ typedef union double dval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE ok_syntax1_lval; #endif /* _ok_syntax1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/pure_calc.tab.c b/contrib/byacc/test/btyacc/pure_calc.tab.c index 8c9cfce026d8..491f881de44c 100644 --- a/contrib/byacc/test/btyacc/pure_calc.tab.c +++ b/contrib/byacc/test/btyacc/pure_calc.tab.c @@ -180,7 +180,7 @@ extern int YYPARSE_DECL(); #define LETTER 258 #define UMINUS 259 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -348,8 +348,9 @@ static const char *const calc_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT @@ -358,17 +359,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -468,7 +469,7 @@ YYLEX_DECL() } return( c ); } -#line 472 "pure_calc.tab.c" +#line 473 "pure_calc.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -605,6 +606,8 @@ YYPARSE_DECL() int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -657,7 +660,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -733,10 +736,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -847,7 +850,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1057,7 +1060,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1086,7 +1089,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1102,7 +1105,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1188,10 +1191,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1257,7 +1260,7 @@ case 18: #line 69 "pure_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1261 "pure_calc.tab.c" +#line 1264 "pure_calc.tab.c" default: break; } @@ -1312,12 +1315,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/pure_error.tab.c b/contrib/byacc/test/btyacc/pure_error.tab.c index 2c334b531867..5dba3d0fe408 100644 --- a/contrib/byacc/test/btyacc/pure_error.tab.c +++ b/contrib/byacc/test/btyacc/pure_error.tab.c @@ -172,7 +172,7 @@ typedef int YYSTYPE; extern int YYPARSE_DECL(); #define YYERRCODE 256 -typedef short YYINT; +typedef int YYINT; static const YYINT error_lhs[] = { -1, 0, }; @@ -236,8 +236,9 @@ static const char *const error_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT @@ -246,17 +247,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -336,7 +337,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 340 "pure_error.tab.c" +#line 341 "pure_error.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -473,6 +474,8 @@ YYPARSE_DECL() int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -525,7 +528,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -601,10 +604,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -715,7 +718,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -925,7 +928,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -954,7 +957,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -970,7 +973,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1056,10 +1059,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1119,12 +1122,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/quote_calc-s.tab.c b/contrib/byacc/test/btyacc/quote_calc-s.tab.c index 25305be1e808..29888135c28a 100644 --- a/contrib/byacc/test/btyacc/quote_calc-s.tab.c +++ b/contrib/byacc/test/btyacc/quote_calc-s.tab.c @@ -176,7 +176,7 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -357,13 +357,16 @@ static const char *const quote_calc_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -376,17 +379,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -522,7 +525,7 @@ yylex(void) { } return( c ); } -#line 526 "quote_calc-s.tab.c" +#line 529 "quote_calc-s.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -661,7 +664,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -728,10 +731,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -842,7 +845,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1052,7 +1055,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1081,7 +1084,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1097,7 +1100,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1183,10 +1186,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1252,7 +1255,7 @@ case 18: #line 70 "quote_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1256 "quote_calc-s.tab.c" +#line 1259 "quote_calc-s.tab.c" default: break; } @@ -1307,12 +1310,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/quote_calc.tab.c b/contrib/byacc/test/btyacc/quote_calc.tab.c index 092129c038a0..384877b5556c 100644 --- a/contrib/byacc/test/btyacc/quote_calc.tab.c +++ b/contrib/byacc/test/btyacc/quote_calc.tab.c @@ -182,7 +182,7 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -363,13 +363,16 @@ static const char *const quote_calc_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -382,17 +385,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -528,7 +531,7 @@ yylex(void) { } return( c ); } -#line 532 "quote_calc.tab.c" +#line 535 "quote_calc.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -667,7 +670,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -734,10 +737,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -848,7 +851,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1058,7 +1061,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1087,7 +1090,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1103,7 +1106,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1189,10 +1192,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1258,7 +1261,7 @@ case 18: #line 70 "quote_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1262 "quote_calc.tab.c" +#line 1265 "quote_calc.tab.c" default: break; } @@ -1313,12 +1316,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/quote_calc2-s.tab.c b/contrib/byacc/test/btyacc/quote_calc2-s.tab.c index fb14a9524c86..7ccd0127e135 100644 --- a/contrib/byacc/test/btyacc/quote_calc2-s.tab.c +++ b/contrib/byacc/test/btyacc/quote_calc2-s.tab.c @@ -176,7 +176,7 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -357,13 +357,16 @@ static const char *const quote_calc2_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -376,17 +379,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -522,7 +525,7 @@ yylex(void) { } return( c ); } -#line 526 "quote_calc2-s.tab.c" +#line 529 "quote_calc2-s.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -661,7 +664,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -728,10 +731,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -842,7 +845,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1052,7 +1055,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1081,7 +1084,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1097,7 +1100,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1183,10 +1186,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1252,7 +1255,7 @@ case 18: #line 70 "quote_calc2.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1256 "quote_calc2-s.tab.c" +#line 1259 "quote_calc2-s.tab.c" default: break; } @@ -1307,12 +1310,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/quote_calc2.tab.c b/contrib/byacc/test/btyacc/quote_calc2.tab.c index f9832043bee6..3378494d51e4 100644 --- a/contrib/byacc/test/btyacc/quote_calc2.tab.c +++ b/contrib/byacc/test/btyacc/quote_calc2.tab.c @@ -182,7 +182,7 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -363,13 +363,16 @@ static const char *const quote_calc2_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -382,17 +385,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -528,7 +531,7 @@ yylex(void) { } return( c ); } -#line 532 "quote_calc2.tab.c" +#line 535 "quote_calc2.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -667,7 +670,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -734,10 +737,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -848,7 +851,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1058,7 +1061,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1087,7 +1090,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1103,7 +1106,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1189,10 +1192,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1258,7 +1261,7 @@ case 18: #line 70 "quote_calc2.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1262 "quote_calc2.tab.c" +#line 1265 "quote_calc2.tab.c" default: break; } @@ -1313,12 +1316,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/quote_calc3-s.tab.c b/contrib/byacc/test/btyacc/quote_calc3-s.tab.c index 15fbd67e18ed..7db30e57057e 100644 --- a/contrib/byacc/test/btyacc/quote_calc3-s.tab.c +++ b/contrib/byacc/test/btyacc/quote_calc3-s.tab.c @@ -176,7 +176,7 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -358,13 +358,16 @@ static const char *const quote_calc3_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -377,17 +380,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -523,7 +526,7 @@ yylex(void) { } return( c ); } -#line 527 "quote_calc3-s.tab.c" +#line 530 "quote_calc3-s.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -662,7 +665,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -729,10 +732,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -843,7 +846,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1053,7 +1056,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1082,7 +1085,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1098,7 +1101,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1184,10 +1187,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1253,7 +1256,7 @@ case 18: #line 70 "quote_calc3.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1257 "quote_calc3-s.tab.c" +#line 1260 "quote_calc3-s.tab.c" default: break; } @@ -1308,12 +1311,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/quote_calc3.tab.c b/contrib/byacc/test/btyacc/quote_calc3.tab.c index ef26f74d9de5..4eae158efdee 100644 --- a/contrib/byacc/test/btyacc/quote_calc3.tab.c +++ b/contrib/byacc/test/btyacc/quote_calc3.tab.c @@ -176,7 +176,7 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -358,13 +358,16 @@ static const char *const quote_calc3_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -377,17 +380,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -523,7 +526,7 @@ yylex(void) { } return( c ); } -#line 527 "quote_calc3.tab.c" +#line 530 "quote_calc3.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -662,7 +665,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -729,10 +732,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -843,7 +846,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1053,7 +1056,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1082,7 +1085,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1098,7 +1101,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1184,10 +1187,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1253,7 +1256,7 @@ case 18: #line 70 "quote_calc3.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1257 "quote_calc3.tab.c" +#line 1260 "quote_calc3.tab.c" default: break; } @@ -1308,12 +1311,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/quote_calc4-s.tab.c b/contrib/byacc/test/btyacc/quote_calc4-s.tab.c index a5ebdbc3cbc6..14ae21643c9d 100644 --- a/contrib/byacc/test/btyacc/quote_calc4-s.tab.c +++ b/contrib/byacc/test/btyacc/quote_calc4-s.tab.c @@ -176,7 +176,7 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -358,13 +358,16 @@ static const char *const quote_calc4_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -377,17 +380,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -523,7 +526,7 @@ yylex(void) { } return( c ); } -#line 527 "quote_calc4-s.tab.c" +#line 530 "quote_calc4-s.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -662,7 +665,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -729,10 +732,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -843,7 +846,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1053,7 +1056,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1082,7 +1085,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1098,7 +1101,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1184,10 +1187,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1253,7 +1256,7 @@ case 18: #line 70 "quote_calc4.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1257 "quote_calc4-s.tab.c" +#line 1260 "quote_calc4-s.tab.c" default: break; } @@ -1308,12 +1311,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/quote_calc4.tab.c b/contrib/byacc/test/btyacc/quote_calc4.tab.c index 14ed4ed06493..1ae947c176b0 100644 --- a/contrib/byacc/test/btyacc/quote_calc4.tab.c +++ b/contrib/byacc/test/btyacc/quote_calc4.tab.c @@ -176,7 +176,7 @@ extern int YYPARSE_DECL(); #define LETTER 270 #define UMINUS 271 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -358,13 +358,16 @@ static const char *const quote_calc4_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -377,17 +380,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -523,7 +526,7 @@ yylex(void) { } return( c ); } -#line 527 "quote_calc4.tab.c" +#line 530 "quote_calc4.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -662,7 +665,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -729,10 +732,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -843,7 +846,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1053,7 +1056,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1082,7 +1085,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1098,7 +1101,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1184,10 +1187,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1253,7 +1256,7 @@ case 18: #line 70 "quote_calc4.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1257 "quote_calc4.tab.c" +#line 1260 "quote_calc4.tab.c" default: break; } @@ -1308,12 +1311,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/rename_debug.c b/contrib/byacc/test/btyacc/rename_debug.c index 5681f91930fd..5e5ec3cc43d8 100644 --- a/contrib/byacc/test/btyacc/rename_debug.c +++ b/contrib/byacc/test/btyacc/rename_debug.c @@ -19,7 +19,7 @@ #line 20 "rename_debug.c" #include "rename_debug.i" #include "rename_debug.h" -typedef short YYINT; +typedef int YYINT; static const YYINT yylhs[] = { -1, 0, }; @@ -83,13 +83,16 @@ static const char *const yyrule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -102,17 +105,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -233,7 +236,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 238 "rename_debug.c" +#line 241 "rename_debug.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -372,7 +375,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -439,10 +442,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -553,7 +556,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -763,7 +766,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -792,7 +795,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -808,7 +811,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -894,10 +897,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -957,12 +960,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/btyacc/rename_debug.i b/contrib/byacc/test/btyacc/rename_debug.i index b8f2144e197f..ce4871a0e68f 100644 --- a/contrib/byacc/test/btyacc/rename_debug.i +++ b/contrib/byacc/test/btyacc/rename_debug.i @@ -37,6 +37,10 @@ typedef int YYSTYPE; # define YYLEX yylex() #endif +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) @@ -47,13 +51,20 @@ typedef int YYSTYPE; extern int YYPARSE_DECL(); +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif + +#if YYDEBUG extern int yydebug; -extern int yynerrs; +#endif extern int yyerrflag; extern int yychar; extern YYSTYPE yyval; extern YYSTYPE yylval; +extern int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) extern YYLTYPE yyloc; /* position returned by actions */ extern YYLTYPE yylloc; /* position from the lexer */ diff --git a/contrib/byacc/test/btyacc/stdin1.calc.c b/contrib/byacc/test/btyacc/stdin1.calc.c new file mode 100644 index 000000000000..62cc97ad5ab6 --- /dev/null +++ b/contrib/byacc/test/btyacc/stdin1.calc.c @@ -0,0 +1,1381 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "(null)" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "(null)" + { yyerrok ; } +break; +case 4: +#line 32 "(null)" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "(null)" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "(null)" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "(null)" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "(null)" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "(null)" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "(null)" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "(null)" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "(null)" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "(null)" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "(null)" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "(null)" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "(null)" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "(null)" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1148 "stdin1.calc.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/stdin1.error b/contrib/byacc/test/btyacc/stdin1.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/stdin1.output b/contrib/byacc/test/btyacc/stdin1.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/stdin2.calc.c b/contrib/byacc/test/btyacc/stdin2.calc.c new file mode 100644 index 000000000000..50b9d5b86b89 --- /dev/null +++ b/contrib/byacc/test/btyacc/stdin2.calc.c @@ -0,0 +1,1381 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#undef YYBTYACC +#define YYBTYACC 0 +#define YYDEBUGSTR YYPREFIX "debug" +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# 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 = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base; +#endif + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", + YYDEBUGSTR, yydepth, yystate, yychar, yys); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); +#endif + fputc('\n', stderr); + } +#endif + } +#if YYBTYACC + + /* Do we have a conflict? */ + if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + YYINT ctry; + + if (yypath) + { + YYParseState *save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", + YYDEBUGSTR, yydepth, yystate); +#endif + /* Switch to the next conflict context */ + save = yypath; + yypath = save->save; + save->save = NULL; + ctry = save->ctry; + if (save->state != yystate) YYABORT; + yyFreeState(save); + + } + else + { + + /* Unresolved conflict - start/continue trial parse */ + YYParseState *save; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); + if (yyps->save) + fputs("ALREADY in conflict, continuing trial parse.\n", stderr); + else + fputs("Starting trial parse.\n", stderr); + } +#endif + save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (save == NULL) goto yyenomem; + save->save = yyps->save; + save->state = yystate; + save->errflag = yyerrflag; + save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = yytable[yyn]; + if (yyctable[ctry] == -1) + { +#if YYDEBUG + if (yydebug && yychar >= YYEOF) + fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); +#endif + ctry++; + } + save->ctry = ctry; + if (yyps->save == NULL) + { + /* If this is a first conflict in the stack, start saving lexemes */ + if (!yylexemes) + { + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + if (yylexemes == NULL) goto yyenomem; + yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); + if (yylvals == NULL) goto yyenomem; + yylvlim = yylvals + YYLVQUEUEGROWTH; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); + if (yylpsns == NULL) goto yyenomem; + yylplim = yylpsns + YYLVQUEUEGROWTH; +#endif + } + if (yylvp == yylve) + { + yylvp = yylve = yylvals; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns; +#endif + yylexp = yylexemes; + if (yychar >= YYEOF) + { + *yylve++ = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpe++ = yylloc; +#endif + *yylexp = (YYINT) yychar; + yychar = YYEMPTY; + } + } + } + if (yychar >= YYEOF) + { + yylvp--; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp--; +#endif + yylexp--; + yychar = YYEMPTY; + } + save->lexeme = (int) (yylvp - yylvals); + yyps->save = save; + } + if (yytable[yyn] == ctry) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); +#endif + if (yychar < 0) + { + yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp++; +#endif + yylexp++; + } + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) + goto yyoverflow; + yystate = yyctable[ctry]; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + else + { + yyn = yyctable[ctry]; + goto yyreduce; + } + } /* End of code dealing with conflicts */ +#endif /* YYBTYACC */ + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", + YYDEBUGSTR, yydepth, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yylloc; +#endif + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; +#if YYBTYACC + + yynewerrflag = 1; + goto yyerrhandler; + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ + +yyerrlab: + /* explicit YYERROR from an action -- pop the rhs of the rule reduced + * before looking for error recovery */ + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + + yynewerrflag = 0; +yyerrhandler: + while (yyps->save) + { + int ctry; + YYParseState *save = yyps->save; +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yyps->save->state, + (int)(yylvp - yylvals - yyps->save->lexeme)); +#endif + /* Memorize most forward-looking error state in case it's really an error. */ + if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) + { + /* Free old saved error context state */ + if (yyerrctx) yyFreeState(yyerrctx); + /* Create and fill out new saved error context state */ + yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); + if (yyerrctx == NULL) goto yyenomem; + yyerrctx->save = yyps->save; + yyerrctx->state = yystate; + yyerrctx->errflag = yyerrflag; + yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); + memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); + memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); + memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yyerrctx->lexeme = (int) (yylvp - yylvals); + } + yylvp = yylvals + save->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + save->lexeme; +#endif + yylexp = yylexemes + save->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); + memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); + memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); + memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + ctry = ++save->ctry; + yystate = save->state; + /* We tried shift, try reduce now */ + if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; + yyps->save = save->save; + save->save = NULL; + yyFreeState(save); + + /* Nothing left on the stack -- error */ + if (!yyps->save) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", + YYPREFIX, yydepth); +#endif + /* Restore state as it was in the most forward-advanced error */ + yylvp = yylvals + yyerrctx->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yyerrctx->lexeme; +#endif + yylexp = yylexemes + yyerrctx->lexeme; + yychar = yylexp[-1]; + yylval = yylvp[-1]; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = yylpp[-1]; +#endif + yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); + memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); + memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); + memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yyerrctx->state; + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yynewerrflag = 1; + } + if (yynewerrflag == 0) goto yyinrecovery; +#endif /* YYBTYACC */ + + YYERROR_CALL("syntax error"); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ +#endif + +#if !YYBTYACC + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: +#endif + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* lookahead position is error end position */ + yyerror_loc_range[2] = yylloc; + YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ + *++yystack.p_mark = yyloc; +#endif + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", + YYDEBUGSTR, yydepth, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + /* the current TOS position is the error start position */ + yyerror_loc_range[1] = *yystack.p_mark; +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); +#else + YYDESTRUCT_CALL("error: discarding state", + yystos[*yystack.s_mark], yystack.l_mark); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + --yystack.s_mark; + --yystack.l_mark; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + --yystack.p_mark; +#endif + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", + YYDEBUGSTR, yydepth, yystate, yychar, yys); + } +#endif +#if defined(YYDESTRUCT_CALL) +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ +#endif /* defined(YYDESTRUCT_CALL) */ + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: + yym = yylen[yyn]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", + YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + if (yym > 0) + { + int i; + fputc('<', stderr); + for (i = yym; i > 0; i--) + { + if (i != yym) fputs(", ", stderr); + fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], + yystack.l_mark[1-i]), stderr); + } + fputc('>', stderr); + } +#endif + fputc('\n', stderr); + } +#endif + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + + /* Perform position reduction */ + memset(&yyloc, 0, sizeof(yyloc)); +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + { + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); + /* just in case YYERROR is invoked within the action, save + the start of the rhs as the error start position */ + yyerror_loc_range[1] = yystack.p_mark[1-yym]; + } +#endif + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 1148 "stdin2.calc.c" + default: + break; + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark -= yym; +#endif + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); +#endif + fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); + } +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + if (yychar < 0) + { +#if YYBTYACC + do { + if (yylvp < yylve) + { + /* we're currently re-reading tokens */ + yylval = *yylvp++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylloc = *yylpp++; +#endif + yychar = *yylexp++; + break; + } + if (yyps->save) + { + /* in trial mode; save scanner results for future parse attempts */ + if (yylvp == yylvlim) + { /* Enlarge lexical value queue */ + size_t p = (size_t) (yylvp - yylvals); + size_t s = (size_t) (yylvlim - yylvals); + + s += YYLVQUEUEGROWTH; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) + goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + goto yyenomem; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + goto yyenomem; +#endif + yylvp = yylve = yylvals + p; + yylvlim = yylvals + s; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpe = yylpsns + p; + yylplim = yylpsns + s; +#endif + yylexp = yylexemes + p; + } + *yylexp = (YYINT) YYLEX; + *yylvp++ = yylval; + yylve++; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *yylpp++ = yylloc; + yylpe++; +#endif + yychar = *yylexp++; + break; + } + /* normal operation, no conflict encountered */ +#endif /* YYBTYACC */ + yychar = YYLEX; +#if YYBTYACC + } while (0); +#endif /* YYBTYACC */ + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", + YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + { + fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); +#ifdef YYSTYPE_TOSTRING +#if YYBTYACC + if (!yytrial) +#endif /* YYBTYACC */ + fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); +#endif + fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); + } +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + *++yystack.p_mark = yyloc; +#endif + goto yyloop; +#if YYBTYACC + + /* Reduction declares that this path is valid. Set yypath and do a full parse */ +yyvalid: + if (yypath) YYABORT; + while (yyps->save) + { + YYParseState *save = yyps->save; + yyps->save = save->save; + save->save = yypath; + yypath = save; + } +#if YYDEBUG + if (yydebug) + fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", + YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); +#endif + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + yylvp = yylvals + yypath->lexeme; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yylpp = yylpsns + yypath->lexeme; +#endif + yylexp = yylexemes + yypath->lexeme; + yychar = YYEMPTY; + yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); + memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); + yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); + memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); + memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); +#endif + yystate = yypath->state; + goto yyloop; +#endif /* YYBTYACC */ + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); +#if YYBTYACC + goto yyabort_nomem; +yyenomem: + YYERROR_CALL("memory exhausted"); +yyabort_nomem: +#endif /* YYBTYACC */ + yyresult = 2; + goto yyreturn; + +yyabort: + yyresult = 1; + goto yyreturn; + +yyaccept: +#if YYBTYACC + if (yyps->save) goto yyvalid; +#endif /* YYBTYACC */ + yyresult = 0; + +yyreturn: +#if defined(YYDESTRUCT_CALL) + if (yychar != YYEOF && yychar != YYEMPTY) +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); +#else + YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + + { + YYSTYPE *pv; +#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) + YYLTYPE *pp; + + for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); +#else + for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) + YYDESTRUCT_CALL("cleanup: discarding state", + yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); +#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ + } +#endif /* defined(YYDESTRUCT_CALL) */ + +#if YYBTYACC + if (yyerrctx) + { + yyFreeState(yyerrctx); + yyerrctx = NULL; + } + while (yyps) + { + YYParseState *save = yyps; + yyps = save->save; + save->save = NULL; + yyFreeState(save); + } + while (yypath) + { + YYParseState *save = yypath; + yypath = save->save; + save->save = NULL; + yyFreeState(save); + } +#endif /* YYBTYACC */ + yyfreestack(&yystack); + return (yyresult); +} diff --git a/contrib/byacc/test/btyacc/stdin2.error b/contrib/byacc/test/btyacc/stdin2.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/stdin2.output b/contrib/byacc/test/btyacc/stdin2.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c index 3f37ddff336e..da6b1d9c397a 100644 --- a/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c +++ b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c @@ -196,7 +196,7 @@ extern int YYPARSE_DECL(); #define CONST 259 #define UMINUS 260 #define YYERRCODE 256 -typedef short YYINT; +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, @@ -394,13 +394,16 @@ static const char *const varsyntax_calc1_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; + #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ @@ -413,17 +416,17 @@ do \ { \ if (n == 0) \ { \ - (loc).first_line = ((rhs)[-1]).last_line; \ - (loc).first_column = ((rhs)[-1]).last_column; \ - (loc).last_line = ((rhs)[-1]).last_line; \ - (loc).last_column = ((rhs)[-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ + (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ + (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ - (loc).first_line = ((rhs)[ 0 ]).first_line; \ - (loc).first_column = ((rhs)[ 0 ]).first_column; \ - (loc).last_line = ((rhs)[n-1]).last_line; \ - (loc).last_column = ((rhs)[n-1]).last_column; \ + (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ + (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ + (loc).last_line = YYRHSLOC(rhs, n).last_line; \ + (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ @@ -649,7 +652,7 @@ vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } -#line 653 "varsyntax_calc1.tab.c" +#line 656 "varsyntax_calc1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -788,7 +791,7 @@ YYPARSE_DECL() YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ + YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; @@ -855,10 +858,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -969,7 +972,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); + yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1179,7 +1182,7 @@ YYPARSE_DECL() YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ + yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC @@ -1208,7 +1211,7 @@ YYPARSE_DECL() *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ - yyerror_loc_range[1] = yylloc; + yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif @@ -1224,7 +1227,7 @@ YYPARSE_DECL() if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ - yyerror_loc_range[0] = *yystack.p_mark; + yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC @@ -1310,10 +1313,10 @@ YYPARSE_DECL() if (!yytrial) #endif /* YYBTYACC */ { - YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); + YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ - yyerror_loc_range[0] = yystack.p_mark[1-yym]; + yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif @@ -1482,7 +1485,7 @@ case 28: yyval.vval = yystack.l_mark[-1].vval; } break; -#line 1486 "varsyntax_calc1.tab.c" +#line 1489 "varsyntax_calc1.tab.c" default: break; } @@ -1537,12 +1540,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) + if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; diff --git a/contrib/byacc/test/calc.tab.c b/contrib/byacc/test/calc.tab.c new file mode 100644 index 000000000000..1f3a81f58dbc --- /dev/null +++ b/contrib/byacc/test/calc.tab.c @@ -0,0 +1,668 @@ +#ifndef lint +static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; +#endif + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) + + +#ifndef yyparse +#define yyparse calc_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_rule +#endif /* yyrule */ +#define YYPREFIX "calc_" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# include + +int regs[26]; +int base; + +extern int yylex(void); +static void yyerror(const char *s); + +#line 109 "calc.tab.c" + +#ifndef YYSTYPE +typedef int YYSTYPE; +#endif + +/* compatibility with bison */ +#ifdef YYPARSE_PARAM +/* compatibility with FreeBSD */ +# ifdef YYPARSE_PARAM_TYPE +# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) +# else +# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#endif + +/* Parameters sent to lex. */ +#ifdef YYLEX_PARAM +# define YYLEX_DECL() yylex(void *YYLEX_PARAM) +# define YYLEX yylex(YYLEX_PARAM) +#else +# define YYLEX_DECL() yylex(void) +# define YYLEX yylex() +#endif + +/* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL +#define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL +#define YYERROR_CALL(msg) yyerror(msg) +#endif + +extern int YYPARSE_DECL(); + +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 +#define YYERRCODE 256 +static const short calc_lhs[] = { -1, + 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, +}; +static const short calc_len[] = { 2, + 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 1, 1, 1, 2, +}; +static const short calc_defred[] = { 1, + 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, + 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, + 10, 11, +}; +static const short calc_dgoto[] = { 1, + 7, 8, 9, +}; +static const short calc_sindex[] = { 0, + -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, + -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, + -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, + 0, 0, +}; +static const short calc_rindex[] = { 0, + 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, + 0, 0, +}; +static const short calc_gindex[] = { 0, + 0, 65, 0, +}; +#define YYTABLESIZE 220 +static const short calc_table[] = { 6, + 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, + 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, + 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, + 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, + 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, + 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, + 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, + 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, + 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, + 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, + 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, +}; +static const short calc_check[] = { 40, + 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, + 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, + -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, + -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, + -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, + 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, + -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, + 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, + 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, + -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, + -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, + -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, + -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, + -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 259 +#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? (YYMAXTOKEN + 1) : (a)) +#if YYDEBUG +static const char *yyname[] = { + +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"DIGIT","LETTER","UMINUS","illegal-symbol", +}; +static const char *yyrule[] = { +"$accept : list", +"list :", +"list : list stat '\\n'", +"list : list error '\\n'", +"stat : expr", +"stat : LETTER '=' expr", +"expr : '(' expr ')'", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : expr '&' expr", +"expr : expr '|' expr", +"expr : '-' expr", +"expr : LETTER", +"expr : number", +"number : DIGIT", +"number : number DIGIT", + +}; +#endif + +int yydebug; +int yynerrs; + +int yyerrflag; +int yychar; +YYSTYPE yyval; +YYSTYPE yylval; + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif + +#define YYINITSTACKSIZE 200 + +typedef struct { + unsigned stacksize; + short *s_base; + short *s_mark; + short *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; +/* variables for the parser stack */ +static YYSTACKDATA yystack; +#line 66 "calc.y" + /* start of programs */ + +int +main (void) +{ + while(!feof(stdin)) { + yyparse(); + } + return 0; +} + +static void +yyerror(const char *s) +{ + fprintf(stderr, "%s\n", s); +} + +int +yylex(void) +{ + /* lexical analysis routine */ + /* returns LETTER for a lower case letter, yylval = 0 through 25 */ + /* return DIGIT for a digit, yylval = 0 through 9 */ + /* all other characters are returned immediately */ + + int c; + + while( (c=getchar()) == ' ' ) { /* skip blanks */ } + + /* c is now nonblank */ + + if( islower( c )) { + yylval = c - 'a'; + return ( LETTER ); + } + if( isdigit( c )) { + yylval = c - '0'; + return ( DIGIT ); + } + return( c ); +} +#line 347 "calc.tab.c" + +#if YYDEBUG +#include /* needed for printf */ +#endif + +#include /* needed for malloc, etc */ +#include /* needed for memset */ + +/* allocate initial stack or double stack size, up to YYMAXDEPTH */ +static int yygrowstack(YYSTACKDATA *data) +{ + int i; + unsigned newsize; + short *newss; + YYSTYPE *newvs; + + if ((newsize = data->stacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return -1; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = (int) (data->s_mark - data->s_base); + newss = (short *)realloc(data->s_base, newsize * sizeof(*newss)); + if (newss == 0) + return -1; + + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); + if (newvs == 0) + return -1; + + data->l_base = newvs; + data->l_mark = newvs + i; + + data->stacksize = newsize; + data->s_last = data->s_base + newsize - 1; + return 0; +} + +#if YYPURE || defined(YY_NO_LEAKS) +static void yyfreestack(YYSTACKDATA *data) +{ + free(data->s_base); + free(data->l_base); + memset(data, 0, sizeof(*data)); +} +#else +#define yyfreestack(data) /* nothing */ +#endif + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab + +int +YYPARSE_DECL() +{ + int yym, yyn, yystate; +#if YYDEBUG + const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + if ((yychar = YYLEX) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + { + goto yyoverflow; + } + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + yyerror("syntax error"); + + goto yyerrlab; + +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + { + goto yyoverflow; + } + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 609 "calc.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + if ((yychar = YYLEX) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = yyname[YYTRANSLATE(yychar)]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) + { + goto yyoverflow; + } + *++yystack.s_mark = (short) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + yyerror("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/calc_code_all.y b/contrib/byacc/test/calc_code_all.y new file mode 100644 index 000000000000..5924877f158e --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/calc_code_default.y b/contrib/byacc/test/calc_code_default.y new file mode 100644 index 000000000000..a0829affbe3d --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/calc_code_imports.y b/contrib/byacc/test/calc_code_imports.y new file mode 100644 index 000000000000..ded30926f7b3 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/calc_code_provides.y b/contrib/byacc/test/calc_code_provides.y new file mode 100644 index 000000000000..53776928dcda --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/calc_code_requires.y b/contrib/byacc/test/calc_code_requires.y new file mode 100644 index 000000000000..5254bcbd6de0 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/calc_code_top.y b/contrib/byacc/test/calc_code_top.y new file mode 100644 index 000000000000..8520791e4def --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/grammar.y b/contrib/byacc/test/grammar.y index 675552268370..c4c8fd580930 100644 --- a/contrib/byacc/test/grammar.y +++ b/contrib/byacc/test/grammar.y @@ -1,4 +1,4 @@ -/* $Id: grammar.y,v 1.5 2012/01/15 20:00:59 tom Exp $ +/* $Id: grammar.y,v 1.7 2020/03/30 23:55:49 tom Exp $ * * yacc grammar for C function prototype generator * This was derived from the grammar in Appendix A of @@ -94,6 +94,7 @@ static void yyerror(const char *s); /* #include "cproto.h" */ #define MAX_TEXT_SIZE 1024 +#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3) /* Prototype styles */ #if OPT_LINTLIBRARY @@ -679,19 +680,19 @@ struct_or_union_specifier { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%s %s", $1.text, $2.text); + (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, $1.text, TEXT_LEN, $2.text); new_decl_spec(&$$, s, $1.begin, DS_NONE); } | struct_or_union braces { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%s {}", $1.text); + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, $1.text); new_decl_spec(&$$, s, $1.begin, DS_NONE); } | struct_or_union any_id { - (void)sprintf(buf, "%s %s", $1.text, $2.text); + (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, $1.text, TEXT_LEN, $2.text); new_decl_spec(&$$, buf, $1.begin, DS_NONE); } ; @@ -744,19 +745,19 @@ enum_specifier { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "enum %s", $2.text); + (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, $2.text); new_decl_spec(&$$, s, $1.begin, DS_NONE); } | enumeration braces { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%s {}", $1.text); + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, $1.text); new_decl_spec(&$$, s, $1.begin, DS_NONE); } | enumeration any_id { - (void)sprintf(buf, "enum %s", $2.text); + (void)sprintf(buf, "enum %.*s", TEXT_LEN, $2.text); new_decl_spec(&$$, buf, $1.begin, DS_NONE); } ; @@ -778,7 +779,7 @@ declarator : pointer direct_declarator { $$ = $2; - (void)sprintf(buf, "%s%s", $1.text, $$->text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $1.text, TEXT_LEN, $$->text); free($$->text); $$->text = xstrdup(buf); $$->begin = $1.begin; @@ -795,7 +796,7 @@ direct_declarator | '(' declarator ')' { $$ = $2; - (void)sprintf(buf, "(%s)", $$->text); + (void)sprintf(buf, "(%.*s)", TEXT_LEN, $$->text); free($$->text); $$->text = xstrdup(buf); $$->begin = $1.begin; @@ -803,7 +804,7 @@ direct_declarator | direct_declarator T_BRACKETS { $$ = $1; - (void)sprintf(buf, "%s%s", $$->text, $2.text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $$->text, TEXT_LEN, $2.text); free($$->text); $$->text = xstrdup(buf); } @@ -828,12 +829,12 @@ direct_declarator pointer : '*' opt_type_qualifiers { - (void)sprintf($$.text, "*%s", $2.text); + (void)sprintf($$.text, "*%.*s", TEXT_LEN, $2.text); $$.begin = $1.begin; } | '*' opt_type_qualifiers pointer { - (void)sprintf($$.text, "*%s%s", $2.text, $3.text); + (void)sprintf($$.text, "*%.*s%.*s", TEXT_LEN, $2.text, TEXT_LEN, $3.text); $$.begin = $1.begin; } ; @@ -856,7 +857,7 @@ type_qualifier_list } | type_qualifier_list type_qualifier { - (void)sprintf($$.text, "%s%s ", $1.text, $2.text); + (void)sprintf($$.text, "%.*s%.*s ", TEXT_LEN, $1.text, TEXT_LEN, $2.text); $$.begin = $1.begin; free($2.text); } @@ -931,7 +932,7 @@ identifier_or_ref $$ = $2; } else #endif - (void)sprintf($$.text, "&%s", $2.text); + (void)sprintf($$.text, "&%.*s", TEXT_LEN, $2.text); $$.begin = $1.begin; } ; @@ -944,7 +945,7 @@ abs_declarator | pointer direct_abs_declarator { $$ = $2; - (void)sprintf(buf, "%s%s", $1.text, $$->text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $1.text, TEXT_LEN, $$->text); free($$->text); $$->text = xstrdup(buf); $$->begin = $1.begin; @@ -956,7 +957,7 @@ direct_abs_declarator : '(' abs_declarator ')' { $$ = $2; - (void)sprintf(buf, "(%s)", $$->text); + (void)sprintf(buf, "(%.*s)", TEXT_LEN, $$->text); free($$->text); $$->text = xstrdup(buf); $$->begin = $1.begin; @@ -964,7 +965,7 @@ direct_abs_declarator | direct_abs_declarator T_BRACKETS { $$ = $1; - (void)sprintf(buf, "%s%s", $$->text, $2.text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, $$->text, TEXT_LEN, $2.text); free($$->text); $$->text = xstrdup(buf); } @@ -1027,7 +1028,7 @@ extern char *yytext; extern FILE *yyin, *yyout; static int curly; /* number of curly brace nesting levels */ -static int ly_count; /* number of occurances of %% */ +static int ly_count; /* number of occurrences of %% */ static int inc_depth; /* include nesting level */ static SymbolTable *included_files; /* files already included */ static int yy_start = 0; /* start state number */ diff --git a/contrib/byacc/test/run_make.sh b/contrib/byacc/test/run_make.sh index 3035eb4274e6..77cf633fa9aa 100755 --- a/contrib/byacc/test/run_make.sh +++ b/contrib/byacc/test/run_make.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: run_make.sh,v 1.15 2016/06/01 22:56:37 Tom.Shields Exp $ +# $Id: run_make.sh,v 1.18 2019/11/25 23:23:26 tom Exp $ # vi:ts=4 sw=4: # do a test-compile on each of the ".c" files in the test-directory @@ -97,7 +97,7 @@ then case $input in ${TEST_DIR}/pure_*) - if test -z `fgrep -l '%pure-parser' $input` + if test -z `fgrep -i -l '%pure-parser' $input` then echo "%pure-parser" >>run_make.y fi @@ -106,7 +106,14 @@ then sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y - bison -Wno-other -Wno-conflicts-sr -Wconflicts-rr -y run_make.y + case $BISON in + [3-9].[0-9]*.[0-9]*) + bison -Wno-other -Wno-conflicts-sr -Wconflicts-rr -y -Wno-yacc run_make.y + ;; + *) + bison -y run_make.y + ;; + esac if test -f "y.tab.c" then sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c @@ -151,9 +158,10 @@ then continue; ;; *) - if fgrep '%pure-parser' $input >/dev/null || - fgrep '%parse-param' $input >/dev/null || - fgrep '%lex-param' $input >/dev/null || + if fgrep -i '%pure-parser' $input >/dev/null || + fgrep -i '%parse-param' $input >/dev/null || + fgrep -i '%lex-param' $input >/dev/null || + fgrep -i '%token-table' $input >/dev/null || fgrep 'YYLEX_PARAM' $input >/dev/null then echo "... skipping $input" diff --git a/contrib/byacc/test/run_test.sh b/contrib/byacc/test/run_test.sh index 22ac61dc9ca9..908a7d0f7a9a 100755 --- a/contrib/byacc/test/run_test.sh +++ b/contrib/byacc/test/run_test.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: run_test.sh,v 1.24 2014/07/15 19:21:10 tom Exp $ +# $Id: run_test.sh,v 1.31 2019/11/03 23:44:07 tom Exp $ # vi:ts=4 sw=4: errors=0 @@ -17,6 +17,9 @@ test_diffs() { else sed -e s,$NEW,$REF, \ -e "s%$YACC_escaped%YACC%" \ + -e "s%^yacc\>%YACC%" \ + -e "s%YACC:.*option.*$%YACC: error message%" \ + -e "s%^Usage: yacc\>%Usage: YACC%" \ -e '/YYPATCH/s/[0-9][0-9]*/"yyyymmdd"/' \ -e '/#define YYPATCH/s/PATCH/CHECK/' \ -e 's,#line \([1-9][0-9]*\) "'$REF_DIR'/,#line \1 ",' \ @@ -45,8 +48,7 @@ test_flags() { root=$1 ROOT=test-$root shift 1 - $YACC $* >$ROOT.output \ - 2>&1 >$ROOT.error + $YACC "$@" >$ROOT.output 2>$ROOT.error for type in .output .error do NEW=$ROOT$type @@ -55,6 +57,58 @@ test_flags() { done } +test_stdin() { + echo "** testing stdin $*" + root=$1 + ROOT=test-$root + shift 1 + opts="$1" + shift 1 + code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"` + if test "x$opts" = "x-" + then + $YACC -o $ROOT.$code $opts <$1 >$ROOT.output 2>$ROOT.error + else + $YACC -o $ROOT.$code $opts $1 >$ROOT.output 2>$ROOT.error + fi + for type in .output .error .$code + do + NEW=$ROOT$type + REF=$REF_DIR/$root$type + test_diffs + done +} + +test_defines() { + echo "** testing defines $*" + root=$1 + ROOT=test-$root + shift 1 + opts= + while test $# != 1 + do + opts="$opts $1" + shift 1 + done + head=`echo "$1"|sed -e 's/y$/h/' -e "s,${TEST_DIR}/,,"` + code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"` + $YACC $opts -H $ROOT.$head $1 >$ROOT.output 2>$ROOT.error + for name in prefix.tab.c y.tab.c + do + if test -f $name + then + mv $name $ROOT.$code + break + fi + done + for name in .output .error .$head .$code + do + NEW=$ROOT$name + REF=$REF_DIR/$root$name + test_diffs + done +} + if test $# = 1 then PROG_DIR=`pwd` @@ -138,6 +192,14 @@ rm -f $MYFILE.code.c rm -f $MYFILE.* +# Test special cases +test_stdin stdin1 - ${TEST_DIR}/calc.y +test_stdin stdin2 -- ${TEST_DIR}/calc.y + +test_defines defines1 ${TEST_DIR}/calc.y +test_defines defines2 -d ${TEST_DIR}/calc.y +test_defines defines3 -b prefix ${TEST_DIR}/calc.y + for input in ${TEST_DIR}/*.y do case $input in diff --git a/contrib/byacc/test/yacc/big_b.error b/contrib/byacc/test/yacc/big_b.error index e69de29bb2d1..7019fded376d 100644 --- a/contrib/byacc/test/yacc/big_b.error +++ b/contrib/byacc/test/yacc/big_b.error @@ -0,0 +1,20 @@ +YACC: w - -B flag unsupported, reconfigure with --enable-btyacc +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/yacc/big_b.output b/contrib/byacc/test/yacc/big_b.output index c98de14b4ad0..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/big_b.output +++ b/contrib/byacc/test/yacc/big_b.output @@ -1,19 +0,0 @@ -YACC: w - -B flag unsupported, reconfigure with --enable-btyacc -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/yacc/big_l.error b/contrib/byacc/test/yacc/big_l.error index e69de29bb2d1..be9f02a84acb 100644 --- a/contrib/byacc/test/yacc/big_l.error +++ b/contrib/byacc/test/yacc/big_l.error @@ -0,0 +1,20 @@ +YACC: w - -L flag unsupported, reconfigure with --enable-btyacc +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/yacc/big_l.output b/contrib/byacc/test/yacc/big_l.output index a39dc34b2d5a..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/big_l.output +++ b/contrib/byacc/test/yacc/big_l.output @@ -1,19 +0,0 @@ -YACC: w - -L flag unsupported, reconfigure with --enable-btyacc -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/yacc/calc.tab.c b/contrib/byacc/test/yacc/calc.tab.c index 4b8fb4c08dec..db205fd46282 100644 --- a/contrib/byacc/test/yacc/calc.tab.c +++ b/contrib/byacc/test/yacc/calc.tab.c @@ -275,13 +275,15 @@ static const char *const calc_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -350,7 +352,7 @@ yylex(void) } return( c ); } -#line 354 "calc.tab.c" +#line 356 "calc.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -609,7 +611,7 @@ case 18: #line 63 "calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 613 "calc.tab.c" +#line 615 "calc.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/calc1.tab.c b/contrib/byacc/test/yacc/calc1.tab.c index fac1c277ac47..6506240019ac 100644 --- a/contrib/byacc/test/yacc/calc1.tab.c +++ b/contrib/byacc/test/yacc/calc1.tab.c @@ -323,13 +323,15 @@ static const char *const calc1_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -487,7 +489,7 @@ vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } -#line 491 "calc1.tab.c" +#line 493 "calc1.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -849,7 +851,7 @@ case 28: yyval.vval = yystack.l_mark[-1].vval; } break; -#line 853 "calc1.tab.c" +#line 855 "calc1.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/calc2.tab.c b/contrib/byacc/test/yacc/calc2.tab.c index ba80946f5ce2..465575eeceb4 100644 --- a/contrib/byacc/test/yacc/calc2.tab.c +++ b/contrib/byacc/test/yacc/calc2.tab.c @@ -277,13 +277,15 @@ static const char *const calc2_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -363,7 +365,7 @@ YYLEX_DECL() } return( c ); } -#line 367 "calc2.tab.c" +#line 369 "calc2.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -622,7 +624,7 @@ case 18: #line 70 "calc2.y" { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 626 "calc2.tab.c" +#line 628 "calc2.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/calc3.tab.c b/contrib/byacc/test/yacc/calc3.tab.c index 2ef0539c063a..3843e6f50bdf 100644 --- a/contrib/byacc/test/yacc/calc3.tab.c +++ b/contrib/byacc/test/yacc/calc3.tab.c @@ -282,8 +282,9 @@ static const char *const calc3_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -361,7 +362,7 @@ YYLEX_DECL() } return( c ); } -#line 365 "calc3.tab.c" +#line 366 "calc3.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -428,6 +429,7 @@ YYPARSE_DECL() int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; /* variables for the parser stack */ YYSTACKDATA yystack; @@ -630,7 +632,7 @@ case 18: #line 73 "calc3.y" { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 634 "calc3.tab.c" +#line 636 "calc3.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/calc_code_all.error b/contrib/byacc/test/yacc/calc_code_all.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/calc_code_all.output b/contrib/byacc/test/yacc/calc_code_all.output new file mode 100644 index 000000000000..3aed47511c93 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/yacc/calc_code_all.tab.c b/contrib/byacc/test/yacc/calc_code_all.tab.c new file mode 100644 index 000000000000..f6b624afb986 --- /dev/null +++ b/contrib/byacc/test/yacc/calc_code_all.tab.c @@ -0,0 +1,699 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +/* %code "top" block start */ +#line 5 "calc_code_all.y" +/* CODE-TOP */ +/* %code "top" block end */ +#line 22 "calc_code_all.tab.c" + +#ifndef yyparse +#define yyparse calc_code_all_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_all_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_all_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_all_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_all_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_all_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_all_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_all_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_all_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_all_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_all_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_all_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_all_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_all_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_all_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_all_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_all_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_all_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_all_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_all_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_all_" + +#define YYPURE 0 + +#line 9 "calc_code_all.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 35 "calc_code_all.y" + { yyerrok ; } +break; +case 4: +#line 39 "calc_code_all.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 41 "calc_code_all.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 45 "calc_code_all.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 47 "calc_code_all.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 49 "calc_code_all.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 51 "calc_code_all.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 53 "calc_code_all.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 55 "calc_code_all.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 57 "calc_code_all.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 59 "calc_code_all.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 61 "calc_code_all.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 63 "calc_code_all.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 68 "calc_code_all.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 70 "calc_code_all.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 643 "calc_code_all.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/calc_code_all.tab.h b/contrib/byacc/test/yacc/calc_code_all.tab.h new file mode 100644 index 000000000000..7edd87c3e6c4 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/yacc/calc_code_default.error b/contrib/byacc/test/yacc/calc_code_default.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/calc_code_default.output b/contrib/byacc/test/yacc/calc_code_default.output new file mode 100644 index 000000000000..3aed47511c93 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/yacc/calc_code_default.tab.c b/contrib/byacc/test/yacc/calc_code_default.tab.c new file mode 100644 index 000000000000..5cdc0cedab08 --- /dev/null +++ b/contrib/byacc/test/yacc/calc_code_default.tab.c @@ -0,0 +1,679 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +#ifndef yyparse +#define yyparse calc_code_default_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_default_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_default_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_default_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_default_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_default_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_default_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_default_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_default_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_default_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_default_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_default_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_default_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_default_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_default_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_default_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_default_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_default_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_default_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_default_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_default_" + +#define YYPURE 0 + +#line 5 "calc_code_default.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_default.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_default.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_default.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_default.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_default.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_default.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_default.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_default.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_default.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_default.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_default.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_default.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_default.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_default.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_default.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 623 "calc_code_default.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/calc_code_default.tab.h b/contrib/byacc/test/yacc/calc_code_default.tab.h new file mode 100644 index 000000000000..19211182d6b3 --- /dev/null +++ b/contrib/byacc/test/yacc/calc_code_default.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/contrib/byacc/test/yacc/calc_code_imports.error b/contrib/byacc/test/yacc/calc_code_imports.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/calc_code_imports.output b/contrib/byacc/test/yacc/calc_code_imports.output new file mode 100644 index 000000000000..3aed47511c93 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/yacc/calc_code_imports.tab.c b/contrib/byacc/test/yacc/calc_code_imports.tab.c new file mode 100644 index 000000000000..c72f987627b6 --- /dev/null +++ b/contrib/byacc/test/yacc/calc_code_imports.tab.c @@ -0,0 +1,671 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +#ifndef yyparse +#define yyparse calc_code_imports_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_imports_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_imports_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_imports_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_imports_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_imports_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_imports_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_imports_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_imports_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_imports_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_imports_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_imports_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_imports_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_imports_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_imports_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_imports_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_imports_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_imports_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_imports_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_imports_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_imports_" + +#define YYPURE 0 + +#line 5 "calc_code_imports.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_imports.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_imports.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_imports.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_imports.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_imports.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_imports.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_imports.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_imports.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_imports.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 615 "calc_code_imports.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/calc_code_imports.tab.h b/contrib/byacc/test/yacc/calc_code_imports.tab.h new file mode 100644 index 000000000000..19211182d6b3 --- /dev/null +++ b/contrib/byacc/test/yacc/calc_code_imports.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/contrib/byacc/test/yacc/calc_code_provides.error b/contrib/byacc/test/yacc/calc_code_provides.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/calc_code_provides.output b/contrib/byacc/test/yacc/calc_code_provides.output new file mode 100644 index 000000000000..3aed47511c93 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/yacc/calc_code_provides.tab.c b/contrib/byacc/test/yacc/calc_code_provides.tab.c new file mode 100644 index 000000000000..2f8f45d1a345 --- /dev/null +++ b/contrib/byacc/test/yacc/calc_code_provides.tab.c @@ -0,0 +1,679 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +#ifndef yyparse +#define yyparse calc_code_provides_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_provides_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_provides_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_provides_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_provides_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_provides_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_provides_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_provides_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_provides_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_provides_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_provides_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_provides_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_provides_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_provides_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_provides_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_provides_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_provides_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_provides_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_provides_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_provides_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_provides_" + +#define YYPURE 0 + +#line 5 "calc_code_provides.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_provides.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_provides.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_provides.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_provides.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_provides.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_provides.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_provides.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_provides.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_provides.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 623 "calc_code_provides.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/calc_code_provides.tab.h b/contrib/byacc/test/yacc/calc_code_provides.tab.h new file mode 100644 index 000000000000..a7004790d1f4 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/yacc/calc_code_requires.error b/contrib/byacc/test/yacc/calc_code_requires.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/calc_code_requires.output b/contrib/byacc/test/yacc/calc_code_requires.output new file mode 100644 index 000000000000..3aed47511c93 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/yacc/calc_code_requires.tab.c b/contrib/byacc/test/yacc/calc_code_requires.tab.c new file mode 100644 index 000000000000..ad8aea1707fd --- /dev/null +++ b/contrib/byacc/test/yacc/calc_code_requires.tab.c @@ -0,0 +1,679 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +#ifndef yyparse +#define yyparse calc_code_requires_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_requires_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_requires_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_requires_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_requires_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_requires_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_requires_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_requires_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_requires_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_requires_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_requires_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_requires_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_requires_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_requires_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_requires_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_requires_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_requires_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_requires_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_requires_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_requires_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_requires_" + +#define YYPURE 0 + +#line 5 "calc_code_requires.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_requires.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_requires.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_requires.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_requires.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_requires.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_requires.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_requires.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_requires.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_requires.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 623 "calc_code_requires.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/calc_code_requires.tab.h b/contrib/byacc/test/yacc/calc_code_requires.tab.h new file mode 100644 index 000000000000..b734c8358f5a --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/yacc/calc_code_top.error b/contrib/byacc/test/yacc/calc_code_top.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/calc_code_top.output b/contrib/byacc/test/yacc/calc_code_top.output new file mode 100644 index 000000000000..3aed47511c93 --- /dev/null +++ b/contrib/byacc/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/contrib/byacc/test/yacc/calc_code_top.tab.c b/contrib/byacc/test/yacc/calc_code_top.tab.c new file mode 100644 index 000000000000..5370f8a98bcf --- /dev/null +++ b/contrib/byacc/test/yacc/calc_code_top.tab.c @@ -0,0 +1,679 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 + +/* %code "top" block start */ +#line 1 "calc_code_top.y" +/* CODE-TOP */ +#line 2 "calc_code_top.y" +/* CODE-TOP2 */ +/* %code "top" block end */ +#line 24 "calc_code_top.tab.c" + +#ifndef yyparse +#define yyparse calc_code_top_parse +#endif /* yyparse */ + +#ifndef yylex +#define yylex calc_code_top_lex +#endif /* yylex */ + +#ifndef yyerror +#define yyerror calc_code_top_error +#endif /* yyerror */ + +#ifndef yychar +#define yychar calc_code_top_char +#endif /* yychar */ + +#ifndef yyval +#define yyval calc_code_top_val +#endif /* yyval */ + +#ifndef yylval +#define yylval calc_code_top_lval +#endif /* yylval */ + +#ifndef yydebug +#define yydebug calc_code_top_debug +#endif /* yydebug */ + +#ifndef yynerrs +#define yynerrs calc_code_top_nerrs +#endif /* yynerrs */ + +#ifndef yyerrflag +#define yyerrflag calc_code_top_errflag +#endif /* yyerrflag */ + +#ifndef yylhs +#define yylhs calc_code_top_lhs +#endif /* yylhs */ + +#ifndef yylen +#define yylen calc_code_top_len +#endif /* yylen */ + +#ifndef yydefred +#define yydefred calc_code_top_defred +#endif /* yydefred */ + +#ifndef yydgoto +#define yydgoto calc_code_top_dgoto +#endif /* yydgoto */ + +#ifndef yysindex +#define yysindex calc_code_top_sindex +#endif /* yysindex */ + +#ifndef yyrindex +#define yyrindex calc_code_top_rindex +#endif /* yyrindex */ + +#ifndef yygindex +#define yygindex calc_code_top_gindex +#endif /* yygindex */ + +#ifndef yytable +#define yytable calc_code_top_table +#endif /* yytable */ + +#ifndef yycheck +#define yycheck calc_code_top_check +#endif /* yycheck */ + +#ifndef yyname +#define yyname calc_code_top_name +#endif /* yyname */ + +#ifndef yyrule +#define yyrule calc_code_top_rule +#endif /* yyrule */ +#define YYPREFIX "calc_code_top_" + +#define YYPURE 0 + +#line 5 "calc_code_top.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 31 "calc_code_top.y" + { yyerrok ; } +break; +case 4: +#line 35 "calc_code_top.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 37 "calc_code_top.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 41 "calc_code_top.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 43 "calc_code_top.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 45 "calc_code_top.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 47 "calc_code_top.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 49 "calc_code_top.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 51 "calc_code_top.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 53 "calc_code_top.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 55 "calc_code_top.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 57 "calc_code_top.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 59 "calc_code_top.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 64 "calc_code_top.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 66 "calc_code_top.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 623 "calc_code_top.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/calc_code_top.tab.h b/contrib/byacc/test/yacc/calc_code_top.tab.h new file mode 100644 index 000000000000..19211182d6b3 --- /dev/null +++ b/contrib/byacc/test/yacc/calc_code_top.tab.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/contrib/byacc/test/yacc/code_calc.code.c b/contrib/byacc/test/yacc/code_calc.code.c index 9d1cb6a28c14..94ad71977a9f 100644 --- a/contrib/byacc/test/yacc/code_calc.code.c +++ b/contrib/byacc/test/yacc/code_calc.code.c @@ -180,13 +180,15 @@ extern char *yyname[]; extern char *yyrule[]; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -259,7 +261,7 @@ yylex(void) } return( c ); } -#line 263 "code_calc.code.c" +#line 265 "code_calc.code.c" #if YYDEBUG #include /* needed for printf */ @@ -518,7 +520,7 @@ case 18: #line 67 "code_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 522 "code_calc.code.c" +#line 524 "code_calc.code.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/code_error.code.c b/contrib/byacc/test/yacc/code_error.code.c index 379bf2f50abe..f8b0ac27bd11 100644 --- a/contrib/byacc/test/yacc/code_error.code.c +++ b/contrib/byacc/test/yacc/code_error.code.c @@ -170,13 +170,15 @@ extern char *yyname[]; extern char *yyrule[]; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -229,7 +231,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 233 "code_error.code.c" +#line 235 "code_error.code.c" #if YYDEBUG #include /* needed for printf */ diff --git a/contrib/byacc/test/yacc/defines1.calc.c b/contrib/byacc/test/yacc/defines1.calc.c new file mode 100644 index 000000000000..8245480d345a --- /dev/null +++ b/contrib/byacc/test/yacc/defines1.calc.c @@ -0,0 +1,595 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 539 "y.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/defines1.calc.h b/contrib/byacc/test/yacc/defines1.calc.h new file mode 100644 index 000000000000..19211182d6b3 --- /dev/null +++ b/contrib/byacc/test/yacc/defines1.calc.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/contrib/byacc/test/yacc/defines1.error b/contrib/byacc/test/yacc/defines1.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/defines1.output b/contrib/byacc/test/yacc/defines1.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/defines2.calc.c b/contrib/byacc/test/yacc/defines2.calc.c new file mode 100644 index 000000000000..8245480d345a --- /dev/null +++ b/contrib/byacc/test/yacc/defines2.calc.c @@ -0,0 +1,595 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 539 "y.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/defines2.calc.h b/contrib/byacc/test/yacc/defines2.calc.h new file mode 100644 index 000000000000..19211182d6b3 --- /dev/null +++ b/contrib/byacc/test/yacc/defines2.calc.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/contrib/byacc/test/yacc/defines2.error b/contrib/byacc/test/yacc/defines2.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/defines2.output b/contrib/byacc/test/yacc/defines2.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/defines3.calc.c b/contrib/byacc/test/yacc/defines3.calc.c new file mode 100644 index 000000000000..2a3f1cafdf1d --- /dev/null +++ b/contrib/byacc/test/yacc/defines3.calc.c @@ -0,0 +1,595 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 539 "prefix.tab.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/defines3.calc.h b/contrib/byacc/test/yacc/defines3.calc.h new file mode 100644 index 000000000000..19211182d6b3 --- /dev/null +++ b/contrib/byacc/test/yacc/defines3.calc.h @@ -0,0 +1,3 @@ +#define DIGIT 257 +#define LETTER 258 +#define UMINUS 259 diff --git a/contrib/byacc/test/yacc/defines3.error b/contrib/byacc/test/yacc/defines3.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/defines3.output b/contrib/byacc/test/yacc/defines3.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/empty.tab.c b/contrib/byacc/test/yacc/empty.tab.c index 17275226c25d..67608d600913 100644 --- a/contrib/byacc/test/yacc/empty.tab.c +++ b/contrib/byacc/test/yacc/empty.tab.c @@ -194,13 +194,15 @@ static const char *const empty_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -240,7 +242,7 @@ static void YYERROR_DECL() { printf("%s\n",s); } -#line 244 "empty.tab.c" +#line 246 "empty.tab.c" #if YYDEBUG #include /* needed for printf */ diff --git a/contrib/byacc/test/yacc/err_syntax10.tab.c b/contrib/byacc/test/yacc/err_syntax10.tab.c index 8a1d6395d0e8..9d309b9b25e3 100644 --- a/contrib/byacc/test/yacc/err_syntax10.tab.c +++ b/contrib/byacc/test/yacc/err_syntax10.tab.c @@ -184,13 +184,15 @@ static const char *const err_syntax10_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -239,7 +241,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 243 "err_syntax10.tab.c" +#line 245 "err_syntax10.tab.c" #if YYDEBUG #include /* needed for printf */ diff --git a/contrib/byacc/test/yacc/err_syntax11.tab.c b/contrib/byacc/test/yacc/err_syntax11.tab.c index 1a64f8624dd6..b040573f892c 100644 --- a/contrib/byacc/test/yacc/err_syntax11.tab.c +++ b/contrib/byacc/test/yacc/err_syntax11.tab.c @@ -190,13 +190,15 @@ static const char *const err_syntax11_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -245,7 +247,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 249 "err_syntax11.tab.c" +#line 251 "err_syntax11.tab.c" #if YYDEBUG #include /* needed for printf */ diff --git a/contrib/byacc/test/yacc/err_syntax12.tab.c b/contrib/byacc/test/yacc/err_syntax12.tab.c index 6b443a0587b5..7dd742e7f374 100644 --- a/contrib/byacc/test/yacc/err_syntax12.tab.c +++ b/contrib/byacc/test/yacc/err_syntax12.tab.c @@ -196,13 +196,15 @@ static const char *const err_syntax12_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -251,7 +253,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 255 "err_syntax12.tab.c" +#line 257 "err_syntax12.tab.c" #if YYDEBUG #include /* needed for printf */ diff --git a/contrib/byacc/test/yacc/err_syntax18.tab.c b/contrib/byacc/test/yacc/err_syntax18.tab.c index 416acf028458..92309c1cd433 100644 --- a/contrib/byacc/test/yacc/err_syntax18.tab.c +++ b/contrib/byacc/test/yacc/err_syntax18.tab.c @@ -192,13 +192,15 @@ static const char *const err_syntax18_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -247,7 +249,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 251 "err_syntax18.tab.c" +#line 253 "err_syntax18.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -450,7 +452,7 @@ case 1: #line 9 "err_syntax18.y" { yyval = yystack.l_mark[1]; } break; -#line 454 "err_syntax18.tab.c" +#line 456 "err_syntax18.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/err_syntax20.tab.c b/contrib/byacc/test/yacc/err_syntax20.tab.c index 2c5b59039d0a..562e254a66e8 100644 --- a/contrib/byacc/test/yacc/err_syntax20.tab.c +++ b/contrib/byacc/test/yacc/err_syntax20.tab.c @@ -188,13 +188,15 @@ static const char *const err_syntax20_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -243,7 +245,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 247 "err_syntax20.tab.c" +#line 249 "err_syntax20.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -446,7 +448,7 @@ case 1: #line 12 "err_syntax20.y" { yystack.l_mark[-1].rechk = 3; } break; -#line 450 "err_syntax20.tab.c" +#line 452 "err_syntax20.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/error.tab.c b/contrib/byacc/test/yacc/error.tab.c index f06f181d4be4..c9e9406e7dc6 100644 --- a/contrib/byacc/test/yacc/error.tab.c +++ b/contrib/byacc/test/yacc/error.tab.c @@ -190,13 +190,15 @@ static const char *const error_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -245,7 +247,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 249 "error.tab.c" +#line 251 "error.tab.c" #if YYDEBUG #include /* needed for printf */ diff --git a/contrib/byacc/test/yacc/expr.oxout.tab.c b/contrib/byacc/test/yacc/expr.oxout.tab.c index fb16527c849b..52cf17d008b4 100644 --- a/contrib/byacc/test/yacc/expr.oxout.tab.c +++ b/contrib/byacc/test/yacc/expr.oxout.tab.c @@ -287,13 +287,15 @@ static const char *const expr.oxout_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -1641,7 +1643,7 @@ void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) -#line 1645 "expr.oxout.tab.c" +#line 1647 "expr.oxout.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -1898,7 +1900,7 @@ case 10: yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} break; -#line 1902 "expr.oxout.tab.c" +#line 1904 "expr.oxout.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/grammar.tab.c b/contrib/byacc/test/yacc/grammar.tab.c index 2af38b678979..e7587cb74522 100644 --- a/contrib/byacc/test/yacc/grammar.tab.c +++ b/contrib/byacc/test/yacc/grammar.tab.c @@ -124,6 +124,7 @@ static void yyerror(const char *s); /* #include "cproto.h" */ #define MAX_TEXT_SIZE 1024 +#define TEXT_LEN (MAX_TEXT_SIZE / 2 - 3) /* Prototype styles */ #if OPT_LINTLIBRARY @@ -384,7 +385,7 @@ haveAnsiParam (void) } return FALSE; } -#line 388 "grammar.tab.c" +#line 389 "grammar.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM @@ -884,13 +885,15 @@ static const char *const grammar_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -917,7 +920,7 @@ typedef struct { } YYSTACKDATA; /* variables for the parser stack */ static YYSTACKDATA yystack; -#line 1014 "grammar.y" +#line 1015 "grammar.y" /* lex.yy.c */ #define BEGIN yy_start = 1 + 2 * @@ -934,7 +937,7 @@ extern char *yytext; extern FILE *yyin, *yyout; static int curly; /* number of curly brace nesting levels */ -static int ly_count; /* number of occurances of %% */ +static int ly_count; /* number of occurrences of %% */ static int inc_depth; /* include nesting level */ static SymbolTable *included_files; /* files already included */ static int yy_start = 0; /* start state number */ @@ -1088,7 +1091,7 @@ free_parser(void) #endif } #endif -#line 1092 "grammar.tab.c" +#line 1095 "grammar.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -1288,19 +1291,19 @@ YYPARSE_DECL() switch (yyn) { case 10: -#line 377 "grammar.y" +#line 378 "grammar.y" { yyerrok; } break; case 11: -#line 381 "grammar.y" +#line 382 "grammar.y" { yyerrok; } break; case 13: -#line 392 "grammar.y" +#line 393 "grammar.y" { /* Provide an empty action here so bison will not complain about * incompatible types in the default action it normally would @@ -1309,13 +1312,13 @@ case 13: } break; case 14: -#line 399 "grammar.y" +#line 400 "grammar.y" { /* empty */ } break; case 15: -#line 406 "grammar.y" +#line 407 "grammar.y" { #if OPT_LINTLIBRARY if (types_out && want_typedef()) { @@ -1328,7 +1331,7 @@ case 15: } break; case 16: -#line 417 "grammar.y" +#line 418 "grammar.y" { if (func_params != NULL) { set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list); @@ -1344,32 +1347,32 @@ case 16: } break; case 17: -#line 431 "grammar.y" +#line 432 "grammar.y" { cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags; free_decl_spec(&yystack.l_mark[0].decl_spec); } break; case 18: -#line 436 "grammar.y" +#line 437 "grammar.y" { end_typedef(); } break; case 19: -#line 443 "grammar.y" +#line 444 "grammar.y" { begin_typedef(); } break; case 20: -#line 447 "grammar.y" +#line 448 "grammar.y" { begin_typedef(); } break; case 23: -#line 459 "grammar.y" +#line 460 "grammar.y" { int flags = cur_decl_spec_flags; @@ -1383,7 +1386,7 @@ case 23: } break; case 24: -#line 471 "grammar.y" +#line 472 "grammar.y" { int flags = cur_decl_spec_flags; @@ -1394,7 +1397,7 @@ case 24: } break; case 25: -#line 483 "grammar.y" +#line 484 "grammar.y" { check_untagged(&yystack.l_mark[-1].decl_spec); if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) { @@ -1407,7 +1410,7 @@ case 25: } break; case 26: -#line 494 "grammar.y" +#line 495 "grammar.y" { /* If we're converting to K&R and we've got a nominally K&R * function which has a parameter which is ANSI (i.e., a prototyped @@ -1433,7 +1436,7 @@ case 26: } break; case 28: -#line 519 "grammar.y" +#line 520 "grammar.y" { if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) { yyerror("syntax error"); @@ -1445,7 +1448,7 @@ case 28: } break; case 29: -#line 529 "grammar.y" +#line 530 "grammar.y" { DeclSpec decl_spec; @@ -1463,7 +1466,7 @@ case 29: } break; case 36: -#line 560 "grammar.y" +#line 561 "grammar.y" { join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec); free(yystack.l_mark[-1].decl_spec.text); @@ -1471,115 +1474,115 @@ case 36: } break; case 40: -#line 575 "grammar.y" +#line 576 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 41: -#line 579 "grammar.y" +#line 580 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN); } break; case 42: -#line 583 "grammar.y" +#line 584 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 43: -#line 587 "grammar.y" +#line 588 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC); } break; case 44: -#line 591 "grammar.y" +#line 592 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE); } break; case 45: -#line 595 "grammar.y" +#line 596 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK); } break; case 46: -#line 602 "grammar.y" +#line 603 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); } break; case 47: -#line 606 "grammar.y" +#line 607 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 48: -#line 610 "grammar.y" +#line 611 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT); } break; case 49: -#line 614 "grammar.y" +#line 615 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 50: -#line 618 "grammar.y" +#line 619 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 51: -#line 622 "grammar.y" +#line 623 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT); } break; case 52: -#line 626 "grammar.y" +#line 627 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 53: -#line 630 "grammar.y" +#line 631 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 54: -#line 634 "grammar.y" +#line 635 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 55: -#line 638 "grammar.y" +#line 639 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR); } break; case 56: -#line 642 "grammar.y" +#line 643 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 57: -#line 646 "grammar.y" +#line 647 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 58: -#line 650 "grammar.y" +#line 651 "grammar.y" { Symbol *s; s = find_symbol(typedef_names, yystack.l_mark[0].text.text); @@ -1588,13 +1591,13 @@ case 58: } break; case 61: -#line 662 "grammar.y" +#line 663 "grammar.y" { new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE); } break; case 62: -#line 666 "grammar.y" +#line 667 "grammar.y" { /* This rule allows the nonterminal to scan #define * names as if they were type modifiers. @@ -1606,56 +1609,56 @@ case 62: } break; case 63: -#line 679 "grammar.y" +#line 680 "grammar.y" { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text); + (void)sprintf(s = buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-2].text.text, TEXT_LEN, yystack.l_mark[-1].text.text); new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); } break; case 64: -#line 686 "grammar.y" +#line 687 "grammar.y" { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text); + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); } break; case 65: -#line 693 "grammar.y" +#line 694 "grammar.y" { - (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text); + (void)sprintf(buf, "%.*s %.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); } break; case 66: -#line 701 "grammar.y" +#line 702 "grammar.y" { imply_typedef(yyval.text.text); } break; case 67: -#line 705 "grammar.y" +#line 706 "grammar.y" { imply_typedef(yyval.text.text); } break; case 68: -#line 712 "grammar.y" +#line 713 "grammar.y" { new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator); } break; case 69: -#line 716 "grammar.y" +#line 717 "grammar.y" { add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator); } break; case 70: -#line 723 "grammar.y" +#line 724 "grammar.y" { if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL && func_style == FUNC_TRADITIONAL && cur_file->convert) { @@ -1666,7 +1669,7 @@ case 70: } break; case 71: -#line 732 "grammar.y" +#line 733 "grammar.y" { if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL && func_style == FUNC_TRADITIONAL && cur_file->convert) { @@ -1676,42 +1679,42 @@ case 71: } break; case 73: -#line 744 "grammar.y" +#line 745 "grammar.y" { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text); + (void)sprintf(s = buf, "enum %.*s", TEXT_LEN, yystack.l_mark[-1].text.text); new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE); } break; case 74: -#line 751 "grammar.y" +#line 752 "grammar.y" { char *s; if ((s = implied_typedef()) == 0) - (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text); + (void)sprintf(s = buf, "%.*s {}", TEXT_LEN, yystack.l_mark[-1].text.text); new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE); } break; case 75: -#line 758 "grammar.y" +#line 759 "grammar.y" { - (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text); + (void)sprintf(buf, "enum %.*s", TEXT_LEN, yystack.l_mark[0].text.text); new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE); } break; case 76: -#line 766 "grammar.y" +#line 767 "grammar.y" { imply_typedef("enum"); yyval.text = yystack.l_mark[0].text; } break; case 79: -#line 779 "grammar.y" +#line 780 "grammar.y" { yyval.declarator = yystack.l_mark[0].declarator; - (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); yyval.declarator->begin = yystack.l_mark[-1].text.begin; @@ -1719,32 +1722,32 @@ case 79: } break; case 81: -#line 792 "grammar.y" +#line 793 "grammar.y" { yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin); } break; case 82: -#line 796 "grammar.y" +#line 797 "grammar.y" { yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "(%s)", yyval.declarator->text); + (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); yyval.declarator->begin = yystack.l_mark[-2].text.begin; } break; case 83: -#line 804 "grammar.y" +#line 805 "grammar.y" { yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); } break; case 84: -#line 811 "grammar.y" +#line 812 "grammar.y" { yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); yyval.declarator->params = yystack.l_mark[-1].param_list; @@ -1754,7 +1757,7 @@ case 84: } break; case 85: -#line 819 "grammar.y" +#line 820 "grammar.y" { yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin); yyval.declarator->params = yystack.l_mark[-1].param_list; @@ -1764,28 +1767,28 @@ case 85: } break; case 86: -#line 830 "grammar.y" +#line 831 "grammar.y" { - (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text); + (void)sprintf(yyval.text.text, "*%.*s", TEXT_LEN, yystack.l_mark[0].text.text); yyval.text.begin = yystack.l_mark[-1].text.begin; } break; case 87: -#line 835 "grammar.y" +#line 836 "grammar.y" { - (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text); + (void)sprintf(yyval.text.text, "*%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].text.text); yyval.text.begin = yystack.l_mark[-2].text.begin; } break; case 88: -#line 843 "grammar.y" +#line 844 "grammar.y" { strcpy(yyval.text.text, ""); yyval.text.begin = 0L; } break; case 90: -#line 852 "grammar.y" +#line 853 "grammar.y" { (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text); yyval.text.begin = yystack.l_mark[0].decl_spec.begin; @@ -1793,132 +1796,132 @@ case 90: } break; case 91: -#line 858 "grammar.y" +#line 859 "grammar.y" { - (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text); + (void)sprintf(yyval.text.text, "%.*s%.*s ", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yystack.l_mark[0].decl_spec.text); yyval.text.begin = yystack.l_mark[-1].text.begin; free(yystack.l_mark[0].decl_spec.text); } break; case 93: -#line 868 "grammar.y" +#line 869 "grammar.y" { add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "..."); } break; case 94: -#line 875 "grammar.y" +#line 876 "grammar.y" { new_param_list(&yyval.param_list, yystack.l_mark[0].parameter); } break; case 95: -#line 879 "grammar.y" +#line 880 "grammar.y" { add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter); } break; case 96: -#line 886 "grammar.y" +#line 887 "grammar.y" { check_untagged(&yystack.l_mark[-1].decl_spec); yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); } break; case 97: -#line 891 "grammar.y" +#line 892 "grammar.y" { check_untagged(&yystack.l_mark[-1].decl_spec); yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator); } break; case 98: -#line 896 "grammar.y" +#line 897 "grammar.y" { check_untagged(&yystack.l_mark[0].decl_spec); yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0); } break; case 99: -#line 904 "grammar.y" +#line 905 "grammar.y" { new_ident_list(&yyval.param_list); } break; case 101: -#line 912 "grammar.y" +#line 913 "grammar.y" { new_ident_list(&yyval.param_list); add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text); } break; case 102: -#line 917 "grammar.y" +#line 918 "grammar.y" { add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text); } break; case 103: -#line 924 "grammar.y" +#line 925 "grammar.y" { yyval.text = yystack.l_mark[0].text; } break; case 104: -#line 928 "grammar.y" +#line 929 "grammar.y" { #if OPT_LINTLIBRARY if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */ yyval.text = yystack.l_mark[0].text; } else #endif - (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text); + (void)sprintf(yyval.text.text, "&%.*s", TEXT_LEN, yystack.l_mark[0].text.text); yyval.text.begin = yystack.l_mark[-1].text.begin; } break; case 105: -#line 941 "grammar.y" +#line 942 "grammar.y" { yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); } break; case 106: -#line 945 "grammar.y" +#line 946 "grammar.y" { yyval.declarator = yystack.l_mark[0].declarator; - (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yystack.l_mark[-1].text.text, TEXT_LEN, yyval.declarator->text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); yyval.declarator->begin = yystack.l_mark[-1].text.begin; } break; case 108: -#line 957 "grammar.y" +#line 958 "grammar.y" { yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "(%s)", yyval.declarator->text); + (void)sprintf(buf, "(%.*s)", TEXT_LEN, yyval.declarator->text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); yyval.declarator->begin = yystack.l_mark[-2].text.begin; } break; case 109: -#line 965 "grammar.y" +#line 966 "grammar.y" { yyval.declarator = yystack.l_mark[-1].declarator; - (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text); + (void)sprintf(buf, "%.*s%.*s", TEXT_LEN, yyval.declarator->text, TEXT_LEN, yystack.l_mark[0].text.text); free(yyval.declarator->text); yyval.declarator->text = xstrdup(buf); } break; case 110: -#line 972 "grammar.y" +#line 973 "grammar.y" { yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin); } break; case 111: -#line 976 "grammar.y" +#line 977 "grammar.y" { yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin); yyval.declarator->params = yystack.l_mark[-1].param_list; @@ -1928,7 +1931,7 @@ case 111: } break; case 112: -#line 984 "grammar.y" +#line 985 "grammar.y" { yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin); yyval.declarator->func_stack = yystack.l_mark[-2].declarator; @@ -1937,7 +1940,7 @@ case 112: } break; case 113: -#line 991 "grammar.y" +#line 992 "grammar.y" { Declarator *d; @@ -1950,7 +1953,7 @@ case 113: } break; case 114: -#line 1002 "grammar.y" +#line 1003 "grammar.y" { Declarator *d; @@ -1961,7 +1964,7 @@ case 114: yyval.declarator->func_def = FUNC_ANSI; } break; -#line 1965 "grammar.tab.c" +#line 1968 "grammar.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/help.error b/contrib/byacc/test/yacc/help.error index e69de29bb2d1..f69a74a93091 100644 --- a/contrib/byacc/test/yacc/help.error +++ b/contrib/byacc/test/yacc/help.error @@ -0,0 +1,20 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/yacc/help.output b/contrib/byacc/test/yacc/help.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/help.output +++ b/contrib/byacc/test/yacc/help.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/yacc/no_b_opt.error b/contrib/byacc/test/yacc/no_b_opt.error index e69de29bb2d1..f69a74a93091 100644 --- a/contrib/byacc/test/yacc/no_b_opt.error +++ b/contrib/byacc/test/yacc/no_b_opt.error @@ -0,0 +1,20 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/yacc/no_b_opt.output b/contrib/byacc/test/yacc/no_b_opt.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_b_opt.output +++ b/contrib/byacc/test/yacc/no_b_opt.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/yacc/no_b_opt1.error b/contrib/byacc/test/yacc/no_b_opt1.error index e69de29bb2d1..87286c2661e6 100644 --- a/contrib/byacc/test/yacc/no_b_opt1.error +++ b/contrib/byacc/test/yacc/no_b_opt1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/yacc/no_b_opt1.output b/contrib/byacc/test/yacc/no_b_opt1.output index 87286c2661e6..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_b_opt1.output +++ b/contrib/byacc/test/yacc/no_b_opt1.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/yacc/no_code_c.error b/contrib/byacc/test/yacc/no_code_c.error index e69de29bb2d1..87286c2661e6 100644 --- a/contrib/byacc/test/yacc/no_code_c.error +++ b/contrib/byacc/test/yacc/no_code_c.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/yacc/no_code_c.output b/contrib/byacc/test/yacc/no_code_c.output index 87286c2661e6..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_code_c.output +++ b/contrib/byacc/test/yacc/no_code_c.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/yacc/no_defines.error b/contrib/byacc/test/yacc/no_defines.error index e69de29bb2d1..773985d66f33 100644 --- a/contrib/byacc/test/yacc/no_defines.error +++ b/contrib/byacc/test/yacc/no_defines.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.h" diff --git a/contrib/byacc/test/yacc/no_defines.output b/contrib/byacc/test/yacc/no_defines.output index 773985d66f33..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_defines.output +++ b/contrib/byacc/test/yacc/no_defines.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.h" diff --git a/contrib/byacc/test/yacc/no_graph.error b/contrib/byacc/test/yacc/no_graph.error index e69de29bb2d1..d5575f400421 100644 --- a/contrib/byacc/test/yacc/no_graph.error +++ b/contrib/byacc/test/yacc/no_graph.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.dot" diff --git a/contrib/byacc/test/yacc/no_graph.output b/contrib/byacc/test/yacc/no_graph.output index d5575f400421..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_graph.output +++ b/contrib/byacc/test/yacc/no_graph.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.dot" diff --git a/contrib/byacc/test/yacc/no_include.error b/contrib/byacc/test/yacc/no_include.error index e69de29bb2d1..3ece4a454e39 100644 --- a/contrib/byacc/test/yacc/no_include.error +++ b/contrib/byacc/test/yacc/no_include.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.i" diff --git a/contrib/byacc/test/yacc/no_include.output b/contrib/byacc/test/yacc/no_include.output index 3ece4a454e39..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_include.output +++ b/contrib/byacc/test/yacc/no_include.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.i" diff --git a/contrib/byacc/test/yacc/no_opts.error b/contrib/byacc/test/yacc/no_opts.error index e69de29bb2d1..ad3131a69ab6 100644 --- a/contrib/byacc/test/yacc/no_opts.error +++ b/contrib/byacc/test/yacc/no_opts.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.y" diff --git a/contrib/byacc/test/yacc/no_opts.output b/contrib/byacc/test/yacc/no_opts.output index ad3131a69ab6..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_opts.output +++ b/contrib/byacc/test/yacc/no_opts.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.y" diff --git a/contrib/byacc/test/yacc/no_output.error b/contrib/byacc/test/yacc/no_output.error index e69de29bb2d1..a2f142a9d531 100644 --- a/contrib/byacc/test/yacc/no_output.error +++ b/contrib/byacc/test/yacc/no_output.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/yacc/no_output.output b/contrib/byacc/test/yacc/no_output.output index a2f142a9d531..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_output.output +++ b/contrib/byacc/test/yacc/no_output.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/yacc/no_output1.error b/contrib/byacc/test/yacc/no_output1.error index e69de29bb2d1..a2f142a9d531 100644 --- a/contrib/byacc/test/yacc/no_output1.error +++ b/contrib/byacc/test/yacc/no_output1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/yacc/no_output1.output b/contrib/byacc/test/yacc/no_output1.output index a2f142a9d531..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_output1.output +++ b/contrib/byacc/test/yacc/no_output1.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/yacc/no_output2.error b/contrib/byacc/test/yacc/no_output2.error index e69de29bb2d1..f69a74a93091 100644 --- a/contrib/byacc/test/yacc/no_output2.error +++ b/contrib/byacc/test/yacc/no_output2.error @@ -0,0 +1,20 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/yacc/no_output2.output b/contrib/byacc/test/yacc/no_output2.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_output2.output +++ b/contrib/byacc/test/yacc/no_output2.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/yacc/no_p_opt.error b/contrib/byacc/test/yacc/no_p_opt.error index e69de29bb2d1..f69a74a93091 100644 --- a/contrib/byacc/test/yacc/no_p_opt.error +++ b/contrib/byacc/test/yacc/no_p_opt.error @@ -0,0 +1,20 @@ +YACC: error message +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/yacc/no_p_opt.output b/contrib/byacc/test/yacc/no_p_opt.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_p_opt.output +++ b/contrib/byacc/test/yacc/no_p_opt.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/yacc/no_p_opt1.error b/contrib/byacc/test/yacc/no_p_opt1.error index e69de29bb2d1..87286c2661e6 100644 --- a/contrib/byacc/test/yacc/no_p_opt1.error +++ b/contrib/byacc/test/yacc/no_p_opt1.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/yacc/no_p_opt1.output b/contrib/byacc/test/yacc/no_p_opt1.output index 87286c2661e6..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_p_opt1.output +++ b/contrib/byacc/test/yacc/no_p_opt1.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.c" diff --git a/contrib/byacc/test/yacc/no_verbose.error b/contrib/byacc/test/yacc/no_verbose.error index e69de29bb2d1..a2f142a9d531 100644 --- a/contrib/byacc/test/yacc/no_verbose.error +++ b/contrib/byacc/test/yacc/no_verbose.error @@ -0,0 +1 @@ +YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/yacc/no_verbose.output b/contrib/byacc/test/yacc/no_verbose.output index a2f142a9d531..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/no_verbose.output +++ b/contrib/byacc/test/yacc/no_verbose.output @@ -1 +0,0 @@ -YACC: f - cannot open "nosuchfile.output" diff --git a/contrib/byacc/test/yacc/nostdin.error b/contrib/byacc/test/yacc/nostdin.error index e69de29bb2d1..67101620d2c1 100644 --- a/contrib/byacc/test/yacc/nostdin.error +++ b/contrib/byacc/test/yacc/nostdin.error @@ -0,0 +1,19 @@ +Usage: YACC [options] filename + +Options: + -b file_prefix set filename prefix (default "y.") + -B create a backtracking parser + -d write definitions (.tab.h) + -H defines_file write definitions to defines_file + -i write interface (y.tab.i) + -g write a graphical description + -l suppress #line directives + -L enable position processing, e.g., "%locations" + -o output_file (default ".tab.c") + -p symbol_prefix set symbol prefix (default "yy") + -P create a reentrant parser, e.g., "%pure-parser" + -r produce separate code and table files (y.code.c) + -s suppress #define's for quoted names in %token lines + -t add debugging support + -v write description (y.output) + -V show version information and exit diff --git a/contrib/byacc/test/yacc/nostdin.output b/contrib/byacc/test/yacc/nostdin.output index 112b7c7a41c5..e69de29bb2d1 100644 --- a/contrib/byacc/test/yacc/nostdin.output +++ b/contrib/byacc/test/yacc/nostdin.output @@ -1,18 +0,0 @@ -Usage: YACC [options] filename - -Options: - -b file_prefix set filename prefix (default "y.") - -B create a backtracking parser - -d write definitions (.tab.h) - -i write interface (y.tab.i) - -g write a graphical description - -l suppress #line directives - -L enable position processing, e.g., "%locations" - -o output_file (default ".tab.c") - -p symbol_prefix set symbol prefix (default "yy") - -P create a reentrant parser, e.g., "%pure-parser" - -r produce separate code and table files (y.code.c) - -s suppress #define's for quoted names in %token lines - -t add debugging support - -v write description (y.output) - -V show version information and exit diff --git a/contrib/byacc/test/yacc/ok_syntax1.tab.c b/contrib/byacc/test/yacc/ok_syntax1.tab.c index 7713d6910bf0..294d3096458a 100644 --- a/contrib/byacc/test/yacc/ok_syntax1.tab.c +++ b/contrib/byacc/test/yacc/ok_syntax1.tab.c @@ -306,8 +306,9 @@ static const char *const ok_syntax1_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -385,7 +386,7 @@ YYLEX_DECL() } return( c ); } -#line 389 "ok_syntax1.tab.c" +#line 390 "ok_syntax1.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -452,6 +453,7 @@ YYPARSE_DECL() int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; /* variables for the parser stack */ YYSTACKDATA yystack; @@ -654,7 +656,7 @@ case 18: #line 101 "ok_syntax1.y" { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } break; -#line 658 "ok_syntax1.tab.c" +#line 660 "ok_syntax1.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/ok_syntax1.tab.h b/contrib/byacc/test/yacc/ok_syntax1.tab.h index 8a51fa00660e..892b211c8a71 100644 --- a/contrib/byacc/test/yacc/ok_syntax1.tab.h +++ b/contrib/byacc/test/yacc/ok_syntax1.tab.h @@ -27,4 +27,3 @@ typedef union double dval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ -extern YYSTYPE ok_syntax1_lval; diff --git a/contrib/byacc/test/yacc/pure_calc.tab.c b/contrib/byacc/test/yacc/pure_calc.tab.c index 9ff809e9c39c..45ced9b94347 100644 --- a/contrib/byacc/test/yacc/pure_calc.tab.c +++ b/contrib/byacc/test/yacc/pure_calc.tab.c @@ -285,8 +285,9 @@ static const char *const calc_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -357,7 +358,7 @@ YYLEX_DECL() } return( c ); } -#line 361 "pure_calc.tab.c" +#line 362 "pure_calc.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -424,6 +425,7 @@ YYPARSE_DECL() int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; /* variables for the parser stack */ YYSTACKDATA yystack; @@ -626,7 +628,7 @@ case 18: #line 69 "pure_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 630 "pure_calc.tab.c" +#line 632 "pure_calc.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/pure_error.tab.c b/contrib/byacc/test/yacc/pure_error.tab.c index 6933867db7d4..361ba542ec0d 100644 --- a/contrib/byacc/test/yacc/pure_error.tab.c +++ b/contrib/byacc/test/yacc/pure_error.tab.c @@ -202,8 +202,9 @@ static const char *const error_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -254,7 +255,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 258 "pure_error.tab.c" +#line 259 "pure_error.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -321,6 +322,7 @@ YYPARSE_DECL() int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; /* variables for the parser stack */ YYSTACKDATA yystack; diff --git a/contrib/byacc/test/yacc/quote_calc-s.tab.c b/contrib/byacc/test/yacc/quote_calc-s.tab.c index 9647fbef5ab7..0cfdfef9cfdd 100644 --- a/contrib/byacc/test/yacc/quote_calc-s.tab.c +++ b/contrib/byacc/test/yacc/quote_calc-s.tab.c @@ -291,13 +291,15 @@ static const char *const quote_calc_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -365,7 +367,7 @@ yylex(void) { } return( c ); } -#line 369 "quote_calc-s.tab.c" +#line 371 "quote_calc-s.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -624,7 +626,7 @@ case 18: #line 70 "quote_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 628 "quote_calc-s.tab.c" +#line 630 "quote_calc-s.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/quote_calc.tab.c b/contrib/byacc/test/yacc/quote_calc.tab.c index 4a2c1323a684..6e9fd4df23f5 100644 --- a/contrib/byacc/test/yacc/quote_calc.tab.c +++ b/contrib/byacc/test/yacc/quote_calc.tab.c @@ -297,13 +297,15 @@ static const char *const quote_calc_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -371,7 +373,7 @@ yylex(void) { } return( c ); } -#line 375 "quote_calc.tab.c" +#line 377 "quote_calc.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -630,7 +632,7 @@ case 18: #line 70 "quote_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 634 "quote_calc.tab.c" +#line 636 "quote_calc.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/quote_calc2-s.tab.c b/contrib/byacc/test/yacc/quote_calc2-s.tab.c index faf8bb55afb5..d8d17fa3b978 100644 --- a/contrib/byacc/test/yacc/quote_calc2-s.tab.c +++ b/contrib/byacc/test/yacc/quote_calc2-s.tab.c @@ -291,13 +291,15 @@ static const char *const quote_calc2_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -365,7 +367,7 @@ yylex(void) { } return( c ); } -#line 369 "quote_calc2-s.tab.c" +#line 371 "quote_calc2-s.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -624,7 +626,7 @@ case 18: #line 70 "quote_calc2.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 628 "quote_calc2-s.tab.c" +#line 630 "quote_calc2-s.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/quote_calc2.tab.c b/contrib/byacc/test/yacc/quote_calc2.tab.c index a5d580093ce9..b601d7b7fea7 100644 --- a/contrib/byacc/test/yacc/quote_calc2.tab.c +++ b/contrib/byacc/test/yacc/quote_calc2.tab.c @@ -297,13 +297,15 @@ static const char *const quote_calc2_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -371,7 +373,7 @@ yylex(void) { } return( c ); } -#line 375 "quote_calc2.tab.c" +#line 377 "quote_calc2.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -630,7 +632,7 @@ case 18: #line 70 "quote_calc2.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 634 "quote_calc2.tab.c" +#line 636 "quote_calc2.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/quote_calc3-s.tab.c b/contrib/byacc/test/yacc/quote_calc3-s.tab.c index f987237d3737..6a4d70259ba7 100644 --- a/contrib/byacc/test/yacc/quote_calc3-s.tab.c +++ b/contrib/byacc/test/yacc/quote_calc3-s.tab.c @@ -292,13 +292,15 @@ static const char *const quote_calc3_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -366,7 +368,7 @@ yylex(void) { } return( c ); } -#line 370 "quote_calc3-s.tab.c" +#line 372 "quote_calc3-s.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -625,7 +627,7 @@ case 18: #line 70 "quote_calc3.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 629 "quote_calc3-s.tab.c" +#line 631 "quote_calc3-s.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/quote_calc3.tab.c b/contrib/byacc/test/yacc/quote_calc3.tab.c index 9d1f054db96d..bcad8e89b0fd 100644 --- a/contrib/byacc/test/yacc/quote_calc3.tab.c +++ b/contrib/byacc/test/yacc/quote_calc3.tab.c @@ -292,13 +292,15 @@ static const char *const quote_calc3_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -366,7 +368,7 @@ yylex(void) { } return( c ); } -#line 370 "quote_calc3.tab.c" +#line 372 "quote_calc3.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -625,7 +627,7 @@ case 18: #line 70 "quote_calc3.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 629 "quote_calc3.tab.c" +#line 631 "quote_calc3.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/quote_calc4-s.tab.c b/contrib/byacc/test/yacc/quote_calc4-s.tab.c index 36c5b970d998..bb747dd66f46 100644 --- a/contrib/byacc/test/yacc/quote_calc4-s.tab.c +++ b/contrib/byacc/test/yacc/quote_calc4-s.tab.c @@ -292,13 +292,15 @@ static const char *const quote_calc4_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -366,7 +368,7 @@ yylex(void) { } return( c ); } -#line 370 "quote_calc4-s.tab.c" +#line 372 "quote_calc4-s.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -625,7 +627,7 @@ case 18: #line 70 "quote_calc4.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 629 "quote_calc4-s.tab.c" +#line 631 "quote_calc4-s.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/quote_calc4.tab.c b/contrib/byacc/test/yacc/quote_calc4.tab.c index c95244db1722..43a55664a9c3 100644 --- a/contrib/byacc/test/yacc/quote_calc4.tab.c +++ b/contrib/byacc/test/yacc/quote_calc4.tab.c @@ -292,13 +292,15 @@ static const char *const quote_calc4_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -366,7 +368,7 @@ yylex(void) { } return( c ); } -#line 370 "quote_calc4.tab.c" +#line 372 "quote_calc4.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -625,7 +627,7 @@ case 18: #line 70 "quote_calc4.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 629 "quote_calc4.tab.c" +#line 631 "quote_calc4.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/test/yacc/rename_debug.c b/contrib/byacc/test/yacc/rename_debug.c index e090fb40029e..c0890dde9356 100644 --- a/contrib/byacc/test/yacc/rename_debug.c +++ b/contrib/byacc/test/yacc/rename_debug.c @@ -66,13 +66,15 @@ static const char *const yyrule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -125,7 +127,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 130 "rename_debug.c" +#line 132 "rename_debug.c" #if YYDEBUG #include /* needed for printf */ diff --git a/contrib/byacc/test/yacc/rename_debug.i b/contrib/byacc/test/yacc/rename_debug.i index b7b801439e7a..1e81e02e8f93 100644 --- a/contrib/byacc/test/yacc/rename_debug.i +++ b/contrib/byacc/test/yacc/rename_debug.i @@ -37,6 +37,10 @@ typedef int YYSTYPE; # define YYLEX yylex() #endif +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) @@ -47,10 +51,16 @@ typedef int YYSTYPE; extern int YYPARSE_DECL(); +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif + +#if YYDEBUG extern int yydebug; -extern int yynerrs; +#endif extern int yyerrflag; extern int yychar; extern YYSTYPE yyval; extern YYSTYPE yylval; +extern int yynerrs; diff --git a/contrib/byacc/test/yacc/stdin1.calc.c b/contrib/byacc/test/yacc/stdin1.calc.c new file mode 100644 index 000000000000..a30852500354 --- /dev/null +++ b/contrib/byacc/test/yacc/stdin1.calc.c @@ -0,0 +1,595 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "(null)" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "(null)" + { yyerrok ; } +break; +case 4: +#line 32 "(null)" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "(null)" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "(null)" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "(null)" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "(null)" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "(null)" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "(null)" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "(null)" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "(null)" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "(null)" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "(null)" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "(null)" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "(null)" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "(null)" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 539 "stdin1.calc.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/stdin1.error b/contrib/byacc/test/yacc/stdin1.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/stdin1.output b/contrib/byacc/test/yacc/stdin1.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/stdin2.calc.c b/contrib/byacc/test/yacc/stdin2.calc.c new file mode 100644 index 000000000000..f86bdc005aab --- /dev/null +++ b/contrib/byacc/test/yacc/stdin2.calc.c @@ -0,0 +1,595 @@ +/* original parser id follows */ +/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ +/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYCHECK "yyyymmdd" + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING() (yyerrflag != 0) +#define YYENOMEM (-2) +#define YYEOF 0 +#define YYPREFIX "yy" + +#define YYPURE 0 + +#line 2 "calc.y" +# include +# 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 = 0; + yyn = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + yystate = 0; + +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; + yystate = 0; + *yystack.s_mark = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag != 0) goto yyinrecovery; + + YYERROR_CALL("syntax error"); + + goto yyerrlab; /* redundant goto avoids 'unused label' warning */ +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + yystate = yytable[yyn]; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yystack.s_mark); +#endif + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; + } + } + } + else + { + if (yychar == YYEOF) goto yyabort; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym > 0) + yyval = yystack.l_mark[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + + switch (yyn) + { +case 3: +#line 28 "calc.y" + { yyerrok ; } +break; +case 4: +#line 32 "calc.y" + { printf("%d\n",yystack.l_mark[0]);} +break; +case 5: +#line 34 "calc.y" + { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } +break; +case 6: +#line 38 "calc.y" + { yyval = yystack.l_mark[-1]; } +break; +case 7: +#line 40 "calc.y" + { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } +break; +case 8: +#line 42 "calc.y" + { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } +break; +case 9: +#line 44 "calc.y" + { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } +break; +case 10: +#line 46 "calc.y" + { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } +break; +case 11: +#line 48 "calc.y" + { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } +break; +case 12: +#line 50 "calc.y" + { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } +break; +case 13: +#line 52 "calc.y" + { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } +break; +case 14: +#line 54 "calc.y" + { yyval = - yystack.l_mark[0]; } +break; +case 15: +#line 56 "calc.y" + { yyval = regs[yystack.l_mark[0]]; } +break; +case 17: +#line 61 "calc.y" + { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } +break; +case 18: +#line 63 "calc.y" + { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } +break; +#line 539 "stdin2.calc.c" + } + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; + if (yychar < 0) + { + yychar = YYLEX; + if (yychar < 0) yychar = YYEOF; +#if YYDEBUG + if (yydebug) + { + if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == YYEOF) goto yyaccept; + goto yyloop; + } + if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); +#endif + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; + *++yystack.s_mark = (YYINT) yystate; + *++yystack.l_mark = yyval; + goto yyloop; + +yyoverflow: + YYERROR_CALL("yacc stack overflow"); + +yyabort: + yyfreestack(&yystack); + return (1); + +yyaccept: + yyfreestack(&yystack); + return (0); +} diff --git a/contrib/byacc/test/yacc/stdin2.error b/contrib/byacc/test/yacc/stdin2.error new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/stdin2.output b/contrib/byacc/test/yacc/stdin2.output new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/contrib/byacc/test/yacc/varsyntax_calc1.tab.c b/contrib/byacc/test/yacc/varsyntax_calc1.tab.c index a954383fd013..8d56d450d834 100644 --- a/contrib/byacc/test/yacc/varsyntax_calc1.tab.c +++ b/contrib/byacc/test/yacc/varsyntax_calc1.tab.c @@ -324,13 +324,15 @@ static const char *const varsyntax_calc1_rule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -488,7 +490,7 @@ vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } -#line 492 "varsyntax_calc1.tab.c" +#line 494 "varsyntax_calc1.tab.c" #if YYDEBUG #include /* needed for printf */ @@ -850,7 +852,7 @@ case 28: yyval.vval = yystack.l_mark[-1].vval; } break; -#line 854 "varsyntax_calc1.tab.c" +#line 856 "varsyntax_calc1.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/contrib/byacc/yacc.1 b/contrib/byacc/yacc.1 index 8076ab03b349..43149fb71e6e 100644 --- a/contrib/byacc/yacc.1 +++ b/contrib/byacc/yacc.1 @@ -1,16 +1,19 @@ -.\" $Id: yacc.1,v 1.24 2014/10/06 00:03:48 tom Exp $ +.\" $Id: yacc.1,v 1.33 2020/03/30 23:36:40 tom Exp $ .\" .\" .TH YACC 1 "July\ 15,\ 1990" .\" .UC 6 -.de ES -.ne 8 +.ds N Yacc +.ds n yacc +.de Ex +.RS +7 +.PP .nf -.sp -.in +4 +.ft CW .. -.de XE -.in -4 +.de Ee .fi +.ft R +.RE .. .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds AQ \(aq @@ -21,14 +24,17 @@ .el .ds '' '' .\" Bulleted paragraph .de bP -.IP \(bu 4 +.ie n .IP \(bu 4 +.el .IP \(bu 2 .. -.TH YACC 1 "October 5, 2014" "Berkeley Yacc" "User Commands" +.TH YACC 1 "November 19, 2019" "Berkeley Yacc" "User Commands" .SH NAME -Yacc \- an LALR(1) parser generator +\*N \- an LALR(1) parser generator .SH SYNOPSIS -.B yacc [ -BdgilLPrtvVy ] [ \-b +.B \*n [ \-BdgilLPrtvVy ] [ \-b .I file_prefix +.B ] [ \-H +.I defines_file .B ] [ \-o .I output_file .B ] [ \-p @@ -36,15 +42,15 @@ Yacc \- an LALR(1) parser generator .B ] .I filename .SH DESCRIPTION -.B Yacc +.B \*N reads the grammar specification in the file .I filename and generates an LALR(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. -.B Yacc +.B \*N normally writes the parse tables and the driver routine to the file -.IR y.tab.c. +.IR y.tab.c . .PP The following options are available: .TP 5 @@ -53,34 +59,40 @@ The .B \-b option changes the prefix prepended to the output file names to the string denoted by -.IR file_prefix. +.I file_prefix. The default prefix is the character -.IR y. +.I y. .TP .B \-B -create a backtracking parser (compile-type configuration for \fBbtyacc\fP). +create a backtracking parser (compile-time configuration for \fBbtyacc\fP). .TP .B \-d -The \fB-d\fR option causes the header file -.BR y.tab.h +causes the header file +.B y.tab.h to be written. It contains #define's for the token identifiers. .TP +\fB\-H \fP\fIdefines_file\fR +causes #define's for the token identifiers +to be written to the given \fIdefines_file\fP rather +than the \fBy.tab.h\fP file used by the \fB\-d\fP option. +.TP .B \-g The .B \-g option causes a graphical description of the generated LALR(1) parser to be written to the file -.BR y.dot -in graphviz format, ready to be processed by dot(1). +.B y.dot +in graphviz format, ready to be processed by +.BR dot (1). .TP .B \-i -The \fB-i\fR option causes a supplementary header file -.BR y.tab.i +The \fB\-i\fR option causes a supplementary header file +.B y.tab.i to be written. It contains extern declarations and supplementary #define's as needed to map the conventional \fIyacc\fP -\fByy\fP-prefixed names to whatever the \fB-p\fP option may specify. +\fByy\fP-prefixed names to whatever the \fB\-p\fP option may specify. The code file, e.g., \fBy.tab.c\fP is modified to #include this file as well as the \fBy.tab.h\fP file, enforcing consistent usage of the symbols defined in those files. @@ -92,32 +104,33 @@ of lex- and yacc-files. If the .B \-l option is not specified, -.B yacc +.B \*n will insert \fI#line\fP directives in the generated code. The \fI#line\fP directives let the C compiler relate errors in the generated code to the user's original code. -If the \fB-l\fR option is specified, -.B yacc +If the \fB\-l\fR option is specified, +.B \*n will not insert the \fI#line\fP directives. \&\fI#line\fP directives specified by the user will be retained. .TP .B \-L -enable position processing, e.g., \*(``%locations\*('' (compile-type configuration for \fBbtyacc\fP). +enable position processing, +e.g., \*(``%locations\*('' (compile-time configuration for \fBbtyacc\fP). .TP \fB\-o \fP\fIoutput_file\fR specify the filename for the parser file. If this option is not given, the output filename is the file prefix concatenated with the file suffix, e.g., \fBy.tab.c\fP. -This overrides the \fB-b\fP option. +This overrides the \fB\-b\fP option. .TP \fB\-p \fP\fIsymbol_prefix\fR The .B \-p option changes the prefix prepended to yacc-generated symbols to the string denoted by -.IR symbol_prefix. +.I symbol_prefix. The default prefix is the string -.BR yy. +.B yy. .TP .B \-P create a reentrant parser, e.g., \*(``%pure-parser\*(''. @@ -126,12 +139,12 @@ create a reentrant parser, e.g., \*(``%pure-parser\*(''. The .B \-r option causes -.B yacc +.B \*n to produce separate files for code and tables. The code file is named -.IR y.code.c, +.IR y.code.c , and the tables file is named -.IR y.tab.c. +.IR y.tab.c . The prefix \*(``\fIy.\fP\*('' can be overridden using the \fB\-b\fP option. .TP .B \-s @@ -140,19 +153,19 @@ a \*(``\fB%token\fP\*('' statement, to more closely match original \fByacc\fP behavior. .IP Normally when \fByacc\fP sees a line such as -.ES +.Ex %token OP_ADD "ADD" -.XE +.Ee .IP it notices that the quoted \*(``ADD\*('' is a valid C identifier, and generates a #define not only for OP_ADD, but for ADD as well, e.g., -.ES +.Ex #define OP_ADD 257 .br #define ADD 258 -.XE +.Ee .IP The original \fByacc\fP does not generate the second \*(``\fB#define\fP\*(''. The \fB\-s\fP option suppresses this \*(``\fB#define\fP\*(''. @@ -165,7 +178,7 @@ though original \fByacc\fP and bison also accept string literals. The .B \-t option changes the preprocessor directives generated by -.B yacc +.B \*n so that debugging statements will be incorporated in the compiled code. .TP .B \-v @@ -173,7 +186,7 @@ The .B \-v option causes a human-readable description of the generated parser to be written to the file -.IR y.output. +.I y.output. .TP .B \-V print the version number to the standard output. @@ -181,15 +194,46 @@ print the version number to the standard output. .B \-y \fByacc\fP ignores this option, which bison supports for ostensible POSIX compatibility. +.PP +The \fIfilename\fP parameter is not optional. +However, \fByacc\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 EXTENSIONS -.B yacc +.B \*N provides some extensions for compatibility with bison and other implementations of yacc. The \fB%destructor\fP and \fB%locations\fP features are available -only if \fByacc\fP has been configured and compiled to support the +only if \fB\*n\fP has been configured and compiled to support the back-tracking (\fBbtyacc\fP) functionality. The remaining features are always available: .TP +\fB %code\fP \fIkeyword\fP { \fIcode\fP } +Adds the indicated source \fIcode\fP at a given point in the output file. +The optional \fIkeyword\fP tells \fB\*n\fP where to insert the \fIcode\fP: +.RS 7 +.TP 5 +\fBtop\fP +just after the version-definition in the generated code-file. +.TP 5 +\fBrequires\fP +just after the declaration of public parser variables. +If the \fB\-d\fP option is given, the code is inserted at the +beginning of the defines-file. +.TP 5 +\fBprovides\fP +just after the declaration of private parser variables. +If the \fB\-d\fP option is given, the code is inserted at the +end of the defines-file. +.RE +.IP +If no \fIkeyword\fP is given, the code is inserted at the +beginning of the section of code copied verbatim from the source file. +Multiple \fB%code\fP directives may be given; +\fB\*n\fP inserts those into the corresponding code- or defines-file +in the order that they appear in the source file. +.TP \fB %destructor\fP { \fIcode\fP } \fIsymbol+\fP defines code that is invoked when a symbol is automatically discarded during error recovery. @@ -206,13 +250,14 @@ if the \fBYYSTYPE\fP value is, or contains, pointers to dynamically allocated memory. .IP The bracketed \fIcode\fP is invoked whenever the parser discards one of -the symbols. Within \fIcode\fP, \*(``\fB$$\fP\*('' or +the symbols. +Within \fIcode\fP, \*(``\fB$$\fP\*('' or \*(``\fB$$\fP\*('' designates the semantic value associated with the -discarded symbol, and \*(``\fB@$\fP\*('' designates its location (see +discarded symbol, and \*(``\fB@$\fP\*('' designates its location (see \fB%locations\fP directive). .IP A per-symbol destructor is defined by listing a grammar symbol -in \fIsymbol+\fP. A per-type destructor is defined by listing +in \fIsymbol+\fP. A per-type destructor is defined by listing a semantic type tag (e.g., \*(``\*('') in \fIsymbol+\fP; in this case, the parser will invoke \fIcode\fP whenever it discards any grammar symbol that has that semantic type tag, unless that symbol has its own @@ -241,28 +286,30 @@ That makes it only report the number if it differs. This is (unlike bison) allowable in LALR parsers. .TP \fB %locations\fP -tells \fByacc\fP to enable management of position information associated +tells \fByacc\fP to enable management of position information associated with each token, provided by the lexer in the global variable \fByylloc\fP, similar to management of semantic value information provided in \fByylval\fP. .IP As for semantic values, locations can be referenced within actions using \fB@$\fP to refer to the location of the left hand side symbol, and \fB@N\fP (\fBN\fP an integer) to refer to the location of one of the right hand side -symbols. Also as for semantic values, when a rule is matched, a default +symbols. +Also as for semantic values, when a rule is matched, a default action is used the compute the location represented by \fB@$\fP as the beginning of the first symbol and the end of the last symbol in the right -hand side of the rule. This default computation can be overridden by +hand side of the rule. +This default computation can be overridden by explicit assignment to \fB@$\fP in a rule action. .IP The type of \fByylloc\fP is \fBYYLTYPE\fP, which is defined by default as: -.ES +.Ex typedef struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; } YYLTYPE; -.XE +.Ee .IP \fBYYLTYPE\fP can be redefined by the user (\fBYYLTYPE_IS_DEFINED\fP must be defined, to inhibit the default) @@ -292,23 +339,24 @@ reentrant. \fB %token-table\fP Make the parser's names for tokens available in the \fByytname\fP array. However, -.B yacc +.B \*n does not predefine \*(``$end\*('', \*(``$error\*('' or \*(``$undefined\*('' in this array. .SH PORTABILITY According to Robert Corbett, -.ES - 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. -.XE +.Ex +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. +.Ee .PP The rationale in -.ES +.Ex http://pubs.opengroup.org/onlinepubs/9699919799/utilities/yacc.html -.XE +.Ee .PP documents some features of AT&T yacc which are no longer required for POSIX compliance. @@ -320,12 +368,12 @@ Here are a few differences: .bP \fBYacc\fP accepts an equals mark preceding the left curly brace of an action (as in the original grammar file \fBftp.y\fP): -.ES - | STAT CRLF - = { - statcmd(); - } -.XE +.Ex + | STAT CRLF + = { + statcmd(); + } +.Ee .bP \fBYacc\fP and bison emit code in different order, and in particular bison makes forward reference to common functions such as yylex, yyparse and @@ -334,18 +382,18 @@ yyerror without providing prototypes. Bison's support for \*(``%expect\*('' is broken in more than one release. For best results using bison, delete that directive. .bP -Bison has no equivalent for some of \fByacc\fP's commmand-line options, +Bison has no equivalent for some of \fByacc\fP's command-line options, relying on directives embedded in the grammar file. .bP Bison's \*(``\fB\-y\fP\*('' option does not affect bison's lack of support for features of AT&T yacc which were deemed obsolescent. .bP -\fBYacc\fP accepts multiple parameters with \fB%lex-param\fP and \fB%parse-param\fP -in two forms -.ES +\fBYacc\fP accepts multiple parameters +with \fB%lex-param\fP and \fB%parse-param\fP in two forms +.Ex {type1 name1} {type2 name2} ... {type1 name1, type2 name2 ...} -.XE +.Ee .IP Bison accepts the latter (though undocumented), but depending on the release may generate bad code. diff --git a/contrib/byacc/yaccpar.c b/contrib/byacc/yaccpar.c index 6186453019e3..e57bd4bb7d36 100644 --- a/contrib/byacc/yaccpar.c +++ b/contrib/byacc/yaccpar.c @@ -2,7 +2,7 @@ * @Id: skel2c,v 1.4 2016/06/07 00:26:09 tom Exp @ */ -/* @Id: yaccpar.skel,v 1.8 2016/12/02 21:44:42 tom Exp @ */ +/* @Id: yaccpar.skel,v 1.10 2018/05/06 21:28:14 Guy.Harris Exp @ */ #include "defs.h" @@ -67,8 +67,9 @@ const char *const tables[] = const char *const global_vars[] = { "", + "#if YYDEBUG", "int yydebug;", - "int yynerrs;", + "#endif", 0 }; @@ -79,6 +80,7 @@ const char *const impure_vars[] = "int yychar;", "YYSTYPE yyval;", "YYSTYPE yylval;", + "int yynerrs;", 0 }; @@ -124,6 +126,7 @@ const char *const body_vars[] = " int yychar;", " YYSTYPE yyval;", " YYSTYPE yylval;", + " int yynerrs;", "", " /* variables for the parser stack */", " YYSTACKDATA yystack;", diff --git a/contrib/byacc/yaccpar.skel b/contrib/byacc/yaccpar.skel index b553180967c9..32e2d1560537 100644 --- a/contrib/byacc/yaccpar.skel +++ b/contrib/byacc/yaccpar.skel @@ -1,4 +1,4 @@ -/* $Id: yaccpar.skel,v 1.9 2017/04/30 23:28:17 tom Exp $ */ +/* $Id: yaccpar.skel,v 1.10 2018/05/06 21:28:14 Guy.Harris Exp $ */ #include "defs.h" @@ -46,14 +46,16 @@ extern char *yyrule[]; #endif %% global_vars +#if YYDEBUG int yydebug; -int yynerrs; +#endif %% impure_vars int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; %% hdr_defs /* define the initial stack-sizes */ @@ -87,6 +89,7 @@ static YYSTACKDATA yystack; int yychar; YYSTYPE yyval; YYSTYPE yylval; + int yynerrs; /* variables for the parser stack */ YYSTACKDATA yystack; diff --git a/usr.bin/yacc/Makefile b/usr.bin/yacc/Makefile index 026a6ccc43fe..65e4304e0361 100644 --- a/usr.bin/yacc/Makefile +++ b/usr.bin/yacc/Makefile @@ -10,10 +10,8 @@ PROG= yacc SRCS= closure.c error.c graph.c lalr.c lr0.c main.c mkpar.c mstring.c output.c \ reader.c yaccpar.c symtab.c verbose.c warshall.c -CFLAGS+= -DHAVE_FCNTL_H=1 \ - -DHAVE_MKSTEMP=1 \ - -DMAXTABLE=INT_MAX \ - -DMIXEDCASE_FILENAMES=1 +CFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR} +CFLAGS+= -DMAXTABLE=INT_MAX YYPATCH!= cat ${BYACC_SRC}/VERSION CFLAGS+= -DYYPATCH=${YYPATCH} diff --git a/usr.bin/yacc/config.h b/usr.bin/yacc/config.h new file mode 100644 index 000000000000..0925055d3f2f --- /dev/null +++ b/usr.bin/yacc/config.h @@ -0,0 +1,108 @@ +/* $FreeBSD$ */ +/* config.h. Generated automatically by configure. */ +/* config_h.in. Generated automatically from configure.in by autoheader. */ + +/* Define to noreturn-attribute for gcc */ +/* #undef GCC_NORETURN */ + +/* Define to 1 if the compiler supports gcc-like printf attribute. */ +/* #undef GCC_PRINTF */ + +/* Define to printf-attribute for gcc */ +/* #undef GCC_PRINTFLIKE */ + +/* Define to 1 if the compiler supports gcc-like scanf attribute. */ +/* #undef GCC_SCANF */ + +/* Define to sscanf-attribute for gcc */ +/* #undef GCC_SCANFLIKE */ + +/* Define to unused-attribute for gcc */ +/* #undef GCC_UNUSED */ + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if getopt variables are declared in header */ +#define HAVE_GETOPT_HEADER 1 + +/* Define if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define if you have the `dbmalloc' library (-ldbmalloc). */ +/* #undef HAVE_LIBDBMALLOC */ + +/* Define if you have the `dmalloc' library (-ldmalloc). */ +/* #undef HAVE_LIBDMALLOC */ + +/* Define if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if mkstemp() is available and working. */ +#define HAVE_MKSTEMP 1 + +/* Define if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to maximum table size (default: 32500) */ +/* #undef MAXTABLE */ + +/* Define to 1 if filesystem supports mixed-case filenames. */ +#define MIXEDCASE_FILENAMES 1 + +/* Define to 1 if we must include getopt.h */ +/* #undef NEED_GETOPT_H */ + +/* Define to 1 if you want to perform memory-leak testing. */ +/* #undef NO_LEAKS */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to the system name. */ +#define SYSTEM_NAME "freebsd13.0" + +/* "Define to 1 if you want to use dbmalloc for testing." */ +/* #undef USE_DBMALLOC */ + +/* "Define to 1 if you want to use dmalloc for testing." */ +/* #undef USE_DMALLOC */ + +/* "Define to 1 if you want to use valgrind for testing." */ +/* #undef USE_VALGRIND */ + +/* Define to 1 to enable backtracking extension */ +/* #undef YYBTYACC */ + +/* Define to 1 if you want to perform memory-leak testing. */ +/* #undef YY_NO_LEAKS */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ diff --git a/usr.bin/yacc/tests/Makefile b/usr.bin/yacc/tests/Makefile index 728f3afd8f59..20dab5217a36 100644 --- a/usr.bin/yacc/tests/Makefile +++ b/usr.bin/yacc/tests/Makefile @@ -23,11 +23,12 @@ FILEStest_yaccPACKAGE=${PACKAGE} FILEStestDIR= ${TESTSDIR} -FILEStest+= btyacc_calc1.y -FILEStest+= btyacc_demo.y -FILEStest+= btyacc_destroy1.y -FILEStest+= btyacc_destroy2.y -FILEStest+= btyacc_destroy3.y +FILEStest+= calc_code_all.y +FILEStest+= calc_code_default.y +FILEStest+= calc_code_imports.y +FILEStest+= calc_code_provides.y +FILEStest+= calc_code_requires.y +FILEStest+= calc_code_top.y FILEStest+= calc.y FILEStest+= calc1.y FILEStest+= calc2.y @@ -36,11 +37,6 @@ FILEStest+= code_calc.y FILEStest+= code_debug.y FILEStest+= code_error.y FILEStest+= empty.y -FILEStest+= err_inherit1.y -FILEStest+= err_inherit2.y -FILEStest+= err_inherit3.y -FILEStest+= err_inherit4.y -FILEStest+= err_inherit5.y FILEStest+= err_syntax1.y FILEStest+= err_syntax10.y FILEStest+= err_syntax11.y @@ -74,9 +70,6 @@ FILEStest+= err_syntax9.y FILEStest+= error.y FILEStest+= expr.oxout.y FILEStest+= grammar.y -FILEStest+= inherit0.y -FILEStest+= inherit1.y -FILEStest+= inherit2.y FILEStest+= ok_syntax1.y FILEStest+= pure_calc.y FILEStest+= pure_error.y @@ -92,6 +85,30 @@ FILEStest_yacc+= big_b.error FILEStest_yacc+= big_b.output FILEStest_yacc+= big_l.error FILEStest_yacc+= big_l.output +FILEStest_yacc+= calc_code_all.error +FILEStest_yacc+= calc_code_all.output +FILEStest_yacc+= calc_code_all.tab.c +FILEStest_yacc+= calc_code_all.tab.h +FILEStest_yacc+= calc_code_default.error +FILEStest_yacc+= calc_code_default.output +FILEStest_yacc+= calc_code_default.tab.c +FILEStest_yacc+= calc_code_default.tab.h +FILEStest_yacc+= calc_code_imports.error +FILEStest_yacc+= calc_code_imports.output +FILEStest_yacc+= calc_code_imports.tab.c +FILEStest_yacc+= calc_code_imports.tab.h +FILEStest_yacc+= calc_code_provides.error +FILEStest_yacc+= calc_code_provides.output +FILEStest_yacc+= calc_code_provides.tab.c +FILEStest_yacc+= calc_code_provides.tab.h +FILEStest_yacc+= calc_code_requires.error +FILEStest_yacc+= calc_code_requires.output +FILEStest_yacc+= calc_code_requires.tab.c +FILEStest_yacc+= calc_code_requires.tab.h +FILEStest_yacc+= calc_code_top.error +FILEStest_yacc+= calc_code_top.output +FILEStest_yacc+= calc_code_top.tab.c +FILEStest_yacc+= calc_code_top.tab.h FILEStest_yacc+= calc.error FILEStest_yacc+= calc.output FILEStest_yacc+= calc.tab.c @@ -118,6 +135,18 @@ FILEStest_yacc+= code_error.error FILEStest_yacc+= code_error.output FILEStest_yacc+= code_error.tab.c FILEStest_yacc+= code_error.tab.h +FILEStest_yacc+= defines1.calc.c +FILEStest_yacc+= defines1.calc.h +FILEStest_yacc+= defines1.error +FILEStest_yacc+= defines1.output +FILEStest_yacc+= defines2.calc.c +FILEStest_yacc+= defines2.calc.h +FILEStest_yacc+= defines2.error +FILEStest_yacc+= defines2.output +FILEStest_yacc+= defines3.calc.c +FILEStest_yacc+= defines3.calc.h +FILEStest_yacc+= defines3.error +FILEStest_yacc+= defines3.output FILEStest_yacc+= empty.error FILEStest_yacc+= empty.output FILEStest_yacc+= empty.tab.c @@ -334,6 +363,12 @@ FILEStest_yacc+= rename_debug.error FILEStest_yacc+= rename_debug.h FILEStest_yacc+= rename_debug.i FILEStest_yacc+= rename_debug.output +FILEStest_yacc+= stdin1.calc.c +FILEStest_yacc+= stdin1.error +FILEStest_yacc+= stdin1.output +FILEStest_yacc+= stdin2.calc.c +FILEStest_yacc+= stdin2.error +FILEStest_yacc+= stdin2.output FILEStest_yacc+= varsyntax_calc1.error FILEStest_yacc+= varsyntax_calc1.output FILEStest_yacc+= varsyntax_calc1.tab.c