summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* glr: style changeAkim Demaille2019-11-301-13/+7
| | | | | | * data/skeletons/glr.c (YYDPRINTF): Expand into an empty statement, instead of nothing. Simplify callers.
* glr: remove useless castsAkim Demaille2019-11-301-6/+5
| | | | | | Reported by GCC's -Wuseless-cast. * data/skeletons/glr.c: Don't cast to yybool, it's useless.
* yacc.c, glr.c: fix crash when reporting errors in consistent statesAkim Demaille2019-11-294-20/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current code for yysyntax_error for %define parse.error verbose is fishy (given that YYEMPTY is -2, invalid argument for yytname[]): static int yysyntax_error ([...]) { YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); [...] if (yytoken != YYEMPTY) A nearby comment reports The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". So it _is_ possible to call yysyntax_error with yytoken == YYEMPTY, albeit quite difficult when meaning to, so virtually impossible by accident (after all, there was never a bug report about this). I failed to produce a test case, but Joel E. Denny provided me with one (added to the test suite below). The yacc.c skeleton fails on this, and once fixed dies on a second problem. The glr.c skeleton was also dying, but immediately of this second problem. Indeed we were not allocating space for the error message's final \0. This was hidden by the fact that we only had error messages with at least an unexpected token displayed, so with at least one "%s" in the format string, whose size (2) was included (incorrectly) in the final size of the message (where the %s have been replaced by the actual content). * data/skeletons/glr.c, data/skeletons/yacc.c (yysyntax_error): Do not invoke yytnamerr on YYEMPTY. Clarify the computation of the length of the _final_ error message, with the NUL terminator but without the '%s's. * tests/conflicts.at (Syntax error in consistent error state): New, contributed by Joel E. Denny.
* tests: avoid creating files whose name collide with standard headersAkim Demaille2019-11-262-6/+6
| | | | | | | | | Having a file named "exception" is risky: the compiler might use that file in #include. Reported by 马俊 <majun123@whu.edu.cn>. * tests/local.at (AT_SKIP_IF_EXCEPTION_SUPPORT_IS_POOR): Generate 'exceptions', not 'exception'.
* doc: more details about the test suiteAkim Demaille2019-11-222-33/+42
| | | | * README-hacking.md: here.
* maint: post-release administriviaAkim Demaille2019-11-202-1/+4
| | | | | | * NEWS: Add header line for next release. * .prev-version: Record previous version. * cfg.mk (old_NEWS_hash): Auto-update.
* version 3.4.91v3.4.91Akim Demaille2019-11-201-1/+1
| | | | * NEWS: Record release date.
* style: pacify syntax-checkAkim Demaille2019-11-205-12/+15
| | | | | * cfg.mk: No need to translate *.md files. * data/skeletons/glr.c, data/skeletons/yacc.c: Fix space issues.
* gnulib: updateAkim Demaille2019-11-191-0/+0
|
* doc: don't promote dangling aliasesAkim Demaille2019-11-181-1/+15
| | | | | | | | | | | | | String literals as tokens serve two distinct purposes: freeing from having to implement the keyword matching in the scanner, and improving error messages. Most of the time both can be achieved at the same time, but on occasions, it does not work so well. We promote their use for error messages. We will also still support the former case, but it is _not_ the recommended approach. * doc/bison.texi (Tokens from Literals): Clearly state that we don't recommend looking up the token types in the list of token names.
* diagnostics: complain about undeclared string tokensAkim Demaille2019-11-176-13/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | String literals, which allow for better error messages, are (too) liberally accepted by Bison, which might result in silent errors. For instance %type <exVal> cond "condition" does not define “condition” as a string alias to 'cond' (nonterminal symbols do not have string aliases). It is rather equivalent to %nterm <exVal> cond %token <exVal> "condition" i.e., it gives the type 'exVal' to the "condition" token, which was clearly not the intention. Introduce -Wdangling-alias to catch this. * src/complain.h, src/complain.c: Add support for -Wdangling-alias. (argmatch_warning_args): Sort. * src/symtab.c (symbol_check_defined): Complain about dangling aliases. * doc/bison.texi: Document it. * tests/input.at (Dangling aliases): New test.
* diagnostics: yacc reserves %type to nonterminalsAkim Demaille2019-11-177-28/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On %token TOKEN1 %type <ival> TOKEN1 TOKEN2 't' %token TOKEN2 %% expr: bison -Wyacc gives input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc] 2 | %type <ival> TOKEN1 TOKEN2 't' | ^~~~~~ input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc] 2 | %type <ival> TOKEN1 TOKEN2 't' | ^~~ input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc] 2 | %type <ival> TOKEN1 TOKEN2 't' | ^~~~~~ The messages appear to be out of order, but they are emitted when the error is found. * src/symtab.h (symbol_class): Add pct_type_sym, used to denote symbols appearing in %type. * src/symtab.c (complain_pct_type_on_token): New. (symbol_class_set): Check that %type is not applied to tokens. (symbol_check_defined): pct_type_sym also means undefined. * src/parse-gram.y (symbol_decl.1): Set the class to pct_type_sym. * src/reader.c (grammar_current_rule_begin): pct_type_sym also means undefined. * tests/input.at (Yacc's %type): New.
* doc: promote %nterm over %typeAkim Demaille2019-11-161-40/+43
| | | | | | | | | | | | | | As an extension to POSIX Yacc, Bison's %type accepts tokens. Unfortunately with string literals as implicit tokens, this is misleading, and led some users to write %type <exVal> cond "condition" believing that "condition" would be associated to the 'cond' nonterminal (see https://github.com/apache/httpd/pull/72). * doc/bison.texi: Promote %nterm rather than %type to declare the type of nonterminals.
* doc: formatting changesAkim Demaille2019-11-161-105/+90
| | | | * doc/bison.texi: No visible changes.
* doc: work around warnings when Flex C output is compiled in C++Akim Demaille2019-11-161-9/+19
| | | | | * doc/bison.texi (calc++/scanner.ll): here. While at it, clarify clang vs. warnings.
* tests: be robust to old Perl versions on CygwinAkim Demaille2019-11-161-2/+6
| | | | | | | Reported by Denis Excoffier. https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00008.html. * tests/output.at: Be sure to remove back up files.
* regenAkim Demaille2019-11-162-18/+29
|
* gram.c: Fix condition of averkaneko y2019-11-121-1/+1
| | | | | * src/gram.c (grammar_dump): Fix condition of aver. What we want to check is that rhs is followed by its rule.
* doc: clarify build instructionsAkim Demaille2019-11-115-173/+215
| | | | | | | | | * README: A few fixes. Explain how to install color support. * README-hacking: Rename as... * README-hacking.md: this, and convert to Markdown. Improve typography. Improve explanations about update-test.
* gnulib: updateAkim Demaille2019-11-113-0/+4
|
* gram.c: also print terminals in grammar_dumpYuichiro Kaneko2019-11-112-9/+117
| | | | | | * src/gram.c (grammar_dump): Print terminals likewise non terminals. * tests/sets.at (Reduced Grammar): Update test case to catch up the change and add a test case where prec and assoc are used.
* doc: work around Texinfo 6.7 bugAkim Demaille2019-11-101-0/+17
| | | | | | | | When @code is used in a @deftype... definition, it issues quotes. Remove them. See https://lists.gnu.org/archive/html/help-texinfo/2019-11/msg00004.html. * doc/local.mk: here.
* doc: formatting changesAkim Demaille2019-11-091-24/+22
| | | | | * doc/bison.texi: Wrap lines. No semantical difference.
* doc: use upper case for tokensAkim Demaille2019-11-091-1/+1
| | | | * doc/bison.texi: here.
* doc: type-face fixesAkim Demaille2019-11-071-64/+64
| | | | * doc/bison.texi: Use @code for types in function definitions.
* c++: expose the type used to store line and column numbersAkim Demaille2019-11-063-51/+68
| | | | | | | * data/skeletons/location.cc (position::counter_type) (location::counter_type): New. Use them. * doc/bison.texi (C++ position, C++ location): Adjust.
* tests: fix comment and adjust to locale names on GNU/LinuxAkim Demaille2019-11-031-4/+5
| | | | | | Reported by Denis Excoffier. * tests/diagnostics.at: here.
* tests: really check complaints from m4Akim Demaille2019-11-031-38/+15
| | | | | | | * tests/diagnostics.at (Locations from M4, Tabulations and multibyte characters from M4): These tests are actually checking a message coming from C, not from M4. Replace with... (Complaints from M4): This.
* tests: simplify prologueAkim Demaille2019-11-031-5/+4
| | | | * tests/testsuite.h: We no longer load gnulib in the tests.
* diagnostics: add missing translationAkim Demaille2019-11-031-4/+4
| | | | * src/muscle-tab.c (muscle_percent_define_check_kind): Here.
* c++: fix old cast warningsAkim Demaille2019-11-0214-137/+186
| | | | | | | | | | | | | | | | | | | | | | | We still have a few old C casts in lalr1.cc, let's get rid of them. Reported by Frank Heckenbach. Actually, let's monitor all our casts using easy to grep macros. Let's use these macros to use the C++ standard casts when we are in C++. * data/skeletons/c.m4 (b4_cast_define): New. * data/skeletons/glr.c, data/skeletons/glr.cc, * data/skeletons/lalr1.cc, data/skeletons/stack.hh, * data/skeletons/yacc.c: Use it and/or its casts. * tests/actions.at, tests/cxx-type.at, * tests/glr-regression.at, tests/headers.at, tests/torture.at, * tests/types.at: Use YY_CAST instead of C casts. * configure.ac (warn_cxx): Add -Wold-style-cast. * doc/bison.texi: Disable it.
* tests: be robust to tput errorsAkim Demaille2019-11-011-1/+1
| | | | | | Reported by Denis Excoffier. * tests/bison.in: here.
* git: update ignoresAkim Demaille2019-11-011-0/+16
| | | | | I don't understand what happened in 10acc148bb90fac8a52a5d35f2bd18bd824c1639.
* maint: post-release administriviaAkim Demaille2019-10-292-1/+4
| | | | | | * NEWS: Add header line for next release. * .prev-version: Record previous version. * cfg.mk (old_NEWS_hash): Auto-update.
* version 3.4.90v3.4.90Akim Demaille2019-10-292-17/+1
| | | | * NEWS: Record release date.
* C++: finish propagating the unsigned->signed conversion in locationsAkim Demaille2019-10-293-14/+18
| | | | | | * data/skeletons/location.cc: Remove the u (for unsigned) suffix from the initial line and column. * NEWS: AFAICT, only C++ backends have their location types changed.
* style: fix cpp indentationAkim Demaille2019-10-291-10/+10
| | | | | | Reported by syntax-check. * src/system.h: here.
* style: glr.c: comment changesAkim Demaille2019-10-291-4/+4
| | | | * data/skeletons/glr.c: here.
* CI: pass -O1 to GCC8 with sanitizersAkim Demaille2019-10-261-1/+2
| | | | | | | This build never finishes in the 50min credit given by Travis. See if with optimizations it works better. * .travis.yml: here.
* reader: reduce the "scope" of global variablesAkim Demaille2019-10-268-34/+30
| | | | | | | | | | | | | | | We have too many global variables, adding structure would help. For a start, let's hide some of the variables closer to their usage. * src/getargs.c, src/files.h (current_file): Move to... * src/scan-gram.c: here. * src/scan-gram.h (gram_in, gram__flex_debug): Remove, make them private to the scanner. * src/reader.h, src/reader.c (reader): Take a grammar file as argument. Move the handling of scanner variables to... * src/scan-gram.l (gram_scanner_open, gram_scanner_close): here. (gram_scanner_initialize): Remove, replaced by gram_scanner_open. * src/main.c: Adjust.
* regenAkim Demaille2019-10-262-10/+10
|
* parser: use grammar_file instead of current_fileAkim Demaille2019-10-261-6/+6
| | | | | | | * src/parse-gram (%initial-action): here. (handle_skeleton): Don't depend on the current file name to look for "local" skeletons (subject to changes coming from "#lines"): depend only on the initial file name, the one given on the command line.
* diagnostics: use grammar_file instead of current_fileAkim Demaille2019-10-262-2/+2
| | | | | | | | | Currently there are two globals denoting the input file: grammar_file is the one from the command line, and current_file which might change because of #line. Use only the former. * src/complain.c (error_message): here. * tests/diagnostics.at: Adjust.
* reader: let symtab deal with the symbolsAkim Demaille2019-10-253-19/+23
| | | | | * src/reader.c (reader): Move the setting up of the builtin symbols to... * src/symtab.c (symbols_new): here.
* style: remove incorrect commentAkim Demaille2019-10-251-1/+0
| | | | | | Reported by Paul Eggert. * src/system.h: here.
* lalr1.cc: fix previous commit: printing of state numbersAkim Demaille2019-10-241-2/+2
| | | | | * data/skeletons/lalr1.cc: Printing a char prints... a char. Print ints instead.
* lalr1.cc: use computed state typesAkim Demaille2019-10-241-5/+4
| | | | | | | | | | | | | | This skeleton uses a single stack of state structures, so it is less likely to benefit from a stack size reduction than yacc.c (which uses several stacks: state number, value and location). But it will reduce the size of the LAC stack. This skeleton was already using int for state numbers, so, contrary to yacc.c, this brings nothing for large automata. Overall, it is still nicer to make the skeletons alike. * data/skeletons/lalr1.cc (state_type): Here.
* README: Fix a typokaneko y2019-10-241-1/+1
| | | | * README: Fix a typo. Git command name is submodule.
* examples: fix missing dependenciesAkim Demaille2019-10-243-3/+31
| | | | | | | | | | | Reported by Thomas Petazzoni. https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00000.html * examples/c/reccalc/local.mk: Complete dependencies, including for earlier versions of Automake (for sake of our CI, on top of Ubuntu Xenial/Bionic, which feature only Automake 1.15). (%D%/scan.c %D%/scan.h): Upgrade to the full version provided in Automake's documentation.
* diagnostics: simplify location handlingAkim Demaille2019-10-242-11/+11
| | | | | | | Locations start at line 1. Don't accept line 0. * src/location.c (location_print): Don't print locations with line 0. (location_caret): Simplify.