From edf97230c34f43fa86b2725b3e6fd1daef309ea9 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Sun, 11 Mar 2018 08:17:21 -0700 Subject: [PATCH] Import byacc-20170709 --- contrib/byacc/CHANGES | 620 ++++++++++++++++++++++++++++++++-------- contrib/byacc/VERSION | 2 +- contrib/byacc/defs.h | 47 +++- contrib/byacc/error.c | 51 ++-- contrib/byacc/lalr.c | 30 +- contrib/byacc/lr0.c | 25 +- contrib/byacc/main.c | 53 +++- contrib/byacc/mkpar.c | 10 +- contrib/byacc/mstring.c | 16 +- contrib/byacc/output.c | 155 ++++++---- contrib/byacc/reader.c | 734 ++++++++++++++++++++++++++++++++++-------------- contrib/byacc/verbose.c | 4 +- contrib/byacc/yaccpar.c | 76 ++--- 13 files changed, 1312 insertions(+), 511 deletions(-) diff --git a/contrib/byacc/CHANGES b/contrib/byacc/CHANGES index 1f01461540..c094671271 100644 --- a/contrib/byacc/CHANGES +++ b/contrib/byacc/CHANGES @@ -1,4 +1,376 @@ -2014-10-06 Thomas E. Dickey +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: + fix another uninitialized variable warning in "make check_make" for btyacc + + * test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/ok_syntax1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/calc3.tab.c, btyaccpar.c, btyaccpar.skel, test/yacc/ok_syntax1.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/calc3.tab.c, yaccpar.c, defs.h, yaccpar.skel, output.c: + fix some compiler warnings for "make check_make" by adding section init_vars, + which initializes the body_vars for pure-parser configuration. + +2017-04-30 Tom.Shields + + * output.c: + use YY_NO_LEAKS set in configure --with-no-leaks, in the generated code + +2017-04-30 Julien.Ramseier + + * main.c, test/yacc/big_l.output: + fix typo in unsupported-flag warning message + +2017-04-30 Thomas E. Dickey + + * 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 + + * config.guess: 2017-03-05 + +2017-02-01 Thomas E. Dickey + + * test/btyacc/expr.oxout.error, test/btyacc/expr.oxout.output, test/btyacc/expr.oxout.tab.c, test/btyacc/expr.oxout.tab.h, test/yacc/expr.oxout.error, test/yacc/expr.oxout.output, test/yacc/expr.oxout.tab.c, test/yacc/expr.oxout.tab.h: + RCS_BASE + + * package/debian/copyright: update copyright + + * reader.c, defs.h, main.c: + avoid using regex.h since some low-end platforms do not have this + + * test/expr.oxout.y: RCS_BASE + + * configure: regen + + * aclocal.m4: quiet a strict gcc warning in CF_MKSTEMP + +2017-02-01 Tom.Shields + + * main.c, reader.c, defs.h: + process #line directives, like bison and flex + +2017-02-01 Thomas E. Dickey + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2016-12-31 Thomas E. Dickey + + * config.guess, config.sub: 2017-01-01 + +2016-12-02 Thomas E. Dickey + + * test/btyacc/quote_calc4-s.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/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.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/rename_debug.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, btyaccpar.c: + regen + + * btyaccpar.skel: changes from NetBSD + + use YYINT rather than short in btyaccpar.skel + (some of this had already been done by Tom Shields) + + remove some casts of malloc/realloc + + * yaccpar.c, yaccpar.skel, output.c: changes from NetBSD + - Add some more bison stuff to make the mesa/gallium parser work: + %initial-action (add missing source struct member in location) + %debug (unimplemented) + %error-verbose (unimplemented) + + This changes some existing code: + + yylloc is now a pointer, so + + the first parameter to YYERROR_DECL() is a pointer + + struct YYLTYPE now has a "source" field + + * test/btyacc/btyacc_demo.tab.h, test/btyacc/code_calc.tab.c, test/btyacc/code_error.tab.c, test/btyacc/err_inherit4.tab.h: + regen + + * btyaccpar.c, btyaccpar.skel, reader.c: changes from NetBSD + - Add some more bison stuff to make the mesa/gallium parser work: + %initial-action (add missing source struct member in location) + %debug (unimplemented) + %error-verbose (unimplemented) + + This changes some existing code: + + yylloc is now a pointer, so + + the first parameter to YYERROR_DECL() is a pointer + + struct YYLTYPE now has a "source" field + + * reader.c: + fix from NetBSD: correct off-by-one when adding a null in copy_param() + + * reader.c: adapted from NetBSD + - Convert *most* error fingerprints to: + -unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) + +unterminated_arglist(const struct ainfo *a) + - Cast new args to unsigned char + + * defs.h: changes from NetBSD + - Add some more bison stuff to make the mesa/gallium parser work: + %initial-action (add missing source struct member in location) + %debug (unimplemented) + %error-verbose (unimplemented) + + This changes some existing code: + + yylloc is now a pointer, so + + the first parameter to YYERROR_DECL() is a pointer + + struct YYLTYPE now has a "source" field + + * defs.h: adapted from NetBSD + - Convert *most* error fingerprints to: + -unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) + +unterminated_arglist(const struct ainfo *a) + - Cast new args to unsigned char + + * main.c: changes from NetBSD + - Add some more bison stuff to make the mesa/gallium parser work: + %initial-action (add missing source struct member in location) + %debug (unimplemented) + %error-verbose (unimplemented) + + This changes some existing code: + + yylloc is now a pointer, so + + the first parameter to YYERROR_DECL() is a pointer + + struct YYLTYPE now has a "source" field + + * error.c: adapted from NetBSD + - Convert *most* error fingerprints to: + -unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) + +unterminated_arglist(const struct ainfo *a) + - Cast new args to unsigned char + + * mstring.c: adapted change from NetBSD to add casts for ctype macros + + * test/btyacc/btyacc_demo.tab.h, test/btyacc/err_inherit4.tab.h: regen + + * output.c: reorder to eliminate a forward-reference + +2016-12-02 Tom.Shields + + * output.c: + modify output to enable compilation of a lexer generated by flex (using + "%option bison-bridge" and "%option bison-locations") to be used with a parser + generated by b(t)yacc (using directives "%locations" and "%pure-parser"). + +2016-12-02 Thomas E. Dickey + + * configure: regen + + * aclocal.m4: Improved autoconf macros + CF_CC_ENV_FLAGS + + improve split between compiler and options, prompted by report where user + had "ccache" before the compiler + + leave non-preprocessor options in "$CC" (but still copy them to "$CFLAGS" + since that's where they should be) + CF_GNU_SOURCE,v + + recent glibc (Debian 2.23-4 for example) has misordered ifdef/checks for new + symbol _DEFAULT_SOURCE, producing warning messages when only _GNU_SOURCE is + defined. Add a followup check to define _DEFAULT_SOURCE. + CF_XOPEN_SOURCE + + add "uclinux" to list of Linux's (patch by Yann E. Morin) + + use _GNU_SOURCE for cygwin headers + + build-fixes for OS/2 + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2016-11-20 Thomas E. Dickey + + * config.sub: 2016-11-19 + + * config.guess: 2016-10-02 + +2016-06-06 Thomas E. Dickey + + * configure: regen + + * aclocal.m4: improved autoconf macros: + CF_CC_ENV_FLAGS - don't limit the check to -I, -U and -D options, since the + added options can include various compiler options before and after + preprocessor options. + CF_PROG_LINT - add cpplint to programs to use; drop ad hoc tdlint and alint. + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * lalr.c: indented + + * btyaccpar.c: regen + + * skel2c: + adjust whitespace so that generated skeleton will follow the same format + as other code + + * mkpar.c, verbose.c, lr0.c, reader.c, error.c, output.c: indented + + * reader.c: fix two compiler warnings + + * 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/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/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/rename_debug.c, btyaccpar.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/err_syntax20.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/ok_syntax1.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/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, yaccpar.c: + regen + +2016-06-06 Tom.Shields + + * btyaccpar.skel, yaccpar.skel: + small fix for an edge case of initialized data in Chris Dodd's btyacc changes: + "Avoid crash when input pops up an Action error at the first token" + +2016-06-01 Thomas E. Dickey + + * test/yacc/quote_calc2-s.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/err_syntax18.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/err_syntax24.error, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/ok_syntax1.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_calc.tab.c, test/yacc/code_calc.tab.h, 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/rename_debug.c, yaccpar.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/err_syntax13.tab.c, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax2.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax24.error, test/btyacc/err_syntax24.tab.c, test/btyacc/err_syntax25.tab.c, test/btyacc/err_syntax26.tab.c, test/btyacc/err_syntax27.tab.c, test/btyacc/err_syntax3.tab.c, test/btyacc/err_syntax4.tab.c, test/btyacc/err_syntax5.tab.c, test/btyacc/err_syntax6.tab.c, test/btyacc/err_syntax7.tab.c, test/btyacc/err_syntax7a.tab.c, test/btyacc/err_syntax7b.tab.c, test/btyacc/err_syntax8.tab.c, test/btyacc/err_syntax8a.tab.c, test/btyacc/err_syntax9.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.output, 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/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.error, test/btyacc/btyacc_demo.output, 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_calc.tab.c, test/btyacc/code_calc.tab.h, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit1.tab.c, test/btyacc/err_inherit2.tab.c, test/btyacc/err_inherit3.output, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.output, test/btyacc/err_inherit4.tab.c, test/btyacc/err_inherit5.tab.c, test/btyacc/err_syntax1.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/rename_debug.c, btyaccpar.c: + regen + +2016-06-01 Tom.Shields + + * btyaccpar.skel, defs.h, error.c, output.c, reader.c, test/code_calc.y, test/err_inherit4.y, test/run_make.sh, yaccpar.skel: + fixes for issues in btyacc (report by Francis Andre): + + + correction to the placement of the #line directive for a %union specification + + + recovery of a set of casts originally added into btyaccpar.c rather than into + btyaccpar.skel, and so are lost whenever building from scratch + + + Chris Dodd's btyacc improved handling of inherited attributes to eliminate + implicit empty copy rules that are not necessary, and thereby avoiding the + introduction of extra parsing ambiguity + + + Chris Dodd's added support for @-N syntax to reference inherited position + information + + + correction to bad interaction between %token-table and YYDEBUG, where YYDEBUG + was required to be defined in order to compile the generated code + + + correction to yyname[] access in code included with YYDEBUG defined for + single character symbols not recognized (e.g., input containing '&' character + where grammar doesn't define that as a symbol) - map to existing + "illegal-symbol" entry in byname[] + + + fixes to test/run_make.sh: skip test-err_* files; in the bison test phase + skip additional files that contain features not supported by bison and + inhibit new bison warning messages + + + minor changes to btyaccpar.skel & yaccpar.skel so they are more similar in + their commonality; makes it easier to maintain the pair of files using + vimdiff + + + changes to a couple of test cases for coverage of #3, #4 and #5 above + +2016-06-01 Thomas E. Dickey + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2016-03-24 Thomas E. Dickey + + * reader.c: unused variable + + * package/pkgsrc/Makefile, package/debian/copyright: bump + +2016-03-24 Jung-uk.Kim + + * main.c: + correct logic for finding output suffix in the "-o" option, which matched + the first occurrence of ".c" in the name in 2005-08-13 changes rather than + at the end of the filename (patch by Jung-uk Kim) + +2016-03-24 Thomas E. Dickey + + * aclocal.m4: + update CF_WITH_MAN2HTML to use configured shell rather than /bin/sh + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2016-01-25 Thomas E. Dickey + + * config.guess, config.sub: 2016-01-01 + +2015-07-10 Thomas E. Dickey + + * lr0.c: fix a duplicate-free in the leak-checking + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + + * reader.c: + make cache-size clearer (prompted by discussion with Pedro Giffuni, + Oliver Pinter) + + * main.c: + make relationship with format/size clearer (prompted by discussion + with Pedro Giffuni, Oliver Pinter) + +2015-07-05 Thomas E. Dickey + + * configure: regen + + * package/pkgsrc/Makefile, package/mingw-byacc.spec, package/debian/copyright, package/debian/changelog, package/byacc.spec, VERSION: + bump + + * aclocal.m4: resync with my-autoconf + add configure option --with-man2html + + * makefile.in: add configure options --with-man2html + + * configure.in: add configure option --with-man2html + +2015-05-02 Thomas E. Dickey + + * config.guess: 2015-03-04 + + * config.sub: 2015-03-08 + +2014-11-28 Thomas E. Dickey + + * lr0.c: coverity #39181: memory leak + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2014-11-13 Jouk.Jansen + + * descrip.mms: + I sucessfully compiled byacc on my OpenVMS systems. However, I had to update + the descrip.mms to include some extra c-source files and some dependenxcies + so that it also works when the distribution is located on an ODS5 disk. + + The patched descrip.mms file can be found at: + http://nchrem.tnw.tudelft.nl/openvms/software2.html#BYACC + + Please feel free to insert the file in your distribution. + + Regards + Jouk. + +2014-10-06 Thomas E. Dickey * package/debian/source/format: change to native format to work around regression in Debian packaging. @@ -18,7 +390,7 @@ better fix for get_line, by ensuring there is enough space to null-terminate its result (prompted by discussion with Craig Rodrigues). -2014-10-05 Thomas E. Dickey +2014-10-05 Thomas E. Dickey * main.c: make change to umask before calling mkstemp, as suggested in Coverity #56902 @@ -89,7 +461,7 @@ modify copy_param() to handle resulting comma-separated list. Before, it only expected a single parameter. -2014-10-04 Thomas E. Dickey +2014-10-04 Thomas E. Dickey * reader.c: split-out save_param() from copy_param() @@ -110,28 +482,28 @@ * test/btyacc/btyacc_destroy3.tab.c, test/btyacc/btyacc_destroy1.tab.c, test/btyacc/btyacc_destroy2.tab.c, test/btyacc/btyacc_destroy3.error, test/btyacc/btyacc_destroy3.output, test/btyacc/btyacc_destroy3.tab.h, test/btyacc/btyacc_destroy2.error, test/btyacc/btyacc_destroy2.output, test/btyacc/btyacc_destroy2.tab.h: RCS_BASE -2014-10-03 Thomas E. Dickey +2014-10-03 Thomas E. Dickey * test/btyacc/btyacc_demo2.error, test/btyacc/btyacc_demo2.output, test/btyacc/btyacc_demo2.tab.c, test/btyacc/btyacc_demo2.tab.h, test/btyacc/btyacc_destroy1.error, test/btyacc/btyacc_destroy1.output, test/btyacc/btyacc_destroy1.tab.h, test/btyacc_destroy3.y, test/btyacc_destroy1.y, test/btyacc_destroy2.y: RCS_BASE -2014-10-02 Thomas E. Dickey +2014-10-02 Thomas E. Dickey * main.c, reader.c, defs.h: use calloc in get_line() when allocating line to ensure it is fully initialized, fixes a later uninitialized value in copy_param() (FreeBSD #193499). -2014-09-17 Thomas E. Dickey +2014-09-17 Thomas E. Dickey * closure.c, lalr.c, output.c, defs.h: rephrase odd addressing to fix Coverity #48848, #38950, #38860, not actually a bug. -2014-09-01 Thomas E. Dickey +2014-09-01 Thomas E. Dickey * config.sub: update to 2014-07-28 -2014-07-27 Thomas E. Dickey +2014-07-27 Thomas E. Dickey * configure: regen @@ -140,7 +512,7 @@ * package/pkgsrc/Makefile, VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec: bump -2014-07-15 Thomas E. Dickey +2014-07-15 Thomas E. Dickey * aclocal.m4: resync with my-autoconf (no change to configure script) @@ -151,7 +523,7 @@ make top-level "make check" work again, by adding another step to filtering the test results. -2014-07-14 Thomas E. Dickey +2014-07-14 Thomas E. Dickey * test/run_test.sh: changes from Garrett Cooper's patch: a) ensure that the script returns an error-code if there are differences @@ -170,12 +542,12 @@ * main.c: remove obsolete -D option from usage message -2014-05-27 Thomas E. Dickey +2014-05-27 Thomas E. Dickey * VERSION, package/byacc.spec, package/debian/changelog, 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: bump -2014-04-22 Thomas E. Dickey +2014-04-22 Thomas E. Dickey * mstring.c: use vsnprintf() to ensure that msprintf's buffer is large enough. @@ -203,12 +575,12 @@ drop "NOTES-btyacc-Changes" and "NOTES-btyacc-Disposition", merging relevant content into README.BTYACC -2014-04-22 Thomas E. Dickey +2014-04-22 Thomas E. Dickey * package/pkgsrc/Makefile, VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec: bump -2014-04-19 Thomas E. Dickey +2014-04-19 Thomas E. Dickey * config.sub: 2014-04-03 @@ -218,7 +590,7 @@ * main.c, defs.h: patch to allow DEBUG build with WIN32 system -2014-04-09 Thomas E. Dickey +2014-04-09 Thomas E. Dickey * output.c, reader.c: gcc warnings @@ -259,7 +631,7 @@ * yacc.1: clarify relationship of btyacc features to default configuration. -2014-04-08 Thomas E. Dickey +2014-04-08 Thomas E. Dickey * test/yacc/ok_syntax1.output, test/yacc/ok_syntax1.tab.c, test/yacc/ok_syntax1.tab.h, test/btyacc/ok_syntax1.output, test/btyacc/ok_syntax1.tab.c, test/btyacc/ok_syntax1.tab.h: reference output for testing @@ -282,7 +654,7 @@ * mstring.c: minor reformatting to make coverage analysis simpler -2014-04-07 Thomas E. Dickey +2014-04-07 Thomas E. Dickey * test/run_test.sh: tidy @@ -317,7 +689,7 @@ YYPATCH #define's to make test-outputs easier to compare #line's (report by Tom Shields) -2014-04-06 Thomas E. Dickey +2014-04-06 Thomas E. Dickey * reader.c: fix for valgrind (the calloc's are intentional - valgrind reported use of uninitialized memory) @@ -421,7 +793,7 @@ * test/run_make.sh: modify to avoid use of VPATH, which has no standard implementation -2014-04-05 Thomas E. Dickey +2014-04-05 Thomas E. Dickey * test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c: discard a change which merged CountLines() with explicit comparisons against @@ -452,13 +824,13 @@ * test/btyacc_demo.y: fix prototypes -2014-04-04 Thomas E. Dickey +2014-04-04 Thomas E. Dickey * reader.c, defs.h, main.c: more merging of Tom Shield's btyacc changes. In the merge, I moved the symbol_pval inside the btyacc ifdef's and added some more btyacc ifdefs -2014-04-03 Thomas E. Dickey +2014-04-03 Thomas E. Dickey * reader.c: merge-in 3/4 of btyacc's changes, deferring those which change test-outputs. @@ -472,7 +844,7 @@ Some of the merge uses ifdef-changes which I applied to ongoing resync, e.g., the introduction of PER_STATE. -2014-04-02 Thomas E. Dickey +2014-04-02 Thomas E. Dickey * test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c: regen @@ -507,7 +879,7 @@ * main.c: changes for btyacc -2014-04-01 Thomas E. Dickey +2014-04-01 Thomas E. Dickey * reader.c: integrate change by Tom Shields to use bsearch rather than successive @@ -522,7 +894,7 @@ * verbose.c: changes for btyacc, ifdef'd -2014-04-01 Thomas E. Dickey +2014-04-01 Thomas E. Dickey * mkpar.c: eliminate most of the ifdef's using macros @@ -534,7 +906,7 @@ new functions used for reporting errors from the btyacc configuration (I reordered some, and ifdef'd the new ones -TD) -2014-03-31 Thomas E. Dickey +2014-03-31 Thomas E. Dickey * test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c: omit the GCC_UNUSED, as noted by Tom Shields not really essential @@ -542,7 +914,7 @@ * test/btyacc/empty.tab.c, test/btyacc/err_inherit1.tab.c, test/btyacc/err_inherit2.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_inherit5.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax24.tab.c: regen -2014-03-29 Thomas E. Dickey +2014-03-29 Thomas E. Dickey * test/yacc/err_syntax22.tab.c, test/yacc/err_syntax23.tab.c, test/yacc/err_syntax24.tab.c, test/yacc/err_syntax25.tab.c, test/yacc/err_syntax26.tab.c, test/yacc/err_syntax3.tab.c, test/yacc/err_syntax4.tab.c, test/yacc/err_syntax5.tab.c, test/yacc/err_syntax6.tab.c, test/yacc/err_syntax7.tab.c, test/yacc/err_syntax7a.tab.c, test/yacc/err_syntax7b.tab.c, test/yacc/err_syntax8.tab.c, test/yacc/err_syntax8a.tab.c, test/yacc/err_syntax9.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax1.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax13.tab.c, test/yacc/err_syntax14.tab.c, test/yacc/err_syntax15.tab.c, test/yacc/err_syntax16.tab.c, test/yacc/err_syntax17.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax19.tab.c, test/yacc/err_syntax2.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/err_syntax21.tab.c, skeleton.c: comment-out yysccsid in the banner because it produces unnecessary compiler @@ -552,7 +924,7 @@ * test/run_test.sh: for yacc, ignore the inherit testcases, since they are btyacc-specific -2014-03-28 Thomas E. Dickey +2014-03-28 Thomas E. Dickey * test/yacc/varsyntax_calc1.error, test/yacc/varsyntax_calc1.output, test/yacc/varsyntax_calc1.tab.c, test/yacc/varsyntax_calc1.tab.h, test/yacc/err_inherit3.error, test/yacc/err_inherit3.output, test/yacc/err_inherit3.tab.c, test/yacc/err_inherit3.tab.h, test/yacc/err_inherit4.error, test/yacc/err_inherit4.output, test/yacc/err_inherit4.tab.c, test/yacc/err_inherit4.tab.h, test/yacc/err_inherit5.error, test/yacc/err_inherit5.output, test/yacc/err_inherit5.tab.c, test/yacc/err_inherit5.tab.h, test/yacc/inherit0.error, test/yacc/inherit0.output, test/yacc/inherit0.tab.c, test/yacc/inherit0.tab.h, test/yacc/inherit1.error, test/yacc/inherit1.output, test/yacc/inherit1.tab.c, test/yacc/inherit1.tab.h, test/yacc/inherit2.error, test/yacc/inherit2.output, test/yacc/inherit2.tab.c, test/yacc/inherit2.tab.h, test/yacc/empty.error, test/yacc/empty.output, test/yacc/empty.tab.c, test/yacc/empty.tab.h, test/yacc/err_inherit1.error, test/yacc/err_inherit1.output, test/yacc/err_inherit1.tab.c, test/yacc/err_inherit1.tab.h, test/yacc/err_inherit2.error, test/yacc/err_inherit2.output, test/yacc/err_inherit2.tab.c, test/yacc/err_inherit2.tab.h: reference output for testing @@ -582,7 +954,7 @@ * yacc.1: document -L/-B features from btyacc -2014-03-25 Thomas E. Dickey +2014-03-25 Thomas E. Dickey * yacc.1: typo @@ -601,7 +973,7 @@ * mstring.c: byacc-btyacc-20140323 -2014-03-25 Thomas E. Dickey +2014-03-25 Thomas E. Dickey * test/btyacc/RCS, test/yacc/RCS: PERMIT FILE @@ -616,7 +988,7 @@ * test/btyacc/err_syntax1.output, test/btyacc/err_syntax1.tab.c, test/btyacc/err_syntax1.tab.h, test/btyacc/err_syntax10.error, test/btyacc/err_syntax10.output, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax10.tab.h, test/btyacc/err_syntax11.error, test/btyacc/err_syntax11.output, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax11.tab.h, test/btyacc/err_syntax12.error, test/btyacc/err_syntax12.output, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax12.tab.h, test/btyacc/err_syntax13.error, test/btyacc/err_syntax13.output, test/btyacc/err_syntax13.tab.c, test/btyacc/err_syntax13.tab.h, test/btyacc/err_syntax14.error, test/btyacc/err_syntax14.output, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax14.tab.h, test/btyacc/err_syntax15.error, test/btyacc/err_syntax15.output, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax15.tab.h, test/btyacc/err_syntax16.error, test/btyacc/err_syntax16.output, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax16.tab.h, test/btyacc/err_syntax17.error, test/btyacc/err_syntax17.output, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax17.tab.h, test/btyacc/err_syntax18.error, test/btyacc/err_syntax18.output, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax18.tab.h, test/btyacc/err_syntax19.error, test/btyacc/err_syntax19.output, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax19.tab.h, test/btyacc/err_syntax2.output, test/btyacc/err_syntax2.tab.c, test/btyacc/err_syntax2.tab.h, test/btyacc/err_syntax20.error, test/btyacc/err_syntax20.output, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax20.tab.h, test/btyacc/err_syntax21.error, test/btyacc/err_syntax21.output, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax21.tab.h, test/btyacc/err_syntax22.error, test/btyacc/err_syntax22.output, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax22.tab.h, test/btyacc/err_syntax23.error, test/btyacc/err_syntax23.output, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax23.tab.h, test/btyacc/err_syntax24.error, test/btyacc/err_syntax24.output, test/btyacc/err_syntax24.tab.c, test/btyacc/err_syntax24.tab.h, test/btyacc/err_syntax25.error, test/btyacc/err_syntax25.output, test/btyacc/err_syntax25.tab.c, test/btyacc/err_syntax25.tab.h, test/btyacc/err_syntax26.error, test/btyacc/err_syntax26.output, test/btyacc/err_syntax26.tab.c, test/btyacc/err_syntax26.tab.h, test/btyacc/err_syntax3.output, test/btyacc/err_syntax3.tab.c, test/btyacc/err_syntax3.tab.h, test/btyacc/err_syntax4.output, test/btyacc/err_syntax4.tab.c, test/btyacc/err_syntax4.tab.h, test/btyacc/err_syntax5.output, test/btyacc/err_syntax5.tab.c, test/btyacc/err_syntax5.tab.h, test/btyacc/err_syntax6.output, test/btyacc/err_syntax6.tab.c, test/btyacc/err_syntax6.tab.h, test/btyacc/err_syntax7.output, test/btyacc/err_syntax7.tab.c, test/btyacc/err_syntax7.tab.h, test/btyacc/err_syntax7a.output, test/btyacc/err_syntax7a.tab.c, test/btyacc/err_syntax7a.tab.h, test/btyacc/err_syntax7b.output, test/btyacc/err_syntax7b.tab.c, test/btyacc/err_syntax7b.tab.h, test/btyacc/err_syntax8.output, test/btyacc/err_syntax8.tab.c, test/btyacc/err_syntax8.tab.h, test/btyacc/err_syntax8a.output, test/btyacc/err_syntax8a.tab.c, test/btyacc/err_syntax8a.tab.h, test/btyacc/err_syntax9.output, test/btyacc/err_syntax9.tab.c, test/btyacc/err_syntax9.tab.h: reference output for testing -2014-03-24 Thomas E. Dickey +2014-03-24 Thomas E. Dickey * defs.h: fix compiler warnings due to mputc() @@ -629,7 +1001,7 @@ * test/varsyntax_calc1.y, test/btyacc_calc1.y: testcase for btyacc -2014-03-23 Thomas E. Dickey +2014-03-23 Thomas E. Dickey * test/err_syntax26.error, test/err_syntax26.output, test/err_syntax26.tab.c, test/err_syntax26.tab.h, test/yacc/err_syntax26.error, test/yacc/err_syntax26.output, test/yacc/err_syntax26.tab.c, test/yacc/err_syntax26.tab.h: reference output for testing @@ -651,7 +1023,7 @@ * test/btyacc/quote_calc3-s.error, test/btyacc/quote_calc4-s.error, test/btyacc/quote_calc4.error, test/btyacc/grammar.dot, test/btyacc/grammar.error, test/btyacc/pure_calc.error, test/btyacc/pure_error.error, test/btyacc/quote_calc-s.error, test/btyacc/quote_calc.error, test/btyacc/quote_calc2-s.error, test/btyacc/quote_calc2.error, test/btyacc/quote_calc3.error, test/btyacc/err_syntax2.error, test/btyacc/err_syntax3.error, test/btyacc/err_syntax4.error, test/btyacc/err_syntax5.error, test/btyacc/err_syntax6.error, test/btyacc/err_syntax7.error, test/btyacc/err_syntax7a.error, test/btyacc/err_syntax7b.error, test/btyacc/err_syntax8.error, test/btyacc/err_syntax8a.error, test/btyacc/err_syntax9.error, test/btyacc/error.error, test/btyacc/calc1.error, test/btyacc/calc2.error, test/btyacc/calc3.error, test/btyacc/code_calc.error, test/btyacc/code_error.error, test/btyacc/empty.error, test/btyacc/err_syntax1.error, test/btyacc/btyacc_calc1.error, test/btyacc/btyacc_demo.error: reference output for testing -2014-03-23 Thomas E. Dickey +2014-03-23 Thomas E. Dickey * test/err_syntax23.error, test/err_syntax23.output, test/err_syntax23.tab.c, test/err_syntax23.tab.h, test/yacc/err_syntax23.error, test/yacc/err_syntax23.output, test/yacc/err_syntax23.tab.c, test/yacc/err_syntax23.tab.h: reference output for testing @@ -663,7 +1035,7 @@ * test/run_test.sh: move test-outputs into subdirectories to keep btyacc/yacc results separate -2014-03-23 Thomas E. Dickey +2014-03-23 Thomas E. Dickey * test/err_syntax22.error, test/err_syntax22.output, test/err_syntax22.tab.c, test/err_syntax22.tab.h, test/yacc/err_syntax22.error, test/yacc/err_syntax22.output, test/yacc/err_syntax22.tab.c, test/yacc/err_syntax22.tab.h: reference output for testing @@ -692,7 +1064,7 @@ * test/err_syntax17.y: testcase for unterminated_action() -2014-03-22 Thomas E. Dickey +2014-03-22 Thomas E. Dickey * test/err_syntax16.error, test/err_syntax16.output, test/err_syntax16.tab.c, test/err_syntax16.tab.h, test/yacc/err_syntax16.error, test/yacc/err_syntax16.output, test/yacc/err_syntax16.tab.c, test/yacc/err_syntax16.tab.h: reference output for testing @@ -730,7 +1102,7 @@ * test/err_syntax10.y: testcase for retyped_warning() -2014-03-21 Thomas E. Dickey +2014-03-21 Thomas E. Dickey * test/err_syntax9.error, test/err_syntax9.output, test/err_syntax9.tab.c, test/err_syntax9.tab.h, test/yacc/err_syntax9.error, test/yacc/err_syntax9.output, test/yacc/err_syntax9.tab.c, test/yacc/err_syntax9.tab.h: reference output for testing @@ -850,7 +1222,7 @@ * lalr.c: rename MAXSHORT to MAXYYINT -2014-01-01 Thomas E. Dickey +2014-01-01 Thomas E. Dickey * yacc.1: document %token-table, improve presentation of double-quotes @@ -874,7 +1246,7 @@ - add YYTRANSLATE() macro - recognize bison's %token-table declaration -2014-01-01 Thomas E. Dickey +2014-01-01 Thomas E. Dickey * configure: regen @@ -886,19 +1258,19 @@ * configure.in: use CF_MAKE_DOCS -2013-12-26 Thomas E. Dickey +2013-12-26 Thomas E. Dickey * config.guess: 2013-11-29 -2013-11-19 Thomas E. Dickey +2013-11-19 Thomas E. Dickey * aclocal.m4: resync with my-autoconf (fixes for clang and mingw) -2013-10-25 Thomas E. Dickey +2013-10-25 Thomas E. Dickey * config.sub: 2013-10-01 -2013-09-25 Thomas E. Dickey +2013-09-25 Thomas E. Dickey * reader.c: fix two loop-limits found by clang 3.3 --analyze @@ -933,13 +1305,13 @@ * package/debian/changelog, VERSION, package/byacc.spec: bump -2013-09-07 Thomas E. Dickey +2013-09-07 Thomas E. Dickey * config.sub: update to 2013-09-15 * config.guess: update to 2013-06-10 -2013-03-04 Thomas E. Dickey +2013-03-04 Thomas E. Dickey * package/debian/changelog, VERSION, package/byacc.spec: bump @@ -969,11 +1341,11 @@ * aclocal.m4: another fix for CF_GCC_VERSION to handle Debian's modification of gcc message. -2013-02-10 Thomas E. Dickey +2013-02-10 Thomas E. Dickey * config.sub, config.guess: update to 2013-02-04 -2012-10-03 Thomas E. Dickey +2012-10-03 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -995,7 +1367,7 @@ suggested patch: drop CF_ANSI_CC_REQD, CF_ANSI_CC_CHECK, CF_PROG_EXT since they are not needed. -2012-10-03 Thomas E. Dickey +2012-10-03 Thomas E. Dickey * aclocal.m4: split-out CF_CC_ENV_FLAGS from CF_ANSI_CC_CHECK to avoid losing it in @@ -1029,13 +1401,13 @@ CF_MIXEDCASE_FILENAMES CF_NO_LEAKS_OPTION -2012-10-03 Thomas E. Dickey +2012-10-03 Thomas E. Dickey * aclocal.m4: move existence-check for mkstemp out of the AC_TRY_RUN, to help with cross-compiles -2012-10-02 Thomas E. Dickey +2012-10-02 Thomas E. Dickey * config_h.in: Adrian Bunk request - replace this with the output from autoheader @@ -1053,7 +1425,7 @@ * makefile.in: add assignment for datarootdir variable. -2012-05-26 Thomas E. Dickey +2012-05-26 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -1081,13 +1453,13 @@ use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation (no object change) -2012-05-25 Thomas E. Dickey +2012-05-25 Thomas E. Dickey * output.c, main.c, verbose.c, mkpar.c, lr0.c: use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation (no object change) -2012-01-15 Thomas E. Dickey +2012-01-15 Thomas E. Dickey * package/debian/copyright: bump @@ -1192,7 +1564,7 @@ * test/quote_calc2-s.tab.c, test/quote_calc3-s.tab.c, test/quote_calc4-s.tab.c, test/quote_calc-s.tab.c, test/quote_calc.tab.c, test/quote_calc2.tab.c, test/quote_calc3.tab.c, test/quote_calc4.tab.c: regen -2012-01-14 Thomas E. Dickey +2012-01-14 Thomas E. Dickey * test/calc2.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/calc1.tab.c: regen @@ -1223,7 +1595,7 @@ * test/run_test.sh: generate/test with "-s" option applied. -2012-01-13 Thomas E. Dickey +2012-01-13 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -1255,7 +1627,7 @@ * aclocal.m4: resync with my-autoconf, i.e., fixes for CF_XOPEN_SOURCE -2011-12-19 Thomas E. Dickey +2011-12-19 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -1269,7 +1641,7 @@ Simply suppressing the second #define makes the behavior closer to yacc. (report by Paulo Andrade). -2011-09-08 Thomas E. Dickey +2011-09-08 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -1277,7 +1649,7 @@ fix some more interaction between -i and -d flags to ensure YYERRCODE and YYSTYPE are declared, tested with cproto. -2011-09-07 Thomas E. Dickey +2011-09-07 Thomas E. Dickey * yacc.1: document "-i" option. @@ -1291,14 +1663,14 @@ * skeleton.c, output.c, defs.h: changes to support "-i" option. -2011-09-06 Thomas E. Dickey +2011-09-06 Thomas E. Dickey * reader.c: pass explicit file-pointer to write_section() * main.c: add "-i" option, to generate interface-file (suggested by Denis M. Wilson) -2011-09-05 Thomas E. Dickey +2011-09-05 Thomas E. Dickey * configure: regen @@ -1309,15 +1681,15 @@ * defs.h, error.c, reader.c: add check for missing "}" on %parse-param and %lex-param lines (report by Denis M Wilson) -2011-04-01 Thomas E. Dickey +2011-04-01 Thomas E. Dickey * config.sub: update to 2011-04-01 -2011-02-02 Thomas E. Dickey +2011-02-02 Thomas E. Dickey * config.guess: update to 2011-01-01 -2010-12-29 Thomas E. Dickey +2010-12-29 Thomas E. Dickey * defs.h, skeleton.c: add const qualifier to skeleton data, per NetBSD changes (report by Christos Zoulas) @@ -1339,7 +1711,7 @@ * test/ftp.y: improve example, which was stuck in 19XX and assumed file sizes were longs. -2010-12-29 Thomas E. Dickey +2010-12-29 Thomas E. Dickey * test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c: regen @@ -1357,11 +1729,11 @@ * output.c: correct definition for YYERROR_DECL() -2010-12-29 Thomas E. Dickey +2010-12-29 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump -2010-12-26 Thomas E. Dickey +2010-12-26 Thomas E. Dickey * defs.h, main.c: change return-type of allocate() to avoid warnings of alignment problems @@ -1381,7 +1753,7 @@ * aclocal.m4: improve quoting, deprecate ${name-value} in favor of standard ${name:-value} -2010-12-25 Thomas E. Dickey +2010-12-25 Thomas E. Dickey * main.c: start revising use of tmpfile(), to make this work with MinGW. Start by @@ -1390,7 +1762,7 @@ * package/debian/changelog, package/byacc.spec, VERSION: bump -2010-11-27 Thomas E. Dickey +2010-11-27 Thomas E. Dickey * package/byacc.spec, package/debian/changelog, VERSION: bump @@ -1400,7 +1772,7 @@ corrected use of %parse-param value in yyerror(); it doesn't use &yylval (report by Clifford Yapp) -2010-11-26 Thomas E. Dickey +2010-11-26 Thomas E. Dickey * skeleton.c: typo @@ -1451,7 +1823,7 @@ * package/debian/changelog, package/byacc.spec, VERSION: bump -2010-11-24 Thomas E. Dickey +2010-11-24 Thomas E. Dickey * main.c, defs.h, symtab.c, error.c: reduce global variables @@ -1461,7 +1833,7 @@ amend fix for Redhat #112617 to still call default_action_warning() for empty rules (report by Bruce Cran). -2010-11-22 Thomas E. Dickey +2010-11-22 Thomas E. Dickey * output.c: add ifdef to guard against redefinition of YYSTYPE union (request by Clifford Yapp). @@ -1493,20 +1865,20 @@ * package/debian/changelog, package/byacc.spec, VERSION: bump -2010-09-28 Thomas E. Dickey +2010-09-28 Thomas E. Dickey * config.guess: update to 2010-09-24 -2010-09-10 Thomas E. Dickey +2010-09-10 Thomas E. Dickey * config.sub: update to 2010-09-11 -2010-06-10 Thomas E. Dickey +2010-06-10 Thomas E. Dickey * yacc.1, package/debian/changelog, package/byacc.spec, VERSION: bump to 2010/06/10 -2010-06-09 Thomas E. Dickey +2010-06-09 Thomas E. Dickey * reader.c: free declarations in leak-testing code. @@ -1549,7 +1921,7 @@ * test/ftp.tab.c, test/ftp.y, reader.c, symtab.c, verbose.c, lr0.c, main.c, mkpar.c, output.c, defs.h, closure.c: fix warnings from clang --analyze -2010-06-08 Thomas E. Dickey +2010-06-08 Thomas E. Dickey * output.c: fix to build with c89, etc. @@ -1581,7 +1953,7 @@ add check_make and check_lint rules to help validate the generated files in the test-directory -2010-06-07 Thomas E. Dickey +2010-06-07 Thomas E. Dickey * test/pure_calc.tab.c, test/pure_error.tab.c: RCS_BASE @@ -1646,11 +2018,11 @@ anyway. This allows for better compatibility with yacc sources written for bison. -2010-06-07 Thomas E. Dickey +2010-06-07 Thomas E. Dickey * VERSION: bump to 2010/06/07 -2010-06-06 Thomas E. Dickey +2010-06-06 Thomas E. Dickey * test/calc.tab.c, configure: regen @@ -1701,12 +2073,12 @@ c) CF_GCC_VERSION, ignore stderr d) CF_GCC_WARNINGS, adjust options to work with c89 wrapper of gcc -2010-04-20 Thomas E. Dickey +2010-04-20 Thomas E. Dickey * package/debian/changelog, package/debian/compat, package/debian/control, package/debian/copyright, package/debian/docs, package/debian/postinst, package/debian/prerm, package/debian/rules, package/debian/watch: scripts from Debian package -2010-02-16 Thomas E. Dickey +2010-02-16 Thomas E. Dickey * yacc.1: document -P and bison-extensions @@ -1758,24 +2130,24 @@ * skeleton.c: fix a memory leak in the generated skeleton -2010-01-01 Thomas E. Dickey +2010-01-01 Thomas E. Dickey * package/debian/source/format: scripts from Debian package -2009-12-31 Thomas E. Dickey +2009-12-31 Thomas E. Dickey * config.guess: update to 2009-12-30 * config.sub: update to 2009-12-31 -2009-10-27 Thomas E. Dickey +2009-10-27 Thomas E. Dickey * VERSION: 20091027 * output.c, mkpar.c, defs.h, lalr.c, closure.c, graph.c, lr0.c, verbose.c, main.c, reader.c: strict compiler warnings -2009-10-26 Thomas E. Dickey +2009-10-26 Thomas E. Dickey * test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c: resync @@ -1790,44 +2162,44 @@ * aclocal.m4: resync with my-autoconf -2009-08-25 Thomas E. Dickey +2009-08-25 Thomas E. Dickey * config.guess, config.sub: update to 2009-08-19 -2009-02-21 Thomas E. Dickey +2009-02-21 Thomas E. Dickey * VERSION: bump * output.c: restore "yylval" symbol, omitted in cleanup on 2008/8/25 -2008-12-26 Thomas E. Dickey +2008-12-26 Thomas E. Dickey * configure: regen with autoconf-2.52 (patched) -2008-12-25 Thomas E. Dickey +2008-12-25 Thomas E. Dickey * test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c: regenerated -2008-12-24 Thomas E. Dickey +2008-12-24 Thomas E. Dickey * VERSION: bump * skeleton.c: remove ifdef-lint from goto yyerrlab, to quiet gcc warning -2008-11-26 Thomas E. Dickey +2008-11-26 Thomas E. Dickey * verbose.c, main.c, defs.h, mkpar.c, reader.c: completed implementation of "%expect" (report by Perry E. Metzger). add "%expect-rr", which is (unlike bison) allowable in LALR parsers. -2008-11-24 Thomas E. Dickey +2008-11-24 Thomas E. Dickey * closure.c, defs.h, error.c, graph.c, lalr.c, lr0.c, main.c, mkpar.c, output.c, reader.c, skeleton.c, symtab.c, verbose.c, warshall.c: change indent-style (request by Perry E. Metzger) -2008-08-27 Thomas E. Dickey +2008-08-27 Thomas E. Dickey * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: better implementation of YYPARSE_PARAM, using YYPARSE_DECL() macro @@ -1866,12 +2238,12 @@ * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: remove 'register' keywords -2008-08-26 Thomas E. Dickey +2008-08-26 Thomas E. Dickey * warshall.c, verbose.c, symtab.c, skeleton.c, reader.c, output.c, mkpar.c, main.c, lr0.c, lalr.c, graph.c, error.c, closure.c: remove 'register' keywords -2008-08-25 Thomas E. Dickey +2008-08-25 Thomas E. Dickey * test/ftp.tab.c: regen'd @@ -1911,7 +2283,7 @@ * makefile.in: add dependency on VERSION file. -2008-08-24 Thomas E. Dickey +2008-08-24 Thomas E. Dickey * VERSION: bump @@ -1929,18 +2301,18 @@ * aclocal.m4: resync with my-autoconf (no major changes) -2008-07-24 Thomas E. Dickey +2008-07-24 Thomas E. Dickey * package/pkgsrc/Makefile, package/pkgsrc/distinfo: scripts from NetBSD pkgsrc, for test-builds -2008-03-14 Thomas E. Dickey +2008-03-14 Thomas E. Dickey * config.sub: update to 2008-03-08 * config.guess: update to 2008-03-12 -2007-05-09 Thomas E. Dickey +2007-05-09 Thomas E. Dickey * main.c: close graph, verbose files if opened, on exit. @@ -1967,19 +2339,19 @@ * main.c: file_prefix did not always have a trailing null. -2007-03-25 Thomas E. Dickey +2007-03-25 Thomas E. Dickey * mkdirs.sh: improved version for "make -j" -2006-12-22 Thomas E. Dickey +2006-12-22 Thomas E. Dickey * config.guess: update to 2006/12/22 -2006-12-08 Thomas E. Dickey +2006-12-08 Thomas E. Dickey * config.sub: update to 2006/12/08 -2005-08-13 Thomas E. Dickey +2005-08-13 Thomas E. Dickey * main.c: add -V to usage message @@ -1998,23 +2370,23 @@ Debian #322858 (don't close union_file, which contained data). This feature is used in groff. -2005-08-13 Thomas E. Dickey +2005-08-13 Thomas E. Dickey * configure: regenerated * aclocal.m4: improve checks for Intel compiler warnings -2005-06-25 Thomas E. Dickey +2005-06-25 Thomas E. Dickey * config.sub: update to 2005/6/2 * config.guess: update to 2005/5/27 -2005-05-05 Thomas E. Dickey +2005-05-05 Thomas E. Dickey * defs.h: add a fallback for GCC_UNUSED -2005-05-04 Thomas E. Dickey +2005-05-04 Thomas E. Dickey * makefile.in: add "." to include-path to pickup config.h @@ -2069,7 +2441,7 @@ add "-o" to usage message. It is too long for a single line; rewrite usage() to show one option per line. -2005-05-03 Thomas E. Dickey +2005-05-03 Thomas E. Dickey * main.c: add -o option, to work with scripts that assume bison. simplify create_file_names() with a macro. @@ -2100,21 +2472,21 @@ add graphical output of the LALR(1) automaton for graphviz, associated with command-line option `-g' -2005-04-16 Thomas E. Dickey +2005-04-16 Thomas E. Dickey * config.sub: update to 2005/2/10 * config.guess: update to 2005/3/24 -2005-04-13 Thomas E. Dickey +2005-04-13 Thomas E. Dickey * package/pkgsrc/PLIST: scripts from NetBSD pkgsrc, for test-builds -2005-03-21 Thomas E. Dickey +2005-03-21 Thomas E. Dickey * package/pkgsrc/DESCR: scripts from NetBSD pkgsrc, for test-builds -2004-03-28 Thomas E. Dickey +2004-03-28 Thomas E. Dickey * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: updates due to adding yyparse() prototype @@ -2185,32 +2557,32 @@ * README: updated to note that this is not the original -2004-03-24 Thomas E. Dickey +2004-03-24 Thomas E. Dickey * test/grammar.y: RCS_BASE -2004-02-23 Thomas E. Dickey +2004-02-23 Thomas E. Dickey * config.sub: RCS_BASE -2004-02-17 Thomas E. Dickey +2004-02-17 Thomas E. Dickey * config.guess: RCS_BASE -2003-11-29 Thomas E. Dickey +2003-11-29 Thomas E. Dickey * install-sh: improved quoting -2002-06-29 Thomas E. Dickey +2002-06-29 Thomas E. Dickey * mkdirs.sh: don't use character range, since some locales don't work as expected -2001-06-22 Thomas E. Dickey +2001-06-22 Thomas E. Dickey * install-sh: RCS_BASE -2000-11-20 Thomas E. Dickey +2000-11-20 Thomas E. Dickey * test/calc.y: RCS_BASE @@ -2218,26 +2590,26 @@ * vmsbuild.com: original version -2000-02-23 Thomas E. Dickey +2000-02-23 dickey@clark.net * test/RCS, RCS: PERMIT FILE -2000-02-14 Thomas E. Dickey +2000-02-14 Thomas E. Dickey * main.c: fix for VMS port - making pathname for temp-file * descrip.mms: original version -2000-02-13 Thomas E. Dickey +2000-02-13 Thomas E. Dickey * defs.h, verbose.c, reader.c, main.c, skeleton.c, warshall.c, symtab.c, closure.c, mkpar.c, lalr.c, lr0.c, output.c, error.c: ansify -1999-11-30 Thomas E. Dickey +1999-11-30 Thomas E. Dickey * mkdirs.sh: RCS_BASE -1995-01-01 Thomas E. Dickey +1995-01-01 Thomas E. Dickey * config_h.in: RCS_BASE @@ -2257,7 +2629,7 @@ * test/ftp.output, test/ftp.tab.c, test/ftp.tab.h: RCS_BASE -1993-02-22 Thomas E. Dickey +1993-02-22 Thomas E. Dickey * test/yacc/error.output, test/yacc/error.tab.h: reference output for testing @@ -2297,7 +2669,7 @@ * symtab.c, lalr.c, error.c: original version -1990-01-16 Thomas E. Dickey +1990-01-16 Thomas E. Dickey * test/code_error.y, test/pure_error.y: RCS_BASE diff --git a/contrib/byacc/VERSION b/contrib/byacc/VERSION index 572a8c23c8..a86b7c7956 100644 --- a/contrib/byacc/VERSION +++ b/contrib/byacc/VERSION @@ -1 +1 @@ -20141006 +20170709 diff --git a/contrib/byacc/defs.h b/contrib/byacc/defs.h index 0124a84a5d..eac530515e 100644 --- a/contrib/byacc/defs.h +++ b/contrib/byacc/defs.h @@ -1,4 +1,4 @@ -/* $Id: defs.h,v 1.51 2014/10/02 22:38:13 tom Exp $ */ +/* $Id: defs.h,v 1.59 2017/07/09 18:12:46 tom Exp $ */ #ifdef HAVE_CONFIG_H #include @@ -118,10 +118,13 @@ #define LEX_PARAM 14 #define POSIX_YACC 15 #define TOKEN_TABLE 16 +#define ERROR_VERBOSE 17 +#define XXXDEBUG 18 #if defined(YYBTYACC) -#define LOCATIONS 17 -#define DESTRUCTOR 18 +#define LOCATIONS 19 +#define DESTRUCTOR 20 +#define INITIAL_ACTION 21 #endif /* symbol classes */ @@ -143,7 +146,9 @@ /* 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') @@ -198,7 +203,7 @@ struct bucket #if defined(YYBTYACC) char **argnames; char **argtags; - int args; + int args; char *destructor; #endif Value_t value; @@ -287,10 +292,12 @@ extern int outline; extern int exit_code; extern int pure_parser; extern int token_table; +extern int error_verbose; #if defined(YYBTYACC) extern int locations; extern int backtrack; extern int destructor; +extern char *initial_action; #endif extern const char *const banner[]; @@ -302,11 +309,14 @@ extern const char *const hdr_defs[]; extern const char *const hdr_vars[]; extern const char *const body_1[]; extern const char *const body_vars[]; +extern const char *const init_vars[]; extern const char *const body_2[]; +extern const char *const body_3[]; extern const char *const trailer[]; extern char *code_file_name; extern char *input_file_name; +extern size_t input_file_name_len; extern char *defines_file_name; extern char *externs_file_name; @@ -412,22 +422,29 @@ extern param *parse_param; #endif #ifndef GCC_PRINTFLIKE -#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ +#define GCC_PRINTFLIKE(fmt,var) /*nothing */ #endif /* closure.c */ -extern void closure(Value_t * nucleus, int n); +extern void closure(Value_t *nucleus, int n); extern void finalize_closure(void); extern void set_first_derives(void); /* error.c */ +struct ainfo +{ + int a_lineno; + char *a_line; + char *a_cptr; +}; + extern void arg_number_disagree_warning(int a_lineno, char *a_name); extern void arg_type_disagree_warning(int a_lineno, int i, char *a_name); extern void at_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void at_warning(int a_lineno, int i); extern void bad_formals(void) GCC_NORETURN; -extern void default_action_warning(void); -extern void destructor_redeclared_warning(int a_lineno, char *a_line, char *a_cptr); +extern void default_action_warning(char *s); +extern void destructor_redeclared_warning(const struct ainfo *); extern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void dollar_warning(int a_lineno, int i); extern void fatal(const char *msg) GCC_NORETURN; @@ -454,16 +471,16 @@ extern void unexpected_EOF(void) GCC_NORETURN; extern void unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char *d_line, const char *d_cptr); extern void unknown_rhs(int i) GCC_NORETURN; extern void unsupported_flag_warning(const char *flag, const char *details); -extern void unterminated_action(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; -extern void unterminated_comment(int c_lineno, char *c_line, char *c_cptr) GCC_NORETURN; -extern void unterminated_string(int s_lineno, char *s_line, char *s_cptr) GCC_NORETURN; -extern void unterminated_text(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN; -extern void unterminated_union(int u_lineno, char *u_line, char *u_cptr) GCC_NORETURN; +extern void unterminated_action(const struct ainfo *) GCC_NORETURN; +extern void unterminated_comment(const struct ainfo *) GCC_NORETURN; +extern void unterminated_string(const struct ainfo *) GCC_NORETURN; +extern void unterminated_text(const struct ainfo *) GCC_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); extern void untyped_lhs(void) GCC_NORETURN; extern void untyped_rhs(int i, char *s) GCC_NORETURN; extern void used_reserved(char *s) GCC_NORETURN; -extern void unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; +extern void 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); diff --git a/contrib/byacc/error.c b/contrib/byacc/error.c index a042aec71e..07dc89417c 100644 --- a/contrib/byacc/error.c +++ b/contrib/byacc/error.c @@ -1,4 +1,4 @@ -/* $Id: error.c,v 1.11 2014/04/07 22:22:49 tom Exp $ */ +/* $Id: error.c,v 1.14 2016/12/02 18:35:55 tom Exp $ */ /* routines for printing error messages */ @@ -77,38 +77,38 @@ syntax_error(int st_lineno, char *st_line, char *st_cptr) } void -unterminated_comment(int c_lineno, char *c_line, char *c_cptr) +unterminated_comment(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n", - myname, c_lineno, input_file_name); - print_pos(c_line, c_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } void -unterminated_string(int s_lineno, char *s_line, char *s_cptr) +unterminated_string(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n", - myname, s_lineno, input_file_name); - print_pos(s_line, s_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } void -unterminated_text(int t_lineno, char *t_line, char *t_cptr) +unterminated_text(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n", - myname, t_lineno, input_file_name); - print_pos(t_line, t_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } void -unterminated_union(int u_lineno, char *u_line, char *u_cptr) +unterminated_union(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \ -declaration\n", myname, u_lineno, input_file_name); - print_pos(u_line, u_cptr); +declaration\n", myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } @@ -218,11 +218,11 @@ specifiers\n", myname, lineno, input_file_name); } void -unterminated_action(int a_lineno, char *a_line, char *a_cptr) +unterminated_action(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n", - myname, a_lineno, input_file_name); - print_pos(a_line, a_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } @@ -267,11 +267,12 @@ unknown_rhs(int i) } void -default_action_warning(void) +default_action_warning(char *s) { fprintf(stderr, - "%s: w - line %d of \"%s\", the default action assigns an \ -undefined value to $$\n", myname, lineno, input_file_name); + "%s: w - line %d of \"%s\", the default action for %s assigns an \ +undefined value to $$\n", + myname, lineno, input_file_name, s); } void @@ -315,12 +316,12 @@ at_error(int a_lineno, char *a_line, char *a_cptr) } void -unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) +unterminated_arglist(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated argument list\n", - myname, a_lineno, input_file_name); - print_pos(a_line, a_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } @@ -393,10 +394,10 @@ start_requires_args(char *a_name) } void -destructor_redeclared_warning(int a_lineno, char *a_line, char *a_cptr) +destructor_redeclared_warning(const struct ainfo *a) { fprintf(stderr, "%s: w - line %d of \"%s\", destructor redeclared\n", - myname, a_lineno, input_file_name); - print_pos(a_line, a_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); } #endif diff --git a/contrib/byacc/lalr.c b/contrib/byacc/lalr.c index bf7e6a83d9..8d19b1a1ee 100644 --- a/contrib/byacc/lalr.c +++ b/contrib/byacc/lalr.c @@ -1,4 +1,4 @@ -/* $Id: lalr.c,v 1.11 2014/09/18 00:26:39 tom Exp $ */ +/* $Id: lalr.c,v 1.12 2016/06/07 00:28:03 tom Exp $ */ #include "defs.h" @@ -10,12 +10,12 @@ typedef struct shorts shorts; static Value_t map_goto(int state, int symbol); -static Value_t **transpose(Value_t ** R, int n); +static Value_t **transpose(Value_t **R, int n); static void add_lookback_edge(int stateno, int ruleno, int gotono); static void build_relations(void); static void compute_FOLLOWS(void); static void compute_lookaheads(void); -static void digraph(Value_t ** relation); +static void digraph(Value_t **relation); static void initialize_F(void); static void initialize_LA(void); static void set_accessing_symbol(void); @@ -147,12 +147,12 @@ initialize_LA(void) k = 0; for (i = 0; i < nstates; i++) { - lookaheads[i] = (Value_t) k; + lookaheads[i] = (Value_t)k; rp = reduction_table[i]; if (rp) k += rp->nreds; } - lookaheads[nstates] = (Value_t) k; + lookaheads[nstates] = (Value_t)k; LA = NEW2(k * tokensetsize, unsigned); LAruleno = NEW2(k, Value_t); @@ -212,15 +212,15 @@ set_goto_map(void) k = 0; for (i = ntokens; i < nsyms; i++) { - temp_map[i] = (Value_t) k; + temp_map[i] = (Value_t)k; k += goto_map[i]; } for (i = ntokens; i < nsyms; i++) goto_map[i] = temp_map[i]; - goto_map[nsyms] = (Value_t) ngotos; - temp_map[nsyms] = (Value_t) ngotos; + goto_map[nsyms] = (Value_t)ngotos; + temp_map[nsyms] = (Value_t)ngotos; from_state = NEW2(ngotos, Value_t); to_state = NEW2(ngotos, Value_t); @@ -264,7 +264,7 @@ map_goto(int state, int symbol) middle = (low + high) >> 1; s = from_state[middle]; if (s == state) - return (Value_t) (middle); + return (Value_t)(middle); else if (s < state) low = middle + 1; else @@ -463,12 +463,12 @@ add_lookback_edge(int stateno, int ruleno, int gotono) sp = NEW(shorts); sp->next = lookback[i]; - sp->value = (Value_t) gotono; + sp->value = (Value_t)gotono; lookback[i] = sp; } static Value_t ** -transpose(Value_t ** R2, int n) +transpose(Value_t **R2, int n) { Value_t **new_R; Value_t **temp_R; @@ -512,7 +512,7 @@ transpose(Value_t ** R2, int n) if (sp) { while (*sp >= 0) - *temp_R[*sp++]++ = (Value_t) i; + *temp_R[*sp++]++ = (Value_t)i; } } @@ -562,11 +562,11 @@ compute_lookaheads(void) } static void -digraph(Value_t ** relation) +digraph(Value_t **relation) { int i; - infinity = (Value_t) (ngotos + 2); + infinity = (Value_t)(ngotos + 2); INDEX = NEW2(ngotos + 1, Value_t); VERTICES = NEW2(ngotos + 1, Value_t); top = 0; @@ -598,7 +598,7 @@ traverse(int i) Value_t height; unsigned *base; - VERTICES[++top] = (Value_t) i; + VERTICES[++top] = (Value_t)i; INDEX[i] = height = top; base = F + i * tokensetsize; diff --git a/contrib/byacc/lr0.c b/contrib/byacc/lr0.c index 162d1067d8..0ac211fd85 100644 --- a/contrib/byacc/lr0.c +++ b/contrib/byacc/lr0.c @@ -1,4 +1,4 @@ -/* $Id: lr0.c,v 1.16 2014/04/07 21:53:50 tom Exp $ */ +/* $Id: lr0.c,v 1.19 2016/06/07 00:21:53 tom Exp $ */ #include "defs.h" @@ -30,6 +30,8 @@ static reductions *last_reduction; static int nshifts; static Value_t *shift_symbol; +static Value_t *rules; + static Value_t *redset; static Value_t *shiftset; @@ -234,7 +236,7 @@ initialize_states(void) p->link = 0; p->number = 0; p->accessing_symbol = 0; - p->nitems = (Value_t) i; + p->nitems = (Value_t)i; for (i = 0; start_derives[i] >= 0; ++i) p->items[i] = rrhs[start_derives[i]]; @@ -270,7 +272,7 @@ new_itemsets(void) ksp = kernel_base[symbol]; } - *ksp++ = (Value_t) (i + 1); + *ksp++ = (Value_t)(i + 1); kernel_end[symbol] = ksp; } } @@ -299,9 +301,9 @@ new_state(int symbol) n = (unsigned)(iend - isp1); p = (core *)allocate((sizeof(core) + (n - 1) * sizeof(Value_t))); - p->accessing_symbol = (Value_t) symbol; - p->number = (Value_t) nstates; - p->nitems = (Value_t) n; + p->accessing_symbol = (Value_t)symbol; + p->number = (Value_t)nstates; + p->nitems = (Value_t)n; isp2 = p->items; while (isp1 < iend) @@ -407,7 +409,7 @@ save_shifts(void) (unsigned)(nshifts - 1) * sizeof(Value_t))); p->number = this_state->number; - p->nshifts = (Value_t) nshifts; + p->nshifts = (Value_t)nshifts; sp1 = shiftset; sp2 = p->shift; @@ -445,7 +447,7 @@ save_reductions(void) item = ritem[*isp]; if (item < 0) { - redset[count++] = (Value_t) - item; + redset[count++] = (Value_t)-item; } } @@ -483,7 +485,6 @@ set_derives(void) { Value_t i, k; int lhs; - Value_t *rules; derives = NEW2(nsyms, Value_t *); rules = NEW2(nvars + nrules, Value_t); @@ -595,8 +596,12 @@ lr0_leaks(void) { if (derives) { - DO_FREE(derives[start_symbol]); + if (derives[start_symbol] != rules) + { + DO_FREE(derives[start_symbol]); + } DO_FREE(derives); + DO_FREE(rules); } DO_FREE(nullable); } diff --git a/contrib/byacc/main.c b/contrib/byacc/main.c index b43cd134a1..9a8099c5ec 100644 --- a/contrib/byacc/main.c +++ b/contrib/byacc/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.54 2014/10/06 22:40:07 tom Exp $ */ +/* $Id: main.c,v 1.60 2017/04/30 20:57:56 Julien.Ramseier Exp $ */ #include #ifndef _WIN32 @@ -48,13 +48,13 @@ const char *myname = "yacc"; int lineno; int outline; -static char empty_string[] = ""; static char default_file_prefix[] = "y"; static char *file_prefix = default_file_prefix; char *code_file_name; -char *input_file_name = empty_string; +char *input_file_name; +size_t input_file_name_len = 0; char *defines_file_name; char *externs_file_name; @@ -92,6 +92,7 @@ char *symbol_assoc; int pure_parser; int token_table; +int error_verbose; #if defined(YYBTYACC) Value_t *symbol_pval; @@ -99,6 +100,7 @@ char **symbol_destructor; char **symbol_type_tag; int locations = 0; /* default to no position processing */ int backtrack = 0; /* default is no backtracking */ +char *initial_action = NULL; #endif int exit_code; @@ -264,7 +266,7 @@ setflag(int ch) #if defined(YYBTYACC) locations = 1; #else - unsupported_flag_warning("-B", "reconfigure with --enable-btyacc"); + unsupported_flag_warning("-L", "reconfigure with --enable-btyacc"); #endif break; @@ -379,7 +381,10 @@ getargs(int argc, char *argv[]) no_more_options:; if (i + 1 != argc) usage(); - input_file_name = argv[i]; + input_file_name_len = strlen(argv[i]); + input_file_name = TMALLOC(char, input_file_name_len + 1); + NO_SPACE(input_file_name); + strcpy(input_file_name, argv[i]); } void * @@ -410,32 +415,46 @@ alloc_file_name(size_t len, const char *suffix) return result; } +static char * +find_suffix(char *name, const char *suffix) +{ + size_t len = strlen(name); + size_t slen = strlen(suffix); + if (len >= slen) + { + name += len - slen; + if (strcmp(name, suffix) == 0) + return name; + } + return NULL; +} + static void create_file_names(void) { size_t len; const char *defines_suffix; const char *externs_suffix; - char *prefix; + char *suffix; - prefix = NULL; + suffix = NULL; defines_suffix = DEFINES_SUFFIX; externs_suffix = EXTERNS_SUFFIX; /* compute the file_prefix from the user provided output_file_name */ if (output_file_name != 0) { - if (!(prefix = strstr(output_file_name, OUTPUT_SUFFIX)) - && (prefix = strstr(output_file_name, ".c"))) + if (!(suffix = find_suffix(output_file_name, OUTPUT_SUFFIX)) + && (suffix = find_suffix(output_file_name, ".c"))) { defines_suffix = ".h"; externs_suffix = ".i"; } } - if (prefix != NULL) + if (suffix != NULL) { - len = (size_t) (prefix - output_file_name); + len = (size_t) (suffix - output_file_name); file_prefix = TMALLOC(char, len + 1); NO_SPACE(file_prefix); strncpy(file_prefix, output_file_name, len)[len] = 0; @@ -477,7 +496,7 @@ create_file_names(void) CREATE_FILE_NAME(graph_file_name, GRAPH_SUFFIX); } - if (prefix != NULL) + if (suffix != NULL) { FREE(file_prefix); } @@ -551,6 +570,7 @@ my_mkstemp(char *temp) static FILE * open_tmpfile(const char *label) { +#define MY_FMT "%s/%.*sXXXXXX" FILE *result; #if USE_MKSTEMP int fd; @@ -569,7 +589,11 @@ open_tmpfile(const char *label) tmpdir = "."; } - name = malloc(strlen(tmpdir) + 10 + strlen(label)); + /* The size of the format is guaranteed to be longer than the result from + * printing empty strings with it; this calculation accounts for the + * string-lengths as well. + */ + name = malloc(strlen(tmpdir) + sizeof(MY_FMT) + strlen(label)); result = 0; if (name != 0) @@ -579,7 +603,7 @@ open_tmpfile(const char *label) if ((mark = strrchr(label, '_')) == 0) mark = label + strlen(label); - sprintf(name, "%s/%.*sXXXXXX", tmpdir, (int)(mark - label), label); + sprintf(name, MY_FMT, tmpdir, (int)(mark - label), label); fd = mkstemp(name); if (fd >= 0) { @@ -612,6 +636,7 @@ open_tmpfile(const char *label) if (result == 0) open_error(label); return result; +#undef MY_FMT } static void diff --git a/contrib/byacc/mkpar.c b/contrib/byacc/mkpar.c index 653c202251..759cb7e73b 100644 --- a/contrib/byacc/mkpar.c +++ b/contrib/byacc/mkpar.c @@ -1,4 +1,4 @@ -/* $Id: mkpar.c,v 1.14 2014/04/01 23:05:37 tom Exp $ */ +/* $Id: mkpar.c,v 1.15 2016/06/07 00:22:12 tom Exp $ */ #include "defs.h" @@ -84,7 +84,7 @@ get_shifts(int stateno) if (sp) { to_state2 = sp->shift; - for (i = (Value_t) (sp->nshifts - 1); i >= 0; i--) + for (i = (Value_t)(sp->nshifts - 1); i >= 0; i--) { k = to_state2[i]; symbol = accessing_symbol[k]; @@ -153,8 +153,8 @@ add_reduce(action *actions, temp = NEW(action); temp->next = next; - temp->symbol = (Value_t) symbol; - temp->number = (Value_t) ruleno; + temp->symbol = (Value_t)symbol; + temp->number = (Value_t)ruleno; temp->prec = rprec[ruleno]; temp->action_code = REDUCE; temp->assoc = rassoc[ruleno]; @@ -372,7 +372,7 @@ defreds(void) defred = NEW2(nstates, Value_t); for (i = 0; i < nstates; i++) - defred[i] = (Value_t) sole_reduction(i); + defred[i] = (Value_t)sole_reduction(i); } static void diff --git a/contrib/byacc/mstring.c b/contrib/byacc/mstring.c index dc384e5a38..3bdb122973 100644 --- a/contrib/byacc/mstring.c +++ b/contrib/byacc/mstring.c @@ -1,4 +1,4 @@ -/* $Id: mstring.c,v 1.6 2014/04/22 23:36:31 tom Exp $ */ +/* $Id: mstring.c,v 1.7 2016/12/02 17:57:21 tom Exp $ */ #include #include @@ -157,20 +157,20 @@ strnscmp(const char *a, const char *b) { while (1) { - while (isspace(*a)) + while (isspace(UCH(*a))) a++; - while (isspace(*b)) + while (isspace(UCH(*b))) b++; while (*a && *a == *b) a++, b++; - if (isspace(*a)) + if (isspace(UCH(*a))) { - if (isalnum(a[-1]) && isalnum(*b)) + if (isalnum(UCH(a[-1])) && isalnum(UCH(*b))) break; } - else if (isspace(*b)) + else if (isspace(UCH(*b))) { - if (isalnum(b[-1]) && isalnum(*a)) + if (isalnum(UCH(b[-1])) && isalnum(UCH(*a))) break; } else @@ -186,7 +186,7 @@ strnshash(const char *s) while (*s) { - if (!isspace(*s)) + if (!isspace(UCH(*s))) h = (h << 5) - h + (unsigned char)*s; s++; } diff --git a/contrib/byacc/output.c b/contrib/byacc/output.c index ecd9494cac..9f87911d80 100644 --- a/contrib/byacc/output.c +++ b/contrib/byacc/output.c @@ -1,4 +1,4 @@ -/* $Id: output.c,v 1.74 2014/10/05 23:21:09 tom Exp $ */ +/* $Id: output.c,v 1.83 2017/07/09 18:13:42 tom Exp $ */ #include "defs.h" @@ -54,7 +54,7 @@ puts_code(FILE * fp, const char *s) } static void -puts_param_types(FILE * fp, param * list, int more) +puts_param_types(FILE * fp, param *list, int more) { param *p; @@ -79,7 +79,7 @@ puts_param_types(FILE * fp, param * list, int more) } static void -puts_param_names(FILE * fp, param * list, int more) +puts_param_names(FILE * fp, param *list, int more) { param *p; @@ -235,6 +235,43 @@ end_table(void) } static void +output_stype(FILE * fp) +{ + if (!unionized && ntags == 0) + { + putc_code(fp, '\n'); + putl_code(fp, "#if " + "! defined(YYSTYPE) && " + "! defined(YYSTYPE_IS_DECLARED)\n"); + putl_code(fp, "/* Default: YYSTYPE is the semantic value type. */\n"); + putl_code(fp, "typedef int YYSTYPE;\n"); + putl_code(fp, "# define YYSTYPE_IS_DECLARED 1\n"); + putl_code(fp, "#endif\n"); + } +} + +#if defined(YYBTYACC) +static void +output_ltype(FILE * fp) +{ + putc_code(fp, '\n'); + putl_code(fp, "#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED\n"); + putl_code(fp, "/* Default: YYLTYPE is the text position type. */\n"); + putl_code(fp, "typedef struct YYLTYPE\n"); + putl_code(fp, "{\n"); + putl_code(fp, " int first_line;\n"); + putl_code(fp, " int first_column;\n"); + putl_code(fp, " int last_line;\n"); + putl_code(fp, " int last_column;\n"); + putl_code(fp, " unsigned source;\n"); + putl_code(fp, "} YYLTYPE;\n"); + putl_code(fp, "#define YYLTYPE_IS_DECLARED 1\n"); + putl_code(fp, "#endif\n"); + putl_code(fp, "#define YYRHSLOC(rhs, k) ((rhs)[k])\n"); +} +#endif + +static void output_YYINT_typedef(FILE * fp) { /* generate the type used to index the various parser tables */ @@ -329,6 +366,8 @@ output_accessing_symbols(void) translate[i] = symbol_pval[gsymb]; } + putl_code(output_file, + "#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)\n"); /* yystos[] may be unused, depending on compile-time defines */ start_int_table("stos", translate[0]); @@ -348,6 +387,8 @@ output_accessing_symbols(void) end_table(); FREE(translate); + putl_code(output_file, + "#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */\n"); } } @@ -366,7 +407,7 @@ find_conflict_base(int cbase) if (j + cbase >= nconflicts) break; } - return (Value_t) i; + return (Value_t)i; } #endif @@ -412,7 +453,7 @@ token_actions(void) conflictcount++; conflicts[nconflicts++] = -1; j = find_conflict_base(cbase); - actionrow[csym + 2 * ntokens] = (Value_t) (j + 1); + actionrow[csym + 2 * ntokens] = (Value_t)(j + 1); if (j == cbase) { cbase = nconflicts; @@ -457,7 +498,7 @@ token_actions(void) else conflicts[nconflicts++] = -1; } - conflicts[nconflicts++] = (Value_t) (p->number - 2); + conflicts[nconflicts++] = (Value_t)(p->number - 2); } } #endif @@ -468,7 +509,7 @@ token_actions(void) conflictcount++; conflicts[nconflicts++] = -1; j = find_conflict_base(cbase); - actionrow[csym + 2 * ntokens] = (Value_t) (j + 1); + actionrow[csym + 2 * ntokens] = (Value_t)(j + 1); if (j == cbase) { cbase = nconflicts; @@ -512,7 +553,7 @@ token_actions(void) *s++ = actionrow[j]; } } - width[i] = (Value_t) (max - min + 1); + width[i] = (Value_t)(max - min + 1); } if (reducecount > 0) { @@ -529,10 +570,10 @@ token_actions(void) if (max < symbol_value[j]) max = symbol_value[j]; *r++ = symbol_value[j]; - *s++ = (Value_t) (actionrow[ntokens + j] - 2); + *s++ = (Value_t)(actionrow[ntokens + j] - 2); } } - width[nstates + i] = (Value_t) (max - min + 1); + width[nstates + i] = (Value_t)(max - min + 1); } #if defined(YYBTYACC) if (backtrack && conflictcount > 0) @@ -550,10 +591,10 @@ token_actions(void) if (max < symbol_value[j]) max = symbol_value[j]; *r++ = symbol_value[j]; - *s++ = (Value_t) (actionrow[2 * ntokens + j] - 1); + *s++ = (Value_t)(actionrow[2 * ntokens + j] - 1); } } - width[2 * nstates + i] = (Value_t) (max - min + 1); + width[2 * nstates + i] = (Value_t)(max - min + 1); } #endif } @@ -635,7 +676,7 @@ save_column(int symbol, int default_state) } tally[symno] = count; - width[symno] = (Value_t) (sp1[-1] - sp[0] + 1); + width[symno] = (Value_t)(sp1[-1] - sp[0] + 1); } static void @@ -871,7 +912,7 @@ pack_table(void) state = matching_vector(i); if (state < 0) - place = (Value_t) pack_vector(i); + place = (Value_t)pack_vector(i); else place = base[state]; @@ -1121,21 +1162,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); @@ -1198,6 +1239,16 @@ output_defines(FILE * fp) if (fp != defines_file || iflag) fprintf(fp, "#define YYERRCODE %d\n", symbol_value[1]); + if (token_table && rflag && fp != externs_file) + { + if (fp == code_file) + ++outline; + fputs("#undef yytname\n", fp); + if (fp == code_file) + ++outline; + fputs("#define yytname yyname\n", fp); + } + if (fp == defines_file || (iflag && !dflag)) { if (unionized) @@ -1210,6 +1261,10 @@ output_defines(FILE * fp) } fprintf(fp, "extern YYSTYPE %slval;\n", symbol_prefix); } +#if defined(YYBTYACC) + if (locations) + output_ltype(fp); +#endif } } @@ -1307,8 +1362,11 @@ output_debug(void) */ if (token_table) { - output_line("#undef yytname"); - output_line("#define yytname yyname"); + if (!rflag) + { + output_line("#undef yytname"); + output_line("#define yytname yyname"); + } } else { @@ -1526,38 +1584,16 @@ output_pure_parser(FILE * fp) putc_code(fp, '\n'); } +#if defined(YY_NO_LEAKS) static void -output_stype(FILE * fp) +output_no_leaks(FILE * fp) { - if (!unionized && ntags == 0) - { - putc_code(fp, '\n'); - putl_code(fp, "#if " - "! defined(YYSTYPE) && " - "! defined(YYSTYPE_IS_DECLARED)\n"); - putl_code(fp, "/* Default: YYSTYPE is the semantic value type. */\n"); - putl_code(fp, "typedef int YYSTYPE;\n"); - putl_code(fp, "# define YYSTYPE_IS_DECLARED 1\n"); - putl_code(fp, "#endif\n"); - } -} + putc_code(fp, '\n'); -#if defined(YYBTYACC) -static void -output_ltype(FILE * fp) -{ + if (fp == code_file) + ++outline; + fputs("#define YY_NO_LEAKS 1\n", fp); putc_code(fp, '\n'); - putl_code(fp, "#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED\n"); - putl_code(fp, "/* Default: YYLTYPE is the text position type. */\n"); - putl_code(fp, "typedef struct YYLTYPE\n"); - putl_code(fp, "{\n"); - putl_code(fp, " int first_line;\n"); - putl_code(fp, " int first_column;\n"); - putl_code(fp, " int last_line;\n"); - putl_code(fp, " int last_column;\n"); - putl_code(fp, "} YYLTYPE;\n"); - putl_code(fp, "#define YYLTYPE_IS_DECLARED 1\n"); - putl_code(fp, "#endif\n"); } #endif @@ -1768,7 +1804,7 @@ output_error_decl(FILE * fp) puts_code(fp, "#define YYERROR_DECL() yyerror("); #if defined(YYBTYACC) if (locations) - puts_code(fp, "YYLTYPE loc, "); + puts_code(fp, "YYLTYPE *loc, "); #endif puts_param_types(fp, parse_param, 1); putl_code(fp, "const char *s)\n"); @@ -1779,7 +1815,7 @@ output_error_decl(FILE * fp) puts_code(fp, "#define YYERROR_CALL(msg) yyerror("); #if defined(YYBTYACC) if (locations) - puts_code(fp, "yylloc, "); + puts_code(fp, "&yylloc, "); #endif puts_param_names(fp, parse_param, 1); putl_code(fp, "msg)\n"); @@ -1833,6 +1869,13 @@ output_yydestruct_decl(FILE * fp) } static void +output_initial_action(void) +{ + if (initial_action) + fprintf(code_file, "%s\n", initial_action); +} + +static void output_yydestruct_impl(void) { int i; @@ -1955,6 +1998,9 @@ output(void) output_prefix(fp); output_pure_parser(fp); +#if defined(YY_NO_LEAKS) + output_no_leaks(fp); +#endif output_stored_text(fp); output_stype(fp); #if defined(YYBTYACC) @@ -2038,6 +2084,15 @@ output(void) write_section(code_file, body_vars); } write_section(code_file, body_2); + if (pure_parser) + { + write_section(code_file, init_vars); + } +#if defined(YYBTYACC) + if (initial_action) + output_initial_action(); +#endif + write_section(code_file, body_3); output_semantic_actions(); write_section(code_file, trailer); } diff --git a/contrib/byacc/reader.c b/contrib/byacc/reader.c index d0d7b1a36d..ebf40d2a6d 100644 --- a/contrib/byacc/reader.c +++ b/contrib/byacc/reader.c @@ -1,4 +1,4 @@ -/* $Id: reader.c,v 1.58 2014/10/06 22:15:08 tom Exp $ */ +/* $Id: reader.c,v 1.73 2017/07/09 19:15:35 tom Exp $ */ #include "defs.h" @@ -22,10 +22,12 @@ static void start_rule(bucket *bp, int s_lineno); #if defined(YYBTYACC) +static void copy_initial_action(void); static void copy_destructor(void); static char *process_destructor_XX(char *code, char *tag); #endif +#define CACHE_SIZE 256 static char *cache; static int cinc, cache_size; @@ -42,6 +44,9 @@ static bucket *goal; static Value_t prec; static int gensym; static char last_was_action; +#if defined(YYBTYACC) +static int trialaction; +#endif static int maxitems; static bucket **pitem; @@ -95,7 +100,7 @@ cachec(int c) assert(cinc >= 0); if (cinc >= cache_size) { - cache_size += 256; + cache_size += CACHE_SIZE; cache = TREALLOC(char, cache, cache_size); NO_SPACE(cache); } @@ -103,56 +108,202 @@ cachec(int c) ++cinc; } -static void -get_line(void) +typedef enum { - FILE *f = input_file; - int c; - int i; + ldSPC1, + ldSPC2, + ldNAME, + ldSPC3, + ldNUM, + ldSPC4, + ldFILE, + ldOK, + ldERR +} +LINE_DIR; - if (saw_eof || (c = getc(f)) == EOF) +/* + * Expect this pattern: + * /^[[:space:]]*#[[:space:]]* + * line[[:space:]]+ + * [[:digit:]]+ + * ([[:space:]]*|[[:space:]]+"[^"]+")/ + */ +static int +line_directive(void) +{ +#define UNLESS(what) if (what) { ld = ldERR; break; } + int n; + int line_1st = -1; + int name_1st = -1; + int name_end = -1; + LINE_DIR ld = ldSPC1; + for (n = 0; (ld <= ldOK) && (line[n] != '\0'); ++n) { - if (line) + int ch = UCH(line[n]); + switch (ld) { - FREE(line); - line = 0; + case ldSPC1: + if (isspace(UCH(ch))) + { + break; + } + else + UNLESS(ch != '#'); + ld = ldSPC2; + break; + case ldSPC2: + if (isspace(UCH(ch))) + { + break; + } + /* FALLTHRU */ + case ldNAME: + UNLESS(strncmp(line + n, "line", 4)); + n += 4; + if (line[n] == '\0') + { + ld = ldOK; + break; + } + else + UNLESS(!isspace(UCH(line[n]))); + ld = ldSPC3; + break; + case ldSPC3: + if (isspace(UCH(ch))) + { + break; + } + else + UNLESS(!isdigit(UCH(ch))); + line_1st = n; + ld = ldNUM; + /* FALLTHRU */ + case ldNUM: + if (isdigit(UCH(ch))) + { + break; + } + else + UNLESS(!isspace(UCH(ch))); + ld = ldSPC4; + break; + case ldSPC4: + if (isspace(UCH(ch))) + { + break; + } + else + UNLESS(ch != '"'); + UNLESS(line[n + 1] == '"'); + ld = ldFILE; + name_1st = n; + break; + case ldFILE: + if (ch != '"') + { + break; + } + ld = ldOK; + name_end = n; + /* FALLTHRU */ + case ldERR: + case ldOK: + break; } - cptr = 0; - saw_eof = 1; - return; } - if (line == 0 || linesize != (LINESIZE + 1)) + if (ld == ldOK) { - if (line) - FREE(line); - linesize = LINESIZE + 1; - line = TMALLOC(char, linesize); - NO_SPACE(line); + size_t need = (size_t) (name_end - name_1st); + if ((long)need > (long)input_file_name_len) + { + 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); + } + 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'; + } } - i = 0; - ++lineno; - for (;;) + if (ld >= ldNUM && ld < ldERR) { - line[i++] = (char)c; - if (c == '\n') - break; - if ((i + 3) >= linesize) + if (line_1st >= 0) { - linesize += LINESIZE; - line = TREALLOC(char, line, linesize); - NO_SPACE(line); + lineno = (int)strtol(line + line_1st, NULL, 10) - 1; } - c = getc(f); - if (c == EOF) + else { - line[i++] = '\n'; + lineno = 0; + } + } + + return (ld == ldOK); +#undef UNLESS +} + +static void +get_line(void) +{ + FILE *f = input_file; + int c; + int i; + + do + { + if (saw_eof || (c = getc(f)) == EOF) + { + if (line) + { + FREE(line); + line = 0; + } + cptr = 0; saw_eof = 1; - break; + return; + } + + if (line == NULL || linesize != (LINESIZE + 1)) + { + if (line) + FREE(line); + linesize = LINESIZE + 1; + line = TMALLOC(char, linesize); + NO_SPACE(line); + } + + i = 0; + ++lineno; + for (;;) + { + line[i++] = (char)c; + if (c == '\n') + break; + if ((i + 3) >= linesize) + { + linesize += LINESIZE; + line = TREALLOC(char, line, linesize); + NO_SPACE(line); + } + c = getc(f); + if (c == EOF) + { + line[i++] = '\n'; + saw_eof = 1; + break; + } } + line[i] = '\0'; } - line[i] = '\0'; + while (line_directive()); cptr = line; return; } @@ -162,8 +313,8 @@ dup_line(void) { char *p, *s, *t; - if (line == 0) - return (0); + if (line == NULL) + return (NULL); s = line; while (*s != '\n') ++s; @@ -181,10 +332,10 @@ static void skip_comment(void) { char *s; - - int st_lineno = lineno; - char *st_line = dup_line(); - char *st_cptr = st_line + (cptr - line); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line); s = cptr + 2; for (;;) @@ -192,14 +343,14 @@ skip_comment(void) if (*s == '*' && s[1] == '/') { cptr = s + 2; - FREE(st_line); + FREE(a.a_line); return; } if (*s == '\n') { get_line(); - if (line == 0) - unterminated_comment(st_lineno, st_line, st_cptr); + if (line == NULL) + unterminated_comment(&a); s = cptr; } else @@ -212,10 +363,10 @@ next_inline(void) { char *s; - if (line == 0) + if (line == NULL) { get_line(); - if (line == 0) + if (line == NULL) return (EOF); } @@ -235,7 +386,7 @@ next_inline(void) else if (s[1] == '/') { get_line(); - if (line == 0) + if (line == NULL) return (EOF); s = cptr; break; @@ -286,17 +437,22 @@ nextc(void) /* *INDENT-OFF* */ static struct keyword { - char name[13]; + char name[14]; int token; } keywords[] = { { "binary", NONASSOC }, + { "debug", XXXDEBUG }, #if defined(YYBTYACC) { "destructor", DESTRUCTOR }, #endif + { "error-verbose",ERROR_VERBOSE }, { "expect", EXPECT }, { "expect-rr", EXPECT_RR }, { "ident", IDENT }, +#if defined(YYBTYACC) + { "initial-action", INITIAL_ACTION }, +#endif { "left", LEFT }, { "lex-param", LEX_PARAM }, #if defined(YYBTYACC) @@ -307,8 +463,8 @@ keywords[] = { { "pure-parser", PURE_PARSER }, { "right", RIGHT }, { "start", START }, - { "term", TOKEN }, - { "token", TOKEN }, + { "term", TOKEN }, + { "token", TOKEN }, { "token-table", TOKEN_TABLE }, { "type", TYPE }, { "union", UNION }, @@ -332,18 +488,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 == '$') @@ -385,6 +541,7 @@ keyword(void) return (NONASSOC); } syntax_error(lineno, line, t_cptr); + /*NOTREACHED */ } static void @@ -423,9 +580,10 @@ copy_string(int quote) { struct mstring *temp = msnew(); int c; - int s_lineno = lineno; - char *s_line = dup_line(); - char *s_cptr = s_line + (cptr - line - 1); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 1); for (;;) { @@ -433,11 +591,11 @@ copy_string(int quote) mputc(temp, c); if (c == quote) { - FREE(s_line); + FREE(a.a_line); return msdone(temp); } if (c == '\n') - unterminated_string(s_lineno, s_line, s_cptr); + unterminated_string(&a); if (c == '\\') { c = *cptr++; @@ -445,8 +603,8 @@ copy_string(int quote) if (c == '\n') { get_line(); - if (line == 0) - unterminated_string(s_lineno, s_line, s_cptr); + if (line == NULL) + unterminated_string(&a); } } } @@ -473,9 +631,10 @@ copy_comment(void) } else if (c == '*') { - int c_lineno = lineno; - char *c_line = dup_line(); - char *c_cptr = c_line + (cptr - line - 1); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 1); mputc(temp, c); ++cptr; @@ -487,14 +646,14 @@ copy_comment(void) { mputc(temp, '/'); ++cptr; - FREE(c_line); + FREE(a.a_line); return msdone(temp); } if (c == '\n') { get_line(); - if (line == 0) - unterminated_comment(c_lineno, c_line, c_cptr); + if (line == NULL) + unterminated_comment(&a); } } } @@ -507,15 +666,16 @@ copy_text(void) int c; FILE *f = text_file; int need_newline = 0; - int t_lineno = lineno; - char *t_line = dup_line(); - char *t_cptr = t_line + (cptr - line - 2); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 2); if (*cptr == '\n') { get_line(); - if (line == 0) - unterminated_text(t_lineno, t_line, t_cptr); + if (line == NULL) + unterminated_text(&a); } if (!lflag) fprintf(f, line_format, lineno, input_file_name); @@ -530,7 +690,7 @@ copy_text(void) get_line(); if (line) goto loop; - unterminated_text(t_lineno, t_line, t_cptr); + unterminated_text(&a); case '\'': case '"': @@ -560,7 +720,7 @@ copy_text(void) if (need_newline) putc('\n', f); ++cptr; - FREE(t_line); + FREE(a.a_line); return; } /* FALLTHRU */ @@ -593,23 +753,24 @@ copy_union(void) { int c; int depth; - int u_lineno = lineno; - char *u_line = dup_line(); - char *u_cptr = u_line + (cptr - line - 6); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 6); if (unionized) over_unionized(cptr - 6); unionized = 1; - if (!lflag) - fprintf(text_file, line_format, lineno, input_file_name); - puts_both("#ifdef YYSTYPE\n"); puts_both("#undef YYSTYPE_IS_DECLARED\n"); puts_both("#define YYSTYPE_IS_DECLARED 1\n"); puts_both("#endif\n"); puts_both("#ifndef YYSTYPE_IS_DECLARED\n"); puts_both("#define YYSTYPE_IS_DECLARED 1\n"); + + if (!lflag) + fprintf(text_file, line_format, lineno, input_file_name); puts_both("typedef union"); depth = 0; @@ -620,8 +781,8 @@ copy_union(void) { case '\n': get_line(); - if (line == 0) - unterminated_union(u_lineno, u_line, u_cptr); + if (line == NULL) + unterminated_union(&a); goto loop; case L_CURL: @@ -633,7 +794,7 @@ copy_union(void) { puts_both(" YYSTYPE;\n"); puts_both("#endif /* !YYSTYPE_IS_DECLARED */\n"); - FREE(u_line); + FREE(a.a_line); return; } goto loop; @@ -856,7 +1017,7 @@ copy_param(int k) else if (c == '\n') { get_line(); - if (line == 0) + if (line == NULL) unexpected_EOF(); --cptr; buf_size += (size_t) linesize; @@ -892,8 +1053,8 @@ copy_param(int k) goto oops; } - buf[i--] = '\0'; - i = trim_blanks(buf); + buf[++i] = '\0'; + (void)trim_blanks(buf); comma = buf - 1; do @@ -969,9 +1130,10 @@ get_literal(void) int n; char *s; bucket *bp; - int s_lineno = lineno; - char *s_line = dup_line(); - char *s_cptr = s_line + (cptr - line); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line); quote = *cptr++; cinc = 0; @@ -981,7 +1143,7 @@ get_literal(void) if (c == quote) break; if (c == '\n') - unterminated_string(s_lineno, s_line, s_cptr); + unterminated_string(&a); if (c == '\\') { char *c_cptr = cptr - 1; @@ -991,8 +1153,8 @@ get_literal(void) { case '\n': get_line(); - if (line == 0) - unterminated_string(s_lineno, s_line, s_cptr); + if (line == NULL) + unterminated_string(&a); continue; case '0': @@ -1064,7 +1226,7 @@ get_literal(void) } cachec(c); } - FREE(s_line); + FREE(a.a_line); n = cinc; s = TMALLOC(char, n); @@ -1087,7 +1249,7 @@ get_literal(void) cachec('\\'); cachec(c); } - else if (isprint(c)) + else if (isprint(UCH(c))) cachec(c); else { @@ -1181,13 +1343,22 @@ 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); + n = 0; + break; + } + } - return (n); + return (Value_t)(n); } static char * @@ -1234,7 +1405,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; @@ -1264,7 +1435,7 @@ scan_id(void) { char *b = cptr; - while (isalnum(*cptr) || *cptr == '_' || *cptr == '$') + while (IS_NAME2(UCH(*cptr))) cptr++; return cache_tag(b, (size_t) (cptr - b)); } @@ -1294,7 +1465,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(); @@ -1316,7 +1487,7 @@ declare_tokens(int assoc) { if (bp->prec && prec != bp->prec) reprec_warning(bp->name); - bp->assoc = (Assoc_t) assoc; + bp->assoc = (Assoc_t)assoc; bp->prec = prec; } @@ -1324,7 +1495,7 @@ declare_tokens(int assoc) if (c == EOF) unexpected_EOF(); - if (isdigit(c)) + if (isdigit(UCH(c))) { value = get_number(); if (bp->value != UNDEFINED && value != bp->value) @@ -1360,7 +1531,7 @@ declare_expect(int assoc) for (;;) { - if (isdigit(c)) + if (isdigit(UCH(c))) { if (assoc == EXPECT) SRexpect = get_number(); @@ -1373,7 +1544,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); } @@ -1428,7 +1599,7 @@ static void declare_types(void) { int c; - bucket *bp; + bucket *bp = NULL; char *tag = NULL; c = nextc(); @@ -1442,7 +1613,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) @@ -1480,7 +1651,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) @@ -1495,7 +1666,7 @@ read_declarations(void) { int c, k; - cache_size = 256; + cache_size = CACHE_SIZE; cache = TMALLOC(char, cache_size); NO_SPACE(cache); @@ -1556,6 +1727,10 @@ read_declarations(void) token_table = 1; break; + case ERROR_VERBOSE: + error_verbose = 1; + break; + #if defined(YYBTYACC) case LOCATIONS: locations = 1; @@ -1565,8 +1740,15 @@ read_declarations(void) destructor = 1; copy_destructor(); break; + case INITIAL_ACTION: + copy_initial_action(); + break; #endif + case XXXDEBUG: + /* XXX: FIXME */ + break; + case POSIX_YACC: /* noop for bison compatibility. byacc is already designed to be posix * yacc compatible. */ @@ -1648,9 +1830,11 @@ copy_args(int *alen) struct mstring *s = msnew(); int depth = 0, len = 1; char c, quote = 0; - int a_lineno = lineno; - char *a_line = dup_line(); - char *a_cptr = a_line + (cptr - line - 1); + struct ainfo a; + + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 1); while ((c = *cptr++) != R_PAREN || depth || quote) { @@ -1667,9 +1851,9 @@ copy_args(int *alen) if (!line) { if (quote) - unterminated_string(a_lineno, a_line, a_cptr); + unterminated_string(&a); else - unterminated_arglist(a_lineno, a_line, a_cptr); + unterminated_arglist(&a); } } else if (quote) @@ -1694,7 +1878,7 @@ copy_args(int *alen) } if (alen) *alen = len; - FREE(a_line); + FREE(a.a_line); return msdone(s); } @@ -1703,13 +1887,13 @@ parse_id(char *p, char **save) { char *b; - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; - if (!isalpha(*p) && *p != '_') + if (!isalpha(UCH(*p)) && *p != '_') return NULL; b = p; - while (isalnum(*p) || *p == '_' || *p == '$') + while (IS_NAME2(UCH(*p))) p++; if (save) { @@ -1723,7 +1907,7 @@ parse_int(char *p, int *save) { int neg = 0, val = 0; - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p == '-') @@ -1731,9 +1915,9 @@ parse_int(char *p, int *save) neg = 1; p++; } - if (!isdigit(*p)) + if (!isdigit(UCH(*p))) return NULL; - while (isdigit(*p)) + while (isdigit(UCH(*p))) val = val * 10 + *p++ - '0'; if (neg) val = -val; @@ -1748,7 +1932,7 @@ parse_arginfo(bucket *a, char *args, int argslen) char *p = args, *tmp; int i, redec = 0; - if (a->args > 0) + if (a->args >= 0) { if (a->args != argslen) arg_number_disagree_warning(rescan_lineno, a->name); @@ -1767,12 +1951,12 @@ parse_arginfo(bucket *a, char *args, int argslen) return; for (i = 0; i < argslen; i++) { - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p++ != '$') bad_formals(); - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p == '<') @@ -1780,7 +1964,7 @@ parse_arginfo(bucket *a, char *args, int argslen) havetags = 1; if (!(p = parse_id(p + 1, &tmp))) bad_formals(); - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p++ != '>') @@ -1797,7 +1981,7 @@ parse_arginfo(bucket *a, char *args, int argslen) a->argtags[i] = NULL; if (!(p = parse_id(p, &a->argnames[i]))) bad_formals(); - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p++) @@ -1830,7 +2014,7 @@ compile_arg(char **theptr, char *yyvaltag) for (j = 0, i++; i < nitems; i++) if (pitem[i]->class != ARGUMENT) - offsets[++j] = (Value_t) (i - nitems + 1); + offsets[++j] = (Value_t)(i - nitems + 1); } rhs = pitem + nitems - 1; @@ -1846,7 +2030,7 @@ compile_arg(char **theptr, char *yyvaltag) if (*++p == '<') if (!(p = parse_id(++p, &tag)) || *p++ != '>') illegal_tag(rescan_lineno, NULL, NULL); - if (isdigit(*p) || *p == '-') + if (isdigit(UCH(*p)) || *p == '-') { int val; if (!(p = parse_int(p, &val))) @@ -1870,7 +2054,7 @@ compile_arg(char **theptr, char *yyvaltag) else if (havetags) unknown_rhs(val); } - else if (isalpha(*p) || *p == '_') + else if (isalpha(UCH(*p)) || *p == '_') { char *arg; if (!(p = parse_id(p, &arg))) @@ -1882,8 +2066,8 @@ compile_arg(char **theptr, char *yyvaltag) unknown_arg_warning(rescan_lineno, "$", arg, NULL, NULL); else if (!tag) tag = plhs[nrules]->argtags[i]; - msprintf(c, "yystack.l_mark[%d]", i - plhs[nrules]->args + 1 - - n); + msprintf(c, "yystack.l_mark[%d]", + i - plhs[nrules]->args + 1 - n); if (tag) msprintf(c, ".%s", tag); else if (havetags) @@ -1909,6 +2093,90 @@ compile_arg(char **theptr, char *yyvaltag) return msdone(c); } +static int +can_elide_arg(char **theptr, char *yyvaltag) +{ + char *p = *theptr; + int rv = 0; + int i, j, n = 0; + Value_t *offsets = NULL, maxoffset = 0; + bucket **rhs; + char *tag = 0; + + if (*p++ != '$') + return 0; + if (*p == '<') + { + if (!(p = parse_id(++p, &tag)) || *p++ != '>') + return 0; + } + for (i = nitems - 1; pitem[i]; --i) + { + n++; + if (pitem[i]->class != ARGUMENT) + maxoffset++; + } + if (maxoffset > 0) + { + offsets = TMALLOC(Value_t, maxoffset + 1); + NO_SPACE(offsets); + + for (j = 0, i++; i < nitems; i++) + if (pitem[i]->class != ARGUMENT) + offsets[++j] = (Value_t)(i - nitems + 1); + } + rhs = pitem + nitems - 1; + + if (isdigit(UCH(*p)) || *p == '-') + { + int val; + if (!(p = parse_int(p, &val))) + rv = 0; + else + { + if (val <= 0) + rv = 1 - val + n; + else if (val > maxoffset) + rv = 0; + else + { + i = offsets[val]; + rv = 1 - i; + if (!tag) + tag = rhs[i]->tag; + } + } + } + else if (isalpha(UCH(*p)) || *p == '_') + { + char *arg; + if (!(p = parse_id(p, &arg))) + return 0; + for (i = plhs[nrules]->args - 1; i >= 0; i--) + if (arg == plhs[nrules]->argnames[i]) + break; + if (i >= 0) + { + if (!tag) + tag = plhs[nrules]->argtags[i]; + rv = plhs[nrules]->args + n - i; + } + } + if (tag && yyvaltag) + { + if (strcmp(tag, yyvaltag)) + rv = 0; + } + else if (tag || yyvaltag) + rv = 0; + if (maxoffset > 0) + FREE(offsets); + if (*p || rv <= 0) + return 0; + *theptr = p + 1; + return rv; +} + #define ARG_CACHE_SIZE 1024 static struct arg_cache { @@ -1960,7 +2228,7 @@ clean_arg_cache(void) arg_cache[i] = NULL; } } -#endif +#endif /* defined(YYBTYACC) */ static void advance_to_start(void) @@ -1999,7 +2267,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) @@ -2059,12 +2327,10 @@ end_rule(void) for (i = nitems - 1; (i > 0) && pitem[i]; --i) continue; if (pitem[i + 1] == 0 || pitem[i + 1]->tag != plhs[nrules]->tag) - default_action_warning(); + default_action_warning(plhs[nrules]->name); } else - { - default_action_warning(); - } + default_action_warning(plhs[nrules]->name); } last_was_action = 0; @@ -2081,6 +2347,7 @@ insert_empty_rule(void) bucket *bp, **bpp; assert(cache); + assert(cache_size >= CACHE_SIZE); sprintf(cache, "$$%d", ++gensym); bp = make_bucket(cache); last_symbol->next = bp; @@ -2091,7 +2358,7 @@ insert_empty_rule(void) bp->args = 0; #endif - nitems = (Value_t) (nitems + 2); + nitems = (Value_t)(nitems + 2); if (nitems > maxitems) expand_items(); bpp = pitem + nitems - 1; @@ -2122,13 +2389,14 @@ insert_arg_rule(char *arg, char *tag) { rule = nrules; insert_arg_cache(code, rule); + trialaction = 1; /* arg rules always run in trial mode */ fprintf(f, "case %d:\n", rule - 2); if (!lflag) fprintf(f, line_format, line_number, input_file_name); fprintf(f, "%s;\n", code); fprintf(f, "break;\n"); insert_empty_rule(); - plhs[rule]->tag = tag; + plhs[rule]->tag = cache_tag(tag, strlen(tag)); plhs[rule]->class = ARGUMENT; } else @@ -2199,11 +2467,33 @@ add_symbol(void) } else if (bp->args != argslen) wrong_number_args_warning("", bp->name); - if (bp->args > 0 && argslen > 0) + if (args != 0) { - char *ap; - int i; - for (ap = args, i = 0; i < argslen; i++) + char *ap = args; + int i = 0; + int elide_cnt = can_elide_arg(&ap, bp->argtags[0]); + + if (elide_cnt > argslen) + elide_cnt = 0; + if (elide_cnt) + { + for (i = 1; i < elide_cnt; i++) + if (can_elide_arg(&ap, bp->argtags[i]) != elide_cnt - i) + { + elide_cnt = 0; + break; + } + } + if (elide_cnt) + { + assert(i == elide_cnt); + } + else + { + ap = args; + i = 0; + } + for (; i < argslen; i++) ap = insert_arg_rule(ap, bp->argtags[i]); free(args); } @@ -2221,29 +2511,31 @@ copy_action(void) int i, j, n; int depth; #if defined(YYBTYACC) - int trialaction = 0; int haveyyval = 0; #endif char *tag; FILE *f = action_file; - int a_lineno = lineno; - char *a_line = dup_line(); - char *a_cptr = a_line + (cptr - line); + struct ainfo a; Value_t *offsets = NULL, maxoffset; bucket **rhs; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line); + if (last_was_action) insert_empty_rule(); last_was_action = 1; +#if defined(YYBTYACC) + trialaction = (*cptr == L_BRAC); +#endif fprintf(f, "case %d:\n", nrules - 2); #if defined(YYBTYACC) if (backtrack) { - if (*cptr != L_BRAC) + if (!trialaction) fprintf(f, " if (!yytrial)\n"); - else - trialaction = 1; } #endif if (!lflag) @@ -2275,7 +2567,7 @@ copy_action(void) { if (pitem[i]->class != ARGUMENT) { - offsets[++j] = (Value_t) (i - nitems + 1); + offsets[++j] = (Value_t)(i - nitems + 1); } } } @@ -2302,7 +2594,7 @@ copy_action(void) FREE(d_line); goto loop; } - else if (isdigit(c)) + else if (isdigit(UCH(c))) { i = get_number(); if (i == 0) @@ -2326,7 +2618,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--) @@ -2334,8 +2626,8 @@ copy_action(void) break; if (i < 0) unknown_arg_warning(d_lineno, "$", arg, d_line, d_cptr); - fprintf(f, "yystack.l_mark[%d].%s", i - plhs[nrules]->args + - 1 - n, tag); + fprintf(f, "yystack.l_mark[%d].%s", + i - plhs[nrules]->args + 1 - n, tag); FREE(d_line); goto loop; } @@ -2397,7 +2689,7 @@ copy_action(void) goto loop; } #if defined(YYBTYACC) - else if (isalpha(cptr[1]) || cptr[1] == '_') + else if (isalpha(UCH(cptr[1])) || cptr[1] == '_') { char *arg; ++cptr; @@ -2448,16 +2740,23 @@ copy_action(void) fprintf(f, "yystack.p_mark[%d]", offsets[i]); goto loop; } + else if (cptr[1] == '-') + { + cptr += 2; + i = get_number(); + fprintf(f, "yystack.p_mark[%d]", -i - n); + goto loop; + } } #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; @@ -2488,7 +2787,7 @@ copy_action(void) goto loop; } fprintf(f, "\nbreak;\n"); - FREE(a_line); + FREE(a.a_line); if (maxoffset > 0) FREE(offsets); return; @@ -2502,13 +2801,13 @@ copy_action(void) get_line(); if (line) goto loop; - unterminated_action(a_lineno, a_line, a_cptr); + unterminated_action(&a); case ';': if (depth > 0) goto loop; fprintf(f, "\nbreak;\n"); - free(a_line); + free(a.a_line); if (maxoffset > 0) FREE(offsets); return; @@ -2551,7 +2850,7 @@ copy_action(void) } #endif fprintf(f, "\nbreak;\n"); - free(a_line); + free(a.a_line); if (maxoffset > 0) FREE(offsets); return; @@ -2579,32 +2878,27 @@ copy_action(void) } #if defined(YYBTYACC) -static void -copy_destructor(void) +static char * +get_code(struct ainfo *a, const char *loc) { int c; int depth; char *tag; - bucket *bp; - struct mstring *destructor_text = msnew(); - char *code_text; - int a_lineno; - char *a_line; - char *a_cptr; + struct mstring *code_mstr = msnew(); if (!lflag) - msprintf(destructor_text, line_format, lineno, input_file_name); + msprintf(code_mstr, line_format, lineno, input_file_name); cptr = after_blanks(cptr); if (*cptr == L_CURL) /* avoid putting curly-braces in first column, to ease editing */ - mputc(destructor_text, '\t'); + mputc(code_mstr, '\t'); else syntax_error(lineno, line, cptr); - a_lineno = lineno; - a_line = dup_line(); - a_cptr = a_line + (cptr - line); + a->a_lineno = lineno; + a->a_line = dup_line(); + a->a_cptr = a->a_line + (cptr - line); depth = 0; loop: @@ -2622,7 +2916,7 @@ copy_destructor(void) c = *cptr; if (c == '$') { - msprintf(destructor_text, "(*val).%s", tag); + msprintf(code_mstr, "(*val).%s", tag); ++cptr; FREE(d_line); goto loop; @@ -2633,7 +2927,7 @@ copy_destructor(void) else if (cptr[1] == '$') { /* process '$$' later; replacement is context dependent */ - msprintf(destructor_text, "$$"); + msprintf(code_mstr, "$$"); cptr += 2; goto loop; } @@ -2647,29 +2941,29 @@ copy_destructor(void) char *l_cptr = l_line + (cptr - line); syntax_error(l_lineno, l_line, l_cptr); } - msprintf(destructor_text, "(*loc)"); + msprintf(code_mstr, "%s", loc); cptr += 2; goto loop; } - if (isalpha(c) || c == '_' || c == '$') + if (IS_NAME1(c)) { do { - mputc(destructor_text, c); + mputc(code_mstr, c); c = *++cptr; } - while (isalnum(c) || c == '_' || c == '$'); + while (IS_NAME2(c)); goto loop; } ++cptr; - mputc(destructor_text, c); + mputc(code_mstr, c); switch (c) { case '\n': get_line(); if (line) goto loop; - unterminated_action(a_lineno, a_line, a_cptr); + unterminated_action(a); case L_CURL: ++depth; @@ -2678,13 +2972,13 @@ copy_destructor(void) case R_CURL: if (--depth > 0) goto loop; - goto process_symbols; + goto out; case '\'': case '"': { char *s = copy_string(c); - msprintf(destructor_text, "%s", s); + msprintf(code_mstr, "%s", s); free(s); } goto loop; @@ -2692,7 +2986,7 @@ copy_destructor(void) case '/': { char *s = copy_comment(); - msprintf(destructor_text, "%s", s); + msprintf(code_mstr, "%s", s); free(s); } goto loop; @@ -2700,8 +2994,29 @@ copy_destructor(void) default: goto loop; } - process_symbols: - code_text = msdone(destructor_text); + out: + return msdone(code_mstr); +} + +static void +copy_initial_action(void) +{ + struct ainfo a; + + initial_action = get_code(&a, "yyloc"); + free(a.a_line); +} + +static void +copy_destructor(void) +{ + char *code_text; + int c; + struct ainfo a; + bucket *bp; + + code_text = get_code(&a, "(*loc)"); + for (;;) { c = nextc(); @@ -2720,7 +3035,7 @@ copy_destructor(void) default_destructor[UNTYPED_DEFAULT] = bp; } if (bp->destructor != NULL) - destructor_redeclared_warning(a_lineno, a_line, a_cptr); + destructor_redeclared_warning(&a); else /* replace "$$" with "(*val)" in destructor code */ bp->destructor = process_destructor_XX(code_text, NULL); @@ -2736,7 +3051,7 @@ copy_destructor(void) default_destructor[TYPED_DEFAULT] = bp; } if (bp->destructor != NULL) - destructor_redeclared_warning(a_lineno, a_line, a_cptr); + destructor_redeclared_warning(&a); else { /* postpone re-processing destructor $$s until end of grammar spec */ @@ -2747,20 +3062,20 @@ copy_destructor(void) } else { /* "semantic type" default destructor */ - tag = get_tag(); + char *tag = get_tag(); bp = lookup_type_destructor(tag); if (bp->destructor != NULL) - destructor_redeclared_warning(a_lineno, a_line, a_cptr); + destructor_redeclared_warning(&a); else /* replace "$$" with "(*val).tag" in destructor code */ 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) - destructor_redeclared_warning(a_lineno, a_line, a_cptr); + destructor_redeclared_warning(&a); else { /* postpone re-processing destructor $$s until end of grammar spec */ @@ -2772,7 +3087,7 @@ copy_destructor(void) else break; } - free(a_line); + free(a.a_line); free(code_text); } @@ -2797,14 +3112,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; @@ -2887,13 +3202,14 @@ 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(); else { syntax_error(lineno, line, cptr); + /*NOTREACHED */ } if (rprec[nrules] != UNDEFINED && bp->prec != rprec[nrules]) @@ -2917,7 +3233,7 @@ read_grammar(void) c = nextc(); if (c == EOF) break; - if (isalpha(c) + if (isalpha(UCH(c)) || c == '_' || c == '.' || c == '$' @@ -3064,8 +3380,8 @@ pack_symbols(void) if (bp->class == TERM) ++ntokens; } - start_symbol = (Value_t) ntokens; - nvars = (Value_t) (nsyms - ntokens); + start_symbol = (Value_t)ntokens; + nvars = (Value_t)(nsyms - ntokens); symbol_name = TMALLOC(char *, nsyms); NO_SPACE(symbol_name); @@ -3100,7 +3416,7 @@ pack_symbols(void) v[start_symbol] = 0; i = 1; - j = (Value_t) (start_symbol + 1); + j = (Value_t)(start_symbol + 1); for (bp = first_symbol; bp; bp = bp->next) { if (bp->class == TERM) @@ -3113,8 +3429,8 @@ pack_symbols(void) for (i = 1; i < ntokens; ++i) v[i]->index = i; - goal->index = (Index_t) (start_symbol + 1); - k = (Value_t) (start_symbol + 2); + goal->index = (Index_t)(start_symbol + 1); + k = (Value_t)(start_symbol + 2); while (++i < nsyms) if (v[i] != goal) { @@ -3124,7 +3440,7 @@ pack_symbols(void) goal->value = 0; k = 1; - for (i = (Value_t) (start_symbol + 1); i < nsyms; ++i) + for (i = (Value_t)(start_symbol + 1); i < nsyms; ++i) { if (v[i] != goal) { @@ -3197,7 +3513,7 @@ pack_symbols(void) symbol_prec[start_symbol] = 0; symbol_assoc[start_symbol] = TOKEN; #if defined(YYBTYACC) - symbol_pval[start_symbol] = (Value_t) (max_tok_pval + 1); + symbol_pval[start_symbol] = (Value_t)(max_tok_pval + 1); #endif for (++i; i < nsyms; ++i) { @@ -3207,7 +3523,7 @@ pack_symbols(void) symbol_prec[k] = v[i]->prec; symbol_assoc[k] = v[i]->assoc; #if defined(YYBTYACC) - symbol_pval[k] = (Value_t) ((max_tok_pval + 1) + v[i]->value + 1); + symbol_pval[k] = (Value_t)((max_tok_pval + 1) + v[i]->value + 1); if (destructor) { symbol_destructor[k] = v[i]->destructor; @@ -3294,7 +3610,7 @@ pack_grammar(void) } ++j; } - ritem[j] = (Value_t) - i; + ritem[j] = (Value_t)-i; ++j; if (rprec[i] == UNDEFINED) { @@ -3452,7 +3768,7 @@ reader(void) #ifdef NO_LEAKS static param * -free_declarations(param * list) +free_declarations(param *list) { while (list != 0) { diff --git a/contrib/byacc/verbose.c b/contrib/byacc/verbose.c index b4e110212a..1135e8f174 100644 --- a/contrib/byacc/verbose.c +++ b/contrib/byacc/verbose.c @@ -1,4 +1,4 @@ -/* $Id: verbose.c,v 1.11 2014/04/01 23:15:59 Tom.Shields Exp $ */ +/* $Id: verbose.c,v 1.12 2016/06/07 00:22:05 tom Exp $ */ #include "defs.h" @@ -230,7 +230,7 @@ print_nulls(int state) else if (i != null_rules[j]) { ++nnulls; - for (k = (Value_t) (nnulls - 1); k > j; --k) + for (k = (Value_t)(nnulls - 1); k > j; --k) null_rules[k] = null_rules[k - 1]; null_rules[j] = i; } diff --git a/contrib/byacc/yaccpar.c b/contrib/byacc/yaccpar.c index 717d735def..6186453019 100644 --- a/contrib/byacc/yaccpar.c +++ b/contrib/byacc/yaccpar.c @@ -1,8 +1,8 @@ /* This file generated automatically using - * @Id: skel2c,v 1.3 2014/04/06 19:48:04 tom Exp @ + * @Id: skel2c,v 1.4 2016/06/07 00:26:09 tom Exp @ */ -/* @Id: yaccpar.skel,v 1.5 2014/04/07 21:51:00 tom Exp @ */ +/* @Id: yaccpar.skel,v 1.8 2016/12/02 21:44:42 tom Exp @ */ #include "defs.h" @@ -55,8 +55,10 @@ const char *const tables[] = "extern YYINT yytable[];", "extern YYINT yycheck[];", "", - "#if YYDEBUG", + "#if YYDEBUG || defined(yytname)", "extern char *yyname[];", + "#endif", + "#if YYDEBUG", "extern char *yyrule[];", "#endif", 0 @@ -132,7 +134,7 @@ const char *const body_1[] = { "", "#if YYDEBUG", - "#include /* needed for printf */", + "#include /* needed for printf */", "#endif", "", "#include /* needed for malloc, etc */", @@ -209,6 +211,21 @@ const char *const body_2[] = " }", "#endif", "", + 0 +}; + +const char *const init_vars[] = +{ + " memset(&yyval, 0, sizeof(yyval));", + " memset(&yylval, 0, sizeof(yylval));", + "", + 0 +}; + +const char *const body_3[] = +{ + " yym = 0;", + " yyn = 0;", " yynerrs = 0;", " yyerrflag = 0;", " yychar = YYEMPTY;", @@ -228,28 +245,26 @@ const char *const body_2[] = " if ((yyn = yydefred[yystate]) != 0) goto yyreduce;", " if (yychar < 0)", " {", - " if ((yychar = YYLEX) < 0) yychar = YYEOF;", + " yychar = YYLEX;", + " if (yychar < 0) yychar = YYEOF;", "#if YYDEBUG", " if (yydebug)", " {", - " yys = yyname[YYTRANSLATE(yychar)];", + " 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]) && (yyn += yychar) >= 0 &&", - " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)", + " 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;", - " }", + " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;", " yystate = yytable[yyn];", " *++yystack.s_mark = yytable[yyn];", " *++yystack.l_mark = yylval;", @@ -257,18 +272,17 @@ const char *const body_2[] = " if (yyerrflag > 0) --yyerrflag;", " goto yyloop;", " }", - " if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&", - " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)", + " if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&", + " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)", " {", " yyn = yytable[yyn];", " goto yyreduce;", " }", - " if (yyerrflag) goto yyinrecovery;", + " if (yyerrflag != 0) goto yyinrecovery;", "", " YYERROR_CALL(\"syntax error\");", "", - " goto yyerrlab;", - "", + " goto yyerrlab; /* redundant goto avoids 'unused label' warning */", "yyerrlab:", " ++yynerrs;", "", @@ -278,18 +292,15 @@ const char *const body_2[] = " yyerrflag = 3;", " for (;;)", " {", - " if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&", - " yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)", + " 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;", - " }", + " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;", " yystate = yytable[yyn];", " *++yystack.s_mark = yytable[yyn];", " *++yystack.l_mark = yylval;", @@ -314,7 +325,7 @@ const char *const body_2[] = "#if YYDEBUG", " if (yydebug)", " {", - " yys = yyname[YYTRANSLATE(yychar)];", + " if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];", " printf(\"%sdebug: state %d, error recovery discards token %d (%s)\\n\",", " YYPREFIX, yystate, yychar, yys);", " }", @@ -330,10 +341,11 @@ const char *const body_2[] = " YYPREFIX, yystate, yyn, yyrule[yyn]);", "#endif", " yym = yylen[yyn];", - " if (yym)", + " if (yym > 0)", " yyval = yystack.l_mark[1-yym];", " else", " memset(&yyval, 0, sizeof yyval);", + "", " switch (yyn)", " {", 0 @@ -358,11 +370,12 @@ const char *const trailer[] = " *++yystack.l_mark = yyval;", " if (yychar < 0)", " {", - " if ((yychar = YYLEX) < 0) yychar = YYEOF;", + " yychar = YYLEX;", + " if (yychar < 0) yychar = YYEOF;", "#if YYDEBUG", " if (yydebug)", " {", - " yys = yyname[YYTRANSLATE(yychar)];", + " if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];", " printf(\"%sdebug: state %d, reading %d (%s)\\n\",", " YYPREFIX, YYFINAL, yychar, yys);", " }", @@ -371,8 +384,8 @@ const char *const trailer[] = " if (yychar == YYEOF) goto yyaccept;", " goto yyloop;", " }", - " if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&", - " yyn <= YYTABLESIZE && yycheck[yyn] == yystate)", + " if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&", + " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)", " yystate = yytable[yyn];", " else", " yystate = yydgoto[yym];", @@ -381,10 +394,7 @@ const char *const trailer[] = " printf(\"%sdebug: after reduction, shifting from state %d \\", "to state %d\\n\", YYPREFIX, *yystack.s_mark, yystate);", "#endif", - " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)", - " {", - " goto yyoverflow;", - " }", + " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;", " *++yystack.s_mark = (YYINT) yystate;", " *++yystack.l_mark = yyval;", " goto yyloop;", -- 2.11.4.GIT