Commit Graph

7470 Commits

Author SHA1 Message Date
Akim Demaille
ee86ea8839 cex: prefer → to ::=
It does not make a lot of sense to use ::= in our counterexamples,
that's not something that belongs to the Bison "vocabulary".  Using
the colon makes sense, but it's too discreet.  Let's use the arrow,
which we already use in some reports (HTML and Dot).

* src/gram.h (print_dot_fallback): Generalize into...
(print_fallback): this.
(print_arrow): New.
* src/derivation.c: Use it.

* NEWS, tests/conflicts.at, tests/counterexample.at,
* tests/diagnostics.at, tests/report.at: Adjust.
* doc/bison.texi: Ditto.
Unfortunately the literal `→` is output as `↦`.  So we need to use
@arrow.
2020-07-11 18:43:46 +02:00
Akim Demaille
a2ad33dca6 style: cex: prefer the array notation
Prefer `&foos[i]` to `foos + i` when `foos` is an array.  IMHO, it
makes the semantics clearer.

* src/counterexample.c, src/lssi.c, src/parse-simulation.c,
* src/state-item.c: With arrays, prefer the array notation rather than
the pointer one.
2020-07-11 18:07:09 +02:00
Akim Demaille
5b2b7b1ffb style: cex: remove variables that don't make it simpler to read
* src/counterexample.c: With arrays, prefer the array notation rather
than the pointer one.
2020-07-11 18:07:09 +02:00
Akim Demaille
dc72b3566d bistromathic: demonstrate caret-diagnostics
* examples/c/bistromathic/parse.y (user_context): We need the current
line.
(yyreport_syntax_error): Quote the guilty line, with squiggles.
* examples/c/bistromathic/bistromathic.test: Adjust.
2020-07-11 18:06:45 +02:00
Akim Demaille
c47e1174d4 bistromathic: do not display parse errors on completion
Currently autocompletion on a line with errors leaks the error
messages.  It can be useful to let the user know, but GNU Readline
does not provide us with an nice way to display the error.  So we
actually break into the current line of the user.

So instead, do not show these errors.

* examples/c/bistromathic/parse.y (user_context): New.
Use %param to pass it to the parser and scanner.
Keep quiet when in computing autocompletion.
2020-07-11 18:05:50 +02:00
Akim Demaille
093eeb27e9 bistromathic: don't stupidly reset the location for each token
That quite defeats the whole point of locations...  But anyway, we
should not see these messages at all.

* examples/c/bistromathic/parse.y (expected_tokens): Fix (useless)
location tracking.
2020-07-11 18:05:41 +02:00
Akim Demaille
dab23c4a21 bistromathic: promote yytoken_kind_t
* examples/c/bistromathic/parse.y: Use yytoken_kind_t rather than int.
2020-07-11 18:05:35 +02:00
Akim Demaille
38a169bec1 html: capitalize titles
* data/xslt/xml2xhtml.xsl: Use "State 0", not "state 0".
As we do in text reports.
2020-07-11 12:58:45 +02:00
Akim Demaille
dc77d6500f html: don't define several times the same anchors
Currently when we output useless rules, they appear before the
grammar, but using the same invocation.  As a result, the anchor is
defined twice, and the wrong one, being first, is honored.

* data/xslt/xml2xhtml.xsl (rule): Take a new 'anchor' parameter to
decide whether being an anchor, or a target.
Let it be true when output the grammar.
* tests/report.at: Adjust.
2020-07-11 12:58:44 +02:00
Akim Demaille
8262c7dc22 html: simplify
* data/xslt/xml2xhtml.xsl: Merge two identical when-clauses.
2020-07-11 12:58:44 +02:00
Akim Demaille
44f28d10ee reports: let html reports catch up with --report and --graph
* data/xslt/xml2xhtml.xsl: Show the symbol types.
* tests/report.at: Adjust.
2020-07-11 12:58:44 +02:00
Akim Demaille
44ad466a32 reports: let xml reports catch up with --report and --graph
The text and Dot reports are expected to be identical when generated
directly (--report, --graph) or indirectly (via XML).  The xml
testsuite had not be run for ages, let it catch up a bit.

* src/print-xml.c: Pass the type of the symbols.
* data/xslt/xml2text.xsl
Catch up with the new layout.
Display the symbol types.
Use '•', not '.'
* tests/local.at: Smash '•' to '.' when matching against the direct
text report.
* tests/report.at: Adjust XML expectations.
2020-07-11 12:58:44 +02:00
Akim Demaille
a839f4c461 reports: update html ouput
* data/xslt/xml2xhtml.xsl: Improve indentation.
Use ul/li rather that pre.
2020-07-11 12:58:44 +02:00
Akim Demaille
9a51c6a128 tests: check html
* tests/report.at: here.
2020-07-11 12:58:44 +02:00
Akim Demaille
2608b0cf12 style: factor complex expressions
* src/print-xml.c, src/print.c: Introduce a variable pointing to the
current symbol.
2020-07-11 12:58:44 +02:00
Akim Demaille
aa766d1560 maint: make it easier to update expectations
* tests/local.mk (update-tests): New.
2020-07-11 12:58:44 +02:00
Akim Demaille
a7ed13b25f maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-07-09 21:38:23 +02:00
Akim Demaille
2d90916067 version 3.6.91
* NEWS: Record release date.
v3.6.91
2020-07-09 21:10:23 +02:00
Akim Demaille
91e5a23ff2 news: update 2020-07-09 20:29:24 +02:00
Akim Demaille
d4ae66c371 gnulib: update 2020-07-09 20:26:16 +02:00
Akim Demaille
70fb574717 examples: add license headers
Prompted by Rici Lake.
https://stackoverflow.com/questions/62658368/#comment110853985_62661621
Discussed with Paul Eggert.

* doc/bison.texi, examples/c/bistromathic/parse.y,
* examples/c/lexcalc/parse.y, examples/c/lexcalc/scan.l,
* examples/c/pushcalc/calc.y, examples/c/reccalc/parse.y,
* examples/c/reccalc/scan.l, examples/d/calc.y,
* examples/java/calc/Calc.y, examples/java/simple/Calc.y:
Install the GPL3+ header.
2020-07-08 22:19:37 +02:00
Akim Demaille
0820f16ca8 style: update comments
* src/reader.c: action_obstack was removed in 2002...
* src/parse-gram.y: Better names.
* src/scan-code.h: More comments.
2020-07-05 09:59:45 +02:00
Akim Demaille
49f1e5f428 style: update comments in the skeletons
* data/skeletons/c++.m4, data/skeletons/glr.c, data/skeletons/lalr1.d,
* data/skeletons/lalr1.java, data/skeletons/yacc.c:
Be more accurate about yychar and yytoken.
Don't name local variables as if they were members.
2020-07-05 09:59:25 +02:00
Akim Demaille
238692ad77 doc: more details about symbols in m4
* data/README.md: here.
* README-hacking.md (Vocabulary): More.
2020-07-05 09:18:27 +02:00
Akim Demaille
5f95583da7 regen 2020-07-05 08:18:51 +02:00
Akim Demaille
964fb2aa6f examples: include the generated header
* examples/c/bistromathic/parse.y, examples/c/lexcalc/parse.y,
* examples/c/reccalc/parse.y: here.
Add some comments.

* src/parse-gram.y (api_version): Pull out of handle_require.
Bump to 3.7.
2020-07-05 08:18:51 +02:00
Akim Demaille
7c0d36b760 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-07-04 12:37:45 +02:00
Akim Demaille
b4d18c7fc6 version 3.6.90
* NEWS: Record release date.
v3.6.90
2020-07-04 12:14:28 +02:00
Akim Demaille
3e6e51cf5c news: update 2020-07-04 12:12:33 +02:00
Akim Demaille
d309bd9f9f package: fix syntax-check errors
* examples/c/bistromathic/bistromathic.test, po/POTFILES.in: here.
2020-07-04 12:10:15 +02:00
Akim Demaille
203f7230ec gnulib: update 2020-07-04 11:43:41 +02:00
Akim Demaille
156e548341 cex: give more details about -Wcex and -rcex
* data/bison-default.css: Cobalt does not seem to be supported.
* doc/bison.texi (Counterexamples): A new section.
(Understanding): Show the counterexamples as it shows in the report:
with its items.
(Bison Options): Document -Wcex and -rcex.
2020-07-04 11:43:35 +02:00
Akim Demaille
526ef45f30 news: update 2020-07-03 07:07:28 +02:00
Akim Demaille
d7f7fcd9c7 dot: also use a dot in the output
* src/print-graph.c (print_core): Use a dot instead of a point.
* doc/figs/example-reduce.gv, doc/figs/example-reduce.txt,
* doc/figs/example-shift.gv, doc/figs/example-shift.txt,
* doc/figs/example.gv: Update.
* tests/output.at, tests/report.at: Adjust.
2020-07-03 06:51:57 +02:00
Akim Demaille
0fd542c3e0 doc: improve a sentence
* doc/bison.texi: here.
2020-07-02 07:21:33 +02:00
Akim Demaille
413908e5a4 news: formatting changes 2020-07-01 07:05:48 +02:00
Akim Demaille
84ef175287 news, todo: update 2020-07-01 07:05:41 +02:00
Akim Demaille
5234c8390f doc: clarify that the pcontext interface is *.c only
Reported by Rici Lake.
https://lists.gnu.org/r/bug-bison/2020-06/msg00054.html

* doc/bison.texi (Syntax Error Reporting Function): Make it clear that
this is not exported.
Remove C++ details that landed in the C doc.
2020-06-30 20:16:31 +02:00
Akim Demaille
21f7690570 doc: use color in the cex examples
* doc/bison.texi: here.
And use smallexample when it no longer fits in PDF.
2020-06-30 20:16:31 +02:00
Akim Demaille
edb39c29a2 doc: repair the references to the Bibliography
In commit c80cdf2db2 ("doc: simplify
uses of @ref", Jan 27 2020, released in Bison 3.6), I broke the
references to the Bibliography.  For instance:

     For a more detailed exposition of the mysterious behavior in LALR parsers
    -and the benefits of IELR, @pxref{Bibliography,,Denny 2008 March}, and
    -@ref{Bibliography,,Denny 2010 November}.
    +and the benefits of IELR, @pxref{Bibliography}, and
    +@ref{Bibliography}.

which results in "see Bibliography" twice, instead of the more precise
reference.

* doc/bison.texi (@pcite, @tcite): New.
Use them instead of @ref to Bibliography.
Cite only the first author (that's what we did for the other entries).
2020-06-30 08:01:40 +02:00
Vincent Imbimbo
1247d94ba6 doc: cex documentation
* NEWS, doc/bison.texi: Add documentation for conflict counterexample
generation.
2020-06-30 08:01:40 +02:00
Akim Demaille
ed9a821caa doc: update Doxygen template file
* doc/Doxyfile.in: here.
2020-06-30 08:01:40 +02:00
Akim Demaille
330552ea49 yacc.c: push: don't clear the parser state when accepting/rejecting
Currently when a push parser finishes its parsing (i.e., it did not
return YYPUSH_MORE), it also clears its state.  It is therefore
impossible to see if it had parse errors.

In the context of autocompletion, because error recovery might have
fired, the parser is actually already in a different state.  For
instance on `(1 + + <TAB>` in the bistromathic, because there's a
`exp: "(" error ")"` recovery rule, `1 + +` tokens have already been
popped, replaced by `error`, and autocompletions think we are ready
for the closing ")".  So here, we would like to see if there was a
syntax error, yet `yynerrs` was cleared.

In the case of a successful parse, we still have a problem: if error
recovery succeeded, we won't know it, since, again, `yynerrs` is
clearer.

It seems much more natural to leave the parser state available for
analysis when there is a failure.

To reuse the parser, we should either:

1. provide an explicit means to reinitialize a parser state for future
   parses.

2. automatically reset the parser state when it is used in a new
   parse.

Option 2 requires to check whether we need to reinitialize the parser
each time we call `yypush_parse`, i.e., each time we give a new token.
This seems expensive compared to Option 1, but benchmarks revealed no
difference.  Option 1 is incompatible with the documentation
("After `yypush_parse` returns a status other than `YYPUSH_MORE`, the
parser instance `yyps` may be reused for a new parse.").

So Option 2 wins, reusing the private `yynew` member to record that a
parse was finished, and therefore that the state must reset in the
next call to `yypull_parse`.

While at it, this implementation now reuses the previously enlarged
stacks from one parse to another.

* data/skeletons/yacc.c (yypstate_new): Set up the stacks in their
initial configurations (setting their bottom to the stack array), and
use yypstate_clear to reset them (moving their top to their bottom).
(yypstate_delete): Adjust.
(yypush_parse): At the beginning, clear yypstate if needed, and at the
end, record when yypstate needs to be clearer.

* examples/c/bistromathic/parse.y (expected_tokens): Do not propose
autocompletion when there are parse errors.
* examples/c/bistromathic/bistromathic.test: Check that case.
2020-06-29 19:36:41 +02:00
Akim Demaille
7c609859ee bistromathic: don't display undefined locations
Currently, completion when there is a syntax error shows broken
locations.

* examples/c/bistromathic/parse.y (expected_tokens): Initialize the
location.
* examples/c/bistromathic/bistromathic.test: Check that.
2020-06-29 19:10:05 +02:00
Akim Demaille
ed10c308fa yacc.c: simplify initialization of push parsers
The previous commit ("yacc.c: declare and initialize and the same
time") made b4_initialize_parser_state_variables useless.

* data/skeletons/yacc.c (b4_initialize_parser_state_variables): Inline
into...
(yypstate_clear): here.
2020-06-29 19:10:05 +02:00
Akim Demaille
b91566edd1 regen 2020-06-29 19:10:05 +02:00
Akim Demaille
29520abb3b yacc.c: declare and initialize and the same time
In order to factor the code of push and pull parsers, the declaration
of the parser's state variable was common (being local variable in
pull parsers, and struct members in push parsers).  This result in
rather poor style in pull parser, with first variable declarations,
and then their initializations.

The initialization is about to differ between push and pull parsers,
so it is no longer worth keeping both cases together.

* data/skeletons/yacc.c (b4_declare_parser_state_variables): Accept an
argument, and when it is set, initialize the variables.
Adjust dependencies.
2020-06-29 19:10:05 +02:00
Akim Demaille
2491de1eef yacc.c: style changes in push mode
* data/skeletons/yacc.c: here.
2020-06-29 19:10:05 +02:00
Akim Demaille
ec207d1bb2 yacc.c: simplify yypull_parse
Currently yypull_parse takes a yypstate* as argument, and accepts it
to be NULL.  This does not seem to make a lot of sense: rather it is
its callers that should do that.

I believe this is historical: yypull_parse was introduced
first (c3d503425f), with yyparse being a
macro.  So yyparse could hardly deal with memory allocation properly.
In 7172e23e8f that yyparse was turned
into a genuine function.  At that point, it should have allocated its
own yypstate*, which would have left yypull_parse deal with only one
single non-null ypstate* argument.

Fortunately, it is nowhere documented that it is valid to pass NULL to
yypull_parse.  It is now forbidden.

* data/skeletons/yacc.c (yypull_parse): Don't allocate a yypstate.
Needs a location to issue the error message.
(yyparse): Allocate the yypstate.
2020-06-29 19:10:05 +02:00
Akim Demaille
688b3404a2 doc: tidy the text files
* etc/README: Rename/reformat as...
* etc/README.md: this.
And ship it.
2020-06-29 19:10:05 +02:00