cex: display the rule numbers

From

    Example: "if" expr "then" "if" expr "then" stmt • "else" stmt
    Shift derivation
      if_stmt
      ↳ "if" expr "then" stmt
                         ↳ if_stmt
                           ↳ "if" expr "then" stmt • "else" stmt
    Reduce derivation
      if_stmt
      ↳ "if" expr "then" stmt                        "else" stmt
                         ↳ if_stmt
                           ↳ "if" expr "then" stmt •

to

    Example: "if" expr "then" "if" expr "then" stmt • "else" stmt
    Shift derivation
      if_stmt
      ↳ 3: "if" expr "then" stmt
                            ↳ 2: if_stmt
                                 ↳ 4: "if" expr "then" stmt • "else" stmt
    Example: "if" expr "then" "if" expr "then" stmt • "else" stmt
    Reduce derivation
      if_stmt
      ↳ 4: "if" expr "then" stmt                              "else" stmt
                            ↳ 2: if_stmt
                                 ↳ 3: "if" expr "then" stmt •

* src/state-item.h, src/state-item.c (state_item_rule): New.
* src/derivation.h, src/derivation.c (struct derivation): Add a rule
member.
Adjust dependencies.
* src/counterexample.c, src/parse-simulation.c: Pass the rule to
derivation_new.
* src/derivation.c (fprintf_if): New.
(derivation_width, derivation_print_tree_impl): Take the rule number
into account.

* tests/conflicts.at, tests/counterexample.at, tests/diagnostics.at,
* tests/report.at: Adjust.

* doc/bison.texi: Adjust.
This commit is contained in:
Akim Demaille
2020-07-28 19:50:22 +02:00
parent 2becdace96
commit 3c36d871fa
13 changed files with 407 additions and 357 deletions

View File

@@ -1541,60 +1541,60 @@ input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples]
Example: exp "+" exp • "⊕" exp
Shift derivation
exp
↳ exp "+" exp
exp • "⊕" exp
2: exp "+" exp
↳ 1: exp • "⊕" exp
Reduce derivation
exp
exp "⊕" exp
exp "+" exp •
1: exp "⊕" exp
↳ 2: exp "+" exp •
input.y: warning: reduce/reduce conflict on tokens $end, "+", "⊕" [-Wcounterexamples]
Example: exp "+" exp •
First reduce derivation
exp
↳ exp "+" exp •
2: exp "+" exp •
Second reduce derivation
exp
↳ exp "+" exp •
3: exp "+" exp •
input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples]
Example: exp "+" exp • "⊕" exp
Shift derivation
exp
↳ exp "+" exp
exp • "⊕" exp
2: exp "+" exp
↳ 1: exp • "⊕" exp
Reduce derivation
exp
exp "⊕" exp
exp "+" exp •
1: exp "⊕" exp
↳ 3: exp "+" exp •
input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples]
Example: exp "⊕" exp • "⊕" exp
Shift derivation
exp
↳ exp "⊕" exp
exp • "⊕" exp
1: exp "⊕" exp
↳ 1: exp • "⊕" exp
Reduce derivation
exp
exp "⊕" exp
exp "⊕" exp •
1: exp "⊕" exp
↳ 1: exp "⊕" exp •
input.y: warning: shift/reduce conflict on token "+" [-Wcounterexamples]
Example: exp "⊕" exp • "+" exp
Shift derivation
exp
↳ exp "⊕" exp
exp • "+" exp
1: exp "⊕" exp
↳ 2: exp • "+" exp
Reduce derivation
exp
exp "+" exp
exp "⊕" exp •
2: exp "+" exp
↳ 1: exp "⊕" exp •
input.y: warning: shift/reduce conflict on token "+" [-Wcounterexamples]
Example: exp "⊕" exp • "+" exp
Shift derivation
exp
↳ exp "⊕" exp
exp • "+" exp
1: exp "⊕" exp
↳ 3: exp • "+" exp
Reduce derivation
exp
exp "+" exp
exp "⊕" exp •
2: exp "+" exp
↳ 1: exp "⊕" exp •
input.y:6.3-13: warning: rule useless in parser due to conflicts [-Wother]
]])
@@ -1745,12 +1745,12 @@ State 7
Example: exp "+" exp • "⊕" exp
Shift derivation
exp
↳ exp "+" exp
exp • "⊕" exp
2: exp "+" exp
↳ 1: exp • "⊕" exp
Reduce derivation
exp
exp "⊕" exp
exp "+" exp •
1: exp "⊕" exp
↳ 2: exp "+" exp •
reduce/reduce conflict on tokens $end, "+", "⊕":
2 exp: exp "+" exp •
@@ -1758,10 +1758,10 @@ State 7
Example: exp "+" exp •
First reduce derivation
exp
↳ exp "+" exp •
2: exp "+" exp •
Second reduce derivation
exp
↳ exp "+" exp •
3: exp "+" exp •
shift/reduce conflict on token "⊕":
3 exp: exp "+" exp •
@@ -1769,12 +1769,12 @@ State 7
Example: exp "+" exp • "⊕" exp
Shift derivation
exp
↳ exp "+" exp
exp • "⊕" exp
2: exp "+" exp
↳ 1: exp • "⊕" exp
Reduce derivation
exp
exp "⊕" exp
exp "+" exp •
1: exp "⊕" exp
↳ 3: exp "+" exp •
@@ -1798,12 +1798,12 @@ State 8
Example: exp "⊕" exp • "⊕" exp
Shift derivation
exp
↳ exp "⊕" exp
exp • "⊕" exp
1: exp "⊕" exp
↳ 1: exp • "⊕" exp
Reduce derivation
exp
exp "⊕" exp
exp "⊕" exp •
1: exp "⊕" exp
↳ 1: exp "⊕" exp •
shift/reduce conflict on token "+":
1 exp: exp "⊕" exp •
@@ -1811,12 +1811,12 @@ State 8
Example: exp "⊕" exp • "+" exp
Shift derivation
exp
↳ exp "⊕" exp
exp • "+" exp
1: exp "⊕" exp
↳ 2: exp • "+" exp
Reduce derivation
exp
exp "+" exp
exp "⊕" exp •
2: exp "+" exp
↳ 1: exp "⊕" exp •
shift/reduce conflict on token "+":
1 exp: exp "⊕" exp •
@@ -1824,12 +1824,12 @@ State 8
Example: exp "⊕" exp • "+" exp
Shift derivation
exp
↳ exp "⊕" exp
exp • "+" exp
1: exp "⊕" exp
↳ 3: exp • "+" exp
Reduce derivation
exp
exp "+" exp
exp "⊕" exp •
2: exp "+" exp
↳ 1: exp "⊕" exp •
]])