Commit Graph

2250 Commits

Author SHA1 Message Date
Akim Demaille
26859f6d61 main: fix error message for missing argument
* src/getargs.c (getargs): Don't display any argv other that argv[0]
when reporting a missing argument.
* tests/bison.in: Neutralize path differences in stderr.
* tests/input.at (Invalid number of arguments): New.
2018-10-04 22:24:11 +02:00
Akim Demaille
f84a8e96d1 gnulib: move timevar to it
* lib/timevar.c, lib/timevar.h, m4/timevar.m4: Remove.
* gnulib: Update.
* configure.ac: Adjust.
* lib/timevar.def: Use lower case for the timevvars.
Adjust dependencies.
2018-09-30 14:19:53 +02:00
Paul Eggert
d03b1a7e8c getargs: use LC_MESSAGES trick only on glibc
* src/getargs.c (usage): Rely on setlocale (LC_MESSAGES, NULL)
trick only on glibc, as POSIX does not specify the output
of setlocale in this case, and the Gnulib localename module
source code indicates that the trick works only on glibc.
2018-09-28 16:41:41 -07:00
Paul Eggert
973c456f63 uniqstr: avoid need for VLAs
C11 no longer requires support for variable-length arrays, and
VS2015 does not have them.  Redo UNIQSTR_CONCAT to use a method
that is simpler and better anyway.
* src/uniqstr.c (uniqstr_vsprintf): Remove; no longer needed.
* src/uniqstr.h (UNIQSTR_GEN_FORMAT, UNIQSTR_GEN_FORMAT_):
* src/uniqstr.c (uniqstr_concat): New function.
* src/uniqstr.h (UNIQSTR_CONCAT): Use it instead of using
uniqstr_vsprintf.
2018-09-28 16:41:41 -07:00
Akim Demaille
b2a3a302e6 style: reduce scopes in muscle-tab.c 2018-09-24 21:52:56 +02:00
Akim Demaille
cf4e3eecef c++: fix warning message for automove
* src/scan-code.l: Remove 'enabled'.
Use only $k (numeric), even for named references, for clarity.
* tests/c++.at: Adjust expectations.
2018-09-24 21:52:55 +02:00
Akim Demaille
2eaa7ed946 style: minor refactoring
* data/bison.m4: Formatting changes.
* src/scan-code.l: Avoid loops, prefer standard string functions.
(find_prefix_end): Be const correct.
Avoid useless intermediate variables.
(variant_add): Be const correct.
(parse_ref): Prefer variable definitions to assignments.
2018-09-24 21:52:55 +02:00
Akim Demaille
9dfd46a5d5 timevar: get rid of a useless macro
* lib/timevar.h (timevar_report): Rename as...
(timevar_enabled): this.
* lib/timevar.c (TIMEVAR_ENABLE): Remove.
2018-09-22 15:58:27 +02:00
Akim Demaille
c8da23c372 timevar: rename init_timevar as timevar_init
* lib/timevar.h, lib/timevar.c: here.
* src/main.c: Adjust.
2018-09-22 15:58:27 +02:00
Akim Demaille
a874011e37 c++: issue a warning with a value is moved several times
Suggested by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2018-09/msg00022.html

* src/scan-code.l (parse_ref): Check multiple occurrences of rhs
values.
* tests/c++.at (Multiple occurrences of $n and api.value.automove): New.
2018-09-22 11:22:31 +02:00
Akim Demaille
db025a6fb7 style: reduce scopes in gram.c
* src/gram.c: here.
2018-09-20 21:19:55 +02:00
Akim Demaille
ca822faeec style: reduce scopes in reduce.c
* src/reduce.c: Here.
2018-09-20 21:19:55 +02:00
Akim Demaille
bbfa419b89 style: use midrule only, not mid-rule
The code was already using midrule only, never mid_rule.  This is
simpler to remember, and matches a similar change we made from
look-ahead to lookahead.

* NEWS, doc/bison.texi, src/reader.c, src/scan-code.h, src/scan-code.l
* tests/actions.at, tests/c++.at, tests/existing.at: here.
2018-09-19 22:09:53 +02:00
Akim Demaille
84dcd7991b style: reduce scopes in complain.c 2018-09-15 08:28:02 +02:00
Akim Demaille
50910389c9 style: reduce scopes in tables.c
* src/tables.c: here.
* src/state.h: Formatting changes.
2018-09-15 07:59:57 +02:00
Akim Demaille
6cc69f4d14 style: reduce scopes in graphviz.c 2018-09-15 07:20:49 +02:00
Akim Demaille
46532a9d3b style: reduce scopes in LR0.c 2018-09-15 07:20:49 +02:00
Akim Demaille
5603f0bdf2 style: reduce scopes in print_graph.c
* src/print_graph.c: here.
2018-09-15 07:20:49 +02:00
Akim Demaille
ea0db44fed build: work around warnings in Flex 2.5.35
That's the version on Ubuntu Precise.
See also 1dac131ec4.

* src/flex-scanner.h: Disable -Wdocumentation.
* doc/bison.texi: Turn off a warning triggered by Flex 2.6.4.
2018-09-08 07:53:08 +02:00
Akim Demaille
1dac131ec4 build: work around GCC warnings on Flex code
See ef98967ada.

* src/flex-scanner.h: Disable -Wnull-dereference for GCC 6+.
2018-09-06 21:28:24 +02:00
Akim Demaille
e866c476fd build: fix concurrent build failure
Reported by Dengke Du and Robert Yang.
https://lists.gnu.org/archive/html/bison-patches/2017-07/msg00000.html

* src/local.mk (src/yacc): Make sure the directory exists.
2018-08-18 15:37:14 +02:00
Akim Demaille
adf0425d11 escape properly the file names in #line for printer/destructor
Reported by Jannick.
http://lists.gnu.org/archive/html/bug-bison/2017-05/msg00001.html

"Amusingly" enough, we have the same problem with %defines when the
parser file name has backslashes or quotes: we generate #includes with
an incorrect C string.

* src/output.c (prepare_symbol_definitions): Escape properly the file
names before passing them to M4.
* data/bison.m4, data/lalr1.cc: Don't simply put the file name between
two quotes (that should have been strong enough a smell...), expect
the string to be properly quoted.
* tests/synclines.at: New tests to check this.
2018-08-18 10:04:50 +02:00
Akim Demaille
2e9ad04cdb style: reduce scopes
* src/output.c: here.
2018-08-18 09:53:29 +02:00
Akim Demaille
28cde9c128 style: reduce scopes
* src/scan-code.l: here.
2018-08-18 09:53:29 +02:00
Akim Demaille
d288047e9b regen 2018-08-18 07:42:07 +02:00
Akim Demaille
d135a16792 style: reduce scopes
* src/parse-gram.y: Declare iterator within the for-loop.
2018-08-18 07:42:07 +02:00
Akim Demaille
8bc4348cc7 reader: simplify the search of the start symbol
Suggested by Paul Eggert.

* src/reader.c (find_start_symbol): Don't check 'res', we know it is
not null.  That suffices to avoid the GCC warnings.
* bootstrap.conf: We don't need 'assume', which doesn't exist anyway.
2018-08-17 06:22:47 +02:00
Akim Demaille
ef98967ada build: work around GCC warnings on Flex code
With GCC 7.3.0 and Flex 2.6.4, we get warnings on all the generated
scanners:

    examples/calc++/calc++-scanner.cc: In function 'void yyrestart(FILE*)':
    examples/calc++/calc++-scanner.cc:1611:20: error: potential null pointer dereference [-Werror=null-dereference]
     /* %endif */
      ~~~~~~~~~~~       ^
    examples/calc++/calc++-scanner.cc:1607:19: error: potential null pointer dereference [-Werror=null-dereference]
     /* %if-c-only */
      ~~~~~~~~~~~~~~~  ^
    examples/calc++/calc++-scanner.cc:1611:20: error: potential null pointer dereference [-Werror=null-dereference]
     /* %endif */
      ~~~~~~~~~~~       ^
    examples/calc++/calc++-scanner.cc:1607:19: error: potential null pointer dereference [-Werror=null-dereference]
     /* %if-c-only */
      ~~~~~~~~~~~~~~~  ^
    cc1plus: all warnings being treated as errors

Obviously the lines are incorrect, and the warnings are emitted twice.
Still, let's get rid of these warnings.

* doc/bison.texi, src/flex-scanner.h: Disable these warnings in code
generated by Flex.
2018-08-15 14:42:09 +02:00
Akim Demaille
7783ba2d4f fix incorrect C code
Commit 3df32101e7 introduced invalid C
code.  Caught by GCC 7.3.0.

* bootstrap.conf (gnulib_modules): We need assume.
* src/reader.c (find_start_symbol): Fix the signature (too much C++,
sorry...).
Prefer 'assume' to 'assert', so that we don't have these warnings even
when NDEBUG is defined.
2018-08-15 14:39:46 +02:00
Akim Demaille
c2de9dafd1 regen 2018-08-14 06:15:42 +02:00
Akim Demaille
9a5c688ae4 style: src: remove useless reference to 'int' in integral types
* src/AnnotationList.c, src/AnnotationList.h, src/InadequacyList.h,
* src/closure.c, src/closure.h, src/gram.c, src/gram.h, src/ielr.c,
* src/location.c, src/output.c, src/reader.c, src/relation.c,
* src/scan-code.l, src/scan-gram.l, src/tables.c, src/tables.h:
Prefer 'unsigned' to 'unsigned int'.  Likewise for long and short.
2018-08-14 06:15:41 +02:00
Akim Demaille
e19e088e66 style: reduce scopes
* src/closure.c, src/conflicts.c: here.
2018-08-11 18:27:09 +02:00
Akim Demaille
da8f4a2f5f rule actions cannot be typed
Make sure that we cannot apply a type to the (main) action of a rule.

* src/reader.c (grammar_rule_check): Issue the warning.
* tests/input.at (Cannot type action): Check the warning.
2018-08-11 18:09:29 +02:00
Akim Demaille
f18f71cfb0 warn about typed mid-rule actions in Yacc mode
* src/reader.c (grammar_current_rule_action_append): Warn.
* tests/input.at (AT_CHECK_UNUSED_VALUES): Check.
2018-08-11 18:09:29 +02:00
Akim Demaille
b79b889de5 regen 2018-08-11 18:09:29 +02:00
Akim Demaille
7b24c424b5 add support for typed mid-rule actions
Prompted on Piotr Marcińczyk's message:
http://lists.gnu.org/archive/html/bug-bison/2017-06/msg00000.html.
See also http://lists.gnu.org/archive/html/bug-bison/2018-06/msg00001.html.

Because their type is unknown to Bison, the values of midrule actions are
not treated like the others: they don't have %printer and %destructor
support.  In addition, in C++, (Bison) variants cannot work properly.

Typed midrule actions address these issues.  Instead of:

    exp: { $<ival>$ = 1; } { $<ival>$ = 2; }   { $$ = $<ival>1 + $<ival>2; }

write:

    exp: <ival>{ $$ = 1; } <ival>{ $$ = 2; }   { $$ = $1 + $2; }

* src/scan-code.h, src/scan-code.l (code_props): Add a `type` field to
record the declared type of an action.
(code_props_rule_action_init): Add a type argument.
* src/parse-gram.y: Accept an optional type tag for actions.
* src/reader.h, src/reader.c (grammar_current_rule_action_append): Add
a type argument.
(grammar_midrule_action): When a mid-rule is typed, pass its type to
the defined dummy non terminal symbol.
2018-08-11 18:09:29 +02:00
Akim Demaille
3df32101e7 warnings: address -Wnull-dereference in reader.c
Based on a patch by David Michael.
http://lists.gnu.org/archive/html/bison-patches/2018-07/msg00000.html

* src/reader.c (find_start): New, extracted from...
(check_and_convert_grammar): here.
2018-08-05 20:25:58 +02:00
Akim Demaille
c699078246 style: ielr: reduce scopes
* src/ielr.c: Use modern C to reduce the scopes of some variables.
2018-08-05 20:17:25 +02:00
Akim Demaille
4c7377f499 style: move to C99 to reduce scopes
* src/symtab.c, src/reader.c: Freely mix statements and variable
definitions.  And use for-loops with initializers.
2018-07-26 20:18:32 +02:00
Akim Demaille
9502b2ab48 style: split a function in two
grammar_current_rule_action_append was used in two different places:
for actual action (`{...}`), and for predicates (`%?{...}`).  Let's
split this in two different functions.

* src/reader.h, src/reader.c (grammar_current_rule_predicate_append): New.
Extracted from...
(grammar_current_rule_action_append): here.
Remove arguments that don't apply.
Adjust dependencies.
2018-07-26 20:18:32 +02:00
Akim Demaille
0def17c3d1 print: remove unused function
This function was unused since 1991's original import by
rms (e06f0c3442).

* src/print.c (print_token): Remove.
2018-07-26 20:10:38 +02:00
Akim Demaille
27767290da report: display the type of the symbols
* src/print.c (print_nonterminal_symbols, print_terminal_symbols):
Also should the type of the symbols.
2018-06-18 07:18:14 +02:00
Akim Demaille
2efaa8e96a style: reduce scopes
* src/print.c (print_terminal_symbols, print_nonterminal_symbols): Here.
2018-06-18 07:16:03 +02:00
Akim Demaille
4cdcb6f243 style: split large function
* src/print.c (print_grammar): Split into...
(print_terminal_symbols, print_nonterminal_symbols): these.
Adjust dependencies.
2018-06-18 07:15:56 +02:00
Akim Demaille
7f42eb0a5e style: reduce scopes
* src/print.c (print_grammar): Shorten scopes.
2018-06-18 07:15:48 +02:00
Akim Demaille
f462a08572 Merge maint into master
* upstream/maint: (48 commits)
  THANKS: update an address
  tests: adjust syncline tests to GCC 7
  glr: fix improperly placed synclines
  bison: be git grep friendly
  Replace ftp with https
  maint: post-release administrivia
  version 3.0.5
  bison: style: indentation fixes
  regen
  bison: please address sanitizer
  C++: style: fix indentation
  NEWS: update
  C++: style: prefer `unsigned` to `unsigned int`
  C++: style: space before paren
  C++: fix -Wdeprecated warnings
  tests: fix -Wdeprecated warning
  maint: update syntax-check exclusions
  autoconf: update
  regen
  Update copyright years
  ...
2018-06-17 18:43:59 +02:00
Akim Demaille
d0447d949b bison: be git grep friendly
* src/output.c (user_actions_output): Make calls to b4_case and
b4_predicate_case explicit.
2018-05-29 09:02:12 +02:00
Akim Demaille
1e7a8315f6 bison: style: indentation fixes
* src/parse-gram.y: here.
2018-05-27 10:58:29 +02:00
Akim Demaille
4eeec4e41f regen 2018-05-27 10:46:31 +02:00
Akim Demaille
6fd3372db4 bison: please address sanitizer
* src/parse-gram.y (add_param): Asan does not like that the second
argument of strspn is not 0-terminated.
2018-05-27 10:44:41 +02:00