mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-23 03:03:02 +00:00
cex: update NEWS for 3.7
* NEWS: Update to the current style of cex display.
This commit is contained in:
182
NEWS
182
NEWS
@@ -2,39 +2,6 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
* Noteworthy changes in release ?.? (????-??-??) [?]
|
* Noteworthy changes in release ?.? (????-??-??) [?]
|
||||||
|
|
||||||
|
|
||||||
* Noteworthy changes in release 3.6.93 (2020-07-20) [beta]
|
|
||||||
|
|
||||||
** Bug fixes
|
|
||||||
|
|
||||||
Portability issues.
|
|
||||||
|
|
||||||
|
|
||||||
* Noteworthy changes in release 3.6.92 (2020-07-19) [beta]
|
|
||||||
|
|
||||||
Changes in the display of counterexamples.
|
|
||||||
|
|
||||||
** Documentation
|
|
||||||
|
|
||||||
*** Examples
|
|
||||||
|
|
||||||
The bistromathic demonstrates %param and how to quote sources in the error
|
|
||||||
messages:
|
|
||||||
|
|
||||||
> 123 456
|
|
||||||
1.5-7: syntax error: expected end of file or + or - or * or / or ^ before number
|
|
||||||
1 | 123 456
|
|
||||||
| ^~~
|
|
||||||
|
|
||||||
* Noteworthy changes in release 3.6.91 (2020-07-09) [beta]
|
|
||||||
|
|
||||||
** Bug fixes
|
|
||||||
|
|
||||||
Portability issues.
|
|
||||||
|
|
||||||
|
|
||||||
* Noteworthy changes in release 3.6.90 (2020-07-04) [beta]
|
|
||||||
|
|
||||||
** Deprecated features
|
** Deprecated features
|
||||||
|
|
||||||
The YYPRINT macro, which works only with yacc.c and only for tokens, was
|
The YYPRINT macro, which works only with yacc.c and only for tokens, was
|
||||||
@@ -51,52 +18,114 @@ Changes in the display of counterexamples.
|
|||||||
|
|
||||||
Contributed by Vincent Imbimbo.
|
Contributed by Vincent Imbimbo.
|
||||||
|
|
||||||
When given `--report=counterexamples` or `-Wcounterexamples`, bison will
|
When given `-Wcounterexamples`/`-Wcex`, bison will now output
|
||||||
now output counterexamples for conflicts in the grammar. These are
|
counterexamples for conflicts in the grammar.
|
||||||
strings in the grammar which can be parsed in two ways due to the
|
|
||||||
conflict. For example:
|
|
||||||
|
|
||||||
Shift/reduce conflict on token "/":
|
**** Unifying Counterexamples
|
||||||
Example exp "+" exp • "/" exp
|
|
||||||
|
Unifying counterexamples are strings which can be parsed in two ways due
|
||||||
|
to the conflict. For example on a grammar that contains the usual
|
||||||
|
"dangling else" ambiguity:
|
||||||
|
|
||||||
|
$ bison else.y
|
||||||
|
else.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
|
||||||
|
else.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
|
||||||
|
|
||||||
|
$ bison else.y -Wcex
|
||||||
|
else.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
|
||||||
|
else.y: warning: shift/reduce conflict on token "else" [-Wcounterexamples]
|
||||||
|
Example: "if" exp "then" "if" exp "then" exp • "else" exp
|
||||||
Shift derivation
|
Shift derivation
|
||||||
exp
|
exp
|
||||||
↳ exp "+" exp
|
↳ "if" exp "then" exp
|
||||||
↳ exp • "/" exp
|
↳ "if" exp "then" exp • "else" exp
|
||||||
Example exp "+" exp • "/" exp
|
Example: "if" exp "then" "if" exp "then" exp • "else" exp
|
||||||
Reduce derivation
|
Reduce derivation
|
||||||
exp
|
exp
|
||||||
↳ exp "/" exp
|
↳ "if" exp "then" exp "else" exp
|
||||||
↳ exp "+" exp •
|
↳ "if" exp "then" exp •
|
||||||
|
|
||||||
When Bison is installed with text styling enabled, the example is actually
|
When text styling is enabled, colors are used in the examples and the
|
||||||
shown twice, with colors highlighting the ambiguity.
|
derivations to highlight the structure of both analyses. In this case,
|
||||||
|
|
||||||
This is a shift/reduce conflict caused by none of the operators having
|
"if" exp "then" [ "if" exp "then" exp • ] "else" exp
|
||||||
precedence, so the example can be parsed in the two ways shown. When
|
|
||||||
bison cannot find an example that can be derived in two ways, it instead
|
|
||||||
generates two examples that are the same up until the dot:
|
|
||||||
|
|
||||||
First example expr • ID ',' ID $end
|
vs.
|
||||||
Shift derivation
|
|
||||||
$accept
|
"if" exp "then" [ "if" exp "then" exp • "else" exp ]
|
||||||
↳ s $end
|
|
||||||
↳ a ID
|
|
||||||
↳ expr
|
The counterexamples are "focused", in two different ways. First, they do
|
||||||
↳ expr • ID ','
|
not clutter the output with all the derivations from the start symbol,
|
||||||
Second example expr • ID $end
|
rather they start on the "conflicted nonterminal". They go straight to the
|
||||||
Reduce derivation
|
point. Second, they don't "expand" nonterminal symbols uselessly.
|
||||||
$accept
|
|
||||||
↳ s $end
|
**** Nonunifying Counterexamples
|
||||||
↳ a ID
|
|
||||||
↳ expr •
|
In the case of the dangling else, Bison found an example that can be
|
||||||
|
parsed in two ways (therefore proving that the grammar is ambiguous).
|
||||||
|
When it cannot find such an example, it instead generates two examples
|
||||||
|
that are the same up until the dot:
|
||||||
|
|
||||||
|
$ bison foo.y
|
||||||
|
foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
|
||||||
|
foo.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
|
||||||
|
foo.y:4.4-7: warning: rule useless in parser due to conflicts [-Wother]
|
||||||
|
4 | a: expr
|
||||||
|
| ^~~~
|
||||||
|
|
||||||
|
$ bison -Wcex foo.y
|
||||||
|
foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
|
||||||
|
foo.y: warning: shift/reduce conflict on token ID [-Wcounterexamples]
|
||||||
|
First example: expr • ID ',' ID $end
|
||||||
|
Shift derivation
|
||||||
|
$accept
|
||||||
|
↳ s $end
|
||||||
|
↳ a ID
|
||||||
|
↳ expr
|
||||||
|
↳ expr • ID ','
|
||||||
|
Second example: expr • ID $end
|
||||||
|
Reduce derivation
|
||||||
|
$accept
|
||||||
|
↳ s $end
|
||||||
|
↳ a ID
|
||||||
|
↳ expr •
|
||||||
|
foo.y:4.4-7: warning: rule useless in parser due to conflicts [-Wother]
|
||||||
|
4 | a: expr
|
||||||
|
| ^~~~
|
||||||
|
|
||||||
In these cases, the parser usually doesn't have enough lookahead to
|
In these cases, the parser usually doesn't have enough lookahead to
|
||||||
differentiate the two given examples.
|
differentiate the two given examples.
|
||||||
|
|
||||||
The counterexamples are "focused" in two different ways. First, they do
|
**** Reports
|
||||||
not clutter the output with all the derivations from the start symbol,
|
|
||||||
rather they start on the "conflicted nonterminal". They go straight to the
|
Counterexamples are also included in the report when given
|
||||||
point. Second, they don't "expand" nonterminal symbols uselessly.
|
`--report=counterexamples`/`-rcex` (or `--report=all`), with more
|
||||||
|
technical details:
|
||||||
|
|
||||||
|
State 7
|
||||||
|
|
||||||
|
1 exp: "if" exp "then" exp • [$end, "then", "else"]
|
||||||
|
2 | "if" exp "then" exp • "else" exp
|
||||||
|
|
||||||
|
"else" shift, and go to state 8
|
||||||
|
|
||||||
|
"else" [reduce using rule 1 (exp)]
|
||||||
|
$default reduce using rule 1 (exp)
|
||||||
|
|
||||||
|
shift/reduce conflict on token "else":
|
||||||
|
1 exp: "if" exp "then" exp •
|
||||||
|
2 exp: "if" exp "then" exp • "else" exp
|
||||||
|
Example: "if" exp "then" "if" exp "then" exp • "else" exp
|
||||||
|
Shift derivation
|
||||||
|
exp
|
||||||
|
↳ "if" exp "then" exp
|
||||||
|
↳ "if" exp "then" exp • "else" exp
|
||||||
|
Example: "if" exp "then" "if" exp "then" exp • "else" exp
|
||||||
|
Reduce derivation
|
||||||
|
exp
|
||||||
|
↳ "if" exp "then" exp "else" exp
|
||||||
|
↳ "if" exp "then" exp •
|
||||||
|
|
||||||
*** File prefix mapping
|
*** File prefix mapping
|
||||||
|
|
||||||
@@ -110,6 +139,11 @@ Changes in the display of counterexamples.
|
|||||||
|
|
||||||
** Changes
|
** Changes
|
||||||
|
|
||||||
|
*** Diagnostics
|
||||||
|
|
||||||
|
When text styling is enabled and the terminal supports it, the warnings
|
||||||
|
now include hyperlinks to the documentation.
|
||||||
|
|
||||||
*** Relocatable installation
|
*** Relocatable installation
|
||||||
|
|
||||||
When installed to be relocatable (via `configure --enable-relocatable`),
|
When installed to be relocatable (via `configure --enable-relocatable`),
|
||||||
@@ -150,6 +184,18 @@ Changes in the display of counterexamples.
|
|||||||
Now the parser state can be examined when parsing is finished. The parser
|
Now the parser state can be examined when parsing is finished. The parser
|
||||||
state is reset when starting a new parse.
|
state is reset when starting a new parse.
|
||||||
|
|
||||||
|
** Documentation
|
||||||
|
|
||||||
|
*** Examples
|
||||||
|
|
||||||
|
The bistromathic demonstrates %param and how to quote sources in the error
|
||||||
|
messages:
|
||||||
|
|
||||||
|
> 123 456
|
||||||
|
1.5-7: syntax error: expected end of file or + or - or * or / or ^ before number
|
||||||
|
1 | 123 456
|
||||||
|
| ^~~
|
||||||
|
|
||||||
** Bug fixes
|
** Bug fixes
|
||||||
|
|
||||||
*** Include the generated header (yacc.c)
|
*** Include the generated header (yacc.c)
|
||||||
@@ -4415,7 +4461,7 @@ LocalWords: yysymbol yytnamerr yyreport ctx ARGMAX yysyntax stderr LPAREN
|
|||||||
LocalWords: symrec yypcontext TOKENMAX yyexpected YYEMPTY yypstate YYEOF
|
LocalWords: symrec yypcontext TOKENMAX yyexpected YYEMPTY yypstate YYEOF
|
||||||
LocalWords: autocompletion bistromathic submessages Cayuela lexcalc hoc
|
LocalWords: autocompletion bistromathic submessages Cayuela lexcalc hoc
|
||||||
LocalWords: yytoken YYUNDEF YYerror basename Automake's UTF ifdef ffile
|
LocalWords: yytoken YYUNDEF YYerror basename Automake's UTF ifdef ffile
|
||||||
LocalWords: gotos readline Imbimbo Wcounterexamples
|
LocalWords: gotos readline Imbimbo Wcounterexamples Wcex Nonunifying rcex
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
ispell-dictionary: "american"
|
ispell-dictionary: "american"
|
||||||
|
|||||||
@@ -193,9 +193,8 @@ all_spaces (const char *s)
|
|||||||
//
|
//
|
||||||
// This function implements this.
|
// This function implements this.
|
||||||
//
|
//
|
||||||
// When COND is true, put S on OUT, preceeded by *PADDING white
|
// When COND is true, put S on OUT, preceded by *PADDING white spaces.
|
||||||
// spaces. Otherwise add the width to *PADDING. Return the width of
|
// Otherwise add the width to *PADDING. Return the width of S.
|
||||||
// S.
|
|
||||||
static int
|
static int
|
||||||
fputs_if (bool cond, FILE *out, int *padding, const char *s)
|
fputs_if (bool cond, FILE *out, int *padding, const char *s)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user