Commit Graph

6202 Commits

Author SHA1 Message Date
Akim Demaille
cf96d1b0af Merge branch maint
* maint:
  maint: post-release administrivia
  version 3.3.2
  style: minor fixes
  NEWS: named constructors are preferable to symbol_type ctors
  gram: fix handling of nterms in actions when some are unused
  style: rename local variable
  CI: update the ICC serial number for travis-ci.org
2019-02-03 15:23:54 +01:00
Akim Demaille
3d25b52a10 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-02-03 14:56:05 +01:00
Akim Demaille
437f6250c5 version 3.3.2
* NEWS: Record release date.
v3.3.2
2019-02-03 14:42:30 +01:00
Akim Demaille
334cb8f222 style: minor fixes
* NEWS, src/reduce.c, src/reduce.h: Use 'nonterminal'.
Fix comments.
2019-02-03 14:42:22 +01:00
Akim Demaille
03878edf77 NEWS: named constructors are preferable to symbol_type ctors
Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00043.html
2019-02-03 10:06:25 +01:00
Akim Demaille
cacdfc2f6e gram: fix handling of nterms in actions when some are unused
Since Bison 3.3, semantic values in rule actions (i.e., '$...') are
passed to the m4 backend as the symbol number.  Unfortunately, when
there are unused symbols, the symbols are renumbered _after_ the
numbers were used in the rule actions.  As a result, the evaluation of
the skeleton failed because it used non existing symbol numbers.
Which is the happy scenario: we could use numbers of other existing
symbols...

Reported by Balázs Scheidler.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00044.html

Translating the rule actions after the symbol renumbering moves too
many parts in bison.  Relying on the symbol identifiers is more
troublesome than it might first seem: some don't have an
identifier (tokens with only a literal string), some might have a
complex one (tokens with a literal string with characters special for
M4).  Well, these are tokens, but nterms also have issues: "dummy"
nterms (for midrule actions) are named $@32 etc. which is risky for
M4.

Instead, let's simply give M4 the mapping between the old numbers and
the new ones.  To avoid confusion between old and new numbers, always
emit pre-renumbering numbers as "orig NUM".

* data/README: Give details about "orig NUM".
* data/skeletons/bison.m4 (__b4_symbol, _b4_symbol): Resolve the
"orig NUM".
* src/output.c (prepare_symbol_definitions): Pass nterm_map to m4.
* src/reduce.h, src/reduce.c (nterm_map): Extract it from
nonterminals_reduce, to make it public.
(reduce_free): Free it.
* src/scan-code.l (handle_action_dollar): When referring to a nterm,
use "orig NUM".
* tests/reduce.at (Useless Parts): New, based Balázs Scheidler's
report.
2019-02-03 10:05:53 +01:00
Akim Demaille
56c00ed1ea tests: strengthen some of them
* tests/reduce.at: Check that the generated parsers are proper C.
2019-02-03 08:00:23 +01:00
Akim Demaille
513d2f723f package: rename data/README as data/README.md
So that it is properly rendered by online git services.
2019-02-03 07:28:57 +01:00
Akim Demaille
48429252c1 style: reduce scopes
* src/symlist.c (symbol_list_free): New.
2019-02-03 07:28:57 +01:00
Akim Demaille
d459a5b8e6 style: prefer snprintf to sprintf
* src/symtab.c (dummy_symbol_get): There's no need for the buffer to
be so big and static.
Use snprintf for safety.
2019-02-03 07:28:57 +01:00
Akim Demaille
9566232422 style: comment and name changes
* src/output.c (prepare_symbol_names): here.
* src/reader.c: Remove obsolete comment.
* src/scan-code.l: Use || for Boolean or.
2019-02-02 17:32:10 +01:00
Akim Demaille
dc654a925c style: comment changes
* src/reader.c, src/scan-code.l: here.
2019-02-02 17:32:04 +01:00
Akim Demaille
76366e8e5c make: regenerate the example parsers when bison changes
* Makefile.am (dependencies): Also depend on Bison's sources.
2019-02-02 17:31:58 +01:00
Akim Demaille
31788ed4c7 style: rename local variable
* src/reduce.c (nonterminals_reduce): Rename nontermmap as nterm_map.
We will expose it.
2019-02-02 16:37:25 +01:00
Akim Demaille
781d2b02de gram: detect and report (in debug traces) useless chain rules
A rule is a useless chain iff it's a chain (aka unit, or injection)
rule (i.e., the RHS has length 1), and it's useless (it has no used
defined semantic action).

* src/gram.h, src/gram.c (rule_useless_chain_p): New.
(grammar_dump): Report useless chain rules.
* tests/sets.at: Check the traces.
2019-01-30 07:08:09 +01:00
Akim Demaille
8b5fc2143f lr(0): more debug traces
* src/lr0.c (core_print, kernel_print): New.
Use them.
2019-01-30 07:08:09 +01:00
Akim Demaille
5670677cb6 lr(0): remove useless conditional
* src/lr0.c (new_itemsets): There's no harm in setting a Boolean
several times.
2019-01-30 07:08:08 +01:00
Akim Demaille
32b9dcecc7 style: sort includes and avoid assignments
* src/symtab.c: Sort includes.
* src/gram.c (grammar_rules_print_xml): Avoid assignments to define
'usefulness'.
2019-01-30 07:08:00 +01:00
Akim Demaille
ac12b725ea style: use item_rule
* src/print-graph.c, src/print-xml.c: here.
2019-01-30 07:06:48 +01:00
Akim Demaille
e1783bc686 gram: factor the printing of items and the computation of their rule
There are several places where we need to recover the rule from an
item, let's factor that into item_rule.  We also want to print items
in a nice way: we do it when generating the *output file, but it is
also useful in debug messages.

* src/gram.h, src/gram.c (item_rule, item_print): New.
* src/print.c (print_core): Use them.
* src/state.h, src/state.c: Propagate constness.
2019-01-30 07:06:48 +01:00
Akim Demaille
c4f143eb96 style: scope reduction in print-xml
* src/print-xml.c: here.
2019-01-30 07:06:48 +01:00
Akim Demaille
94054924a9 tests: check XML and dot reports
* tests/report.at: Here.
2019-01-30 07:06:48 +01:00
Akim Demaille
c639611002 CI: update the ICC serial number for travis-ci.org
On travis-ci.org, there are five concurrent slaves, instead of three
on travis-ci.com.
2019-01-28 19:53:25 +01:00
Akim Demaille
69061fed82 CI: update the ICC serial number for travis-ci.org
On travis-ci.org, there are five concurrent slaves, instead of three
on travis-ci.com.
2019-01-28 08:12:13 +01:00
Akim Demaille
3075d96d44 style: comment changes
* src/lr0.c, src/state.c, src/state.h: here.
2019-01-28 07:00:23 +01:00
Akim Demaille
7fec997ecf closure: initialize it once for all
The memory allocated by 'closure' (and some data such as 'fderives')
is used to computed a state's full itemset from its core.  This is
needed during the construction of the LR(0) automaton, and the memory
is reclaimed immediately afterwards.

Unfortunately the reports (graph, text, xml) also need this
information when describing the states with their full itemsets.  As a
consequence the memory was allocated again, fderives computed again
too, and more --trace reports are generated which only duplicate what
was already reported.

Stop that.  It does mean that we release the memory later (hence the
peak memory usage is higher now), but I don't think that's a problem
today.

* src/lr0.c (generate_states): Don't call closure_free.
* src/state.c (states_free): Do it here.
(for symmetry with closure_new which is called in generate_states).
* src/print-graph.c, src/print-xml.c, src/print.c: You can now expect
the closure module to be functional.
2019-01-28 06:57:31 +01:00
Akim Demaille
7355a35e4b style: rename closure_* functions as closure_*
This is more consistent with the other files.

* closure.h, closure.c (new_closure, free_closure): Rename as...
(closure_new, closure_free): this.
Adjust dependencies.
2019-01-28 06:47:33 +01:00
Akim Demaille
e585377e68 lr0: use a bitset for the set of "shiftable symbols"
This will make it easier to add new elements (that might already be
part of shift_symbol) without having to worry about the size of
shift_symbol (which is currently a fixed size vector).

I could not measure any significant differences in performances in the
generation of LR(0) automaton (benched on gramamrs of Ruby, C, and C++).

* src/lr0.c (shift_symbol): Make it a bitset.
2019-01-28 06:47:33 +01:00
Akim Demaille
9cd7bd4d5f add -fsyntax-only
When debugging Bison itself, this is very handy, especially when
tweaking the frontend badly enough to break the backends. It can also
be used to check a grammar.

* src/getargs.h, src/getargs.c (feature_syntax_only): New.
(feature_args, feature_types): Adjust.
* src/main.c (main): Use it.
2019-01-28 06:47:07 +01:00
Akim Demaille
a108d84f88 style: beware of collisions on status
* src/symtab.h (status): Rename as...
(declaration_status): this, to avoid colliding with status, the
argument of 'usage'.
'status' seems a tad too general to be used only here.
2019-01-27 20:07:08 +01:00
Akim Demaille
1e83dd2229 gnulib: update 2019-01-27 19:48:09 +01:00
Akim Demaille
d02ca923e2 usage: document -ffixit
* src/getargs.c (usage): Document -ffixit.
Document the aliases of -f.
2019-01-27 18:08:55 +01:00
Akim Demaille
f82f7eb1d8 style: reduce scopes in state.c and ielr.c 2019-01-27 18:08:47 +01:00
Akim Demaille
0d472b29ec Merge branch 'maint'
* maint:
  maint: post-release administrivia
  version 3.3.1
  yacc: issue warnings, not errors, for Bison extensions
  style: formatting changes in NEWS and complain.c
  tests: don't depend on the user's definition of SHELL
2019-01-27 16:44:56 +01:00
Akim Demaille
7a21067bb9 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-01-27 16:17:28 +01:00
Akim Demaille
ed02d34fbc version 3.3.1
* NEWS: Record release date.
v3.3.1
2019-01-27 16:03:23 +01:00
Akim Demaille
8b0b295569 yacc: issue warnings, not errors, for Bison extensions
Reported by Kiyoshi Kanazawa.
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00029.html

* src/getargs.c (getargs): Let --yacc imply -Wyacc, not -Werror=yacc.
* tests/input.at: Adjust.
* doc/bison.tex (Bison Options): Document.
2019-01-27 15:53:28 +01:00
Akim Demaille
59a108c0a6 style: formatting changes in NEWS and complain.c 2019-01-27 15:51:44 +01:00
Kiyoshi Kanazawa
83ebc8bdb6 tests: don't depend on the user's definition of SHELL
http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00031.html

* examples/test (SHELL): Set it to /bin/sh.
2019-01-27 07:06:44 +01:00
Akim Demaille
21a7fa8063 traces: always print the reduced grammar and fix it
* src/gram.c (grammar_dump): Print the effective number first instead
of last.  And fix it (remove the incorrect "+1").
Use t/f for Booleans.
* src/reduce.c: When asked, always print the reduced grammar, even if
there was nothing useless.
* tests/sets.at (Reduced Grammar): Check that.
2019-01-26 16:21:35 +01:00
Akim Demaille
83463dfbee style: rename LR0.* as lr0.*
Let's stick to lower case for file names.

* src/LR0.h, src/LR0.c: Rename as...
* src/lr0.h, src/lr0.c: these.
2019-01-26 16:21:35 +01:00
Akim Demaille
c3c50c0030 style: rename print_graph.* as print-graph.*
These are the only files with _.

* src/print_graph.h, src/print_graph.c: Rename as...
* src/print-graph.h, src/print-graph.c: these.
2019-01-26 16:16:47 +01:00
Akim Demaille
e85ab7ac9b style: various fixes
* src/gram.c: Use consistent variable names.
Prefix prefix unary operators.
(grammar_dump): Use rule_rhs_length instead of duplicating it.
* src/reduce.c: Avoid useless variables.
2019-01-26 16:16:47 +01:00
Akim Demaille
a11463a02f style: comment changes in gram.h
* src/gram.h: Shorten comments.
2019-01-26 16:16:47 +01:00
Akim Demaille
8023b3153a maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-01-26 11:45:20 +01:00
Akim Demaille
b23ca37ed2 version 3.3
* NEWS: Record release date.
v3.3
2019-01-26 11:32:11 +01:00
Akim Demaille
bb5e4b659b NEWS: update 2019-01-26 11:31:01 +01:00
Akim Demaille
bc8ec1d7bf c++: fix comment
* data/skeletons/c++.m4: here.
2019-01-26 10:46:33 +01:00
Akim Demaille
665c5d688c style: formatting changes
* data/skeletons/lalr1.cc: Add dnl.
* data/skeletons/bison.m4: Comment the use of dnl.
2019-01-26 10:46:33 +01:00
Akim Demaille
53d379b905 tests: run the printer/destructor test on glr.cc
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Adjust for
glr.cc, and use it.
2019-01-26 10:46:33 +01:00