Stop storing rules from 1 to nrules + 1.

* src/LR0.c, src/closure.c, src/derives.c, src/gram.c, src/lalr.c
* src/nullable.c, src/output.c, src/print.c, src/reader.c
* src/reduce.c: Allocate and free from &rules[0], not &rules[1].
Iterate from 0 to nrules.
Use rule_number_as_item_number and item_number_as_rule_number.
Adjust to `derive' now containing possibly 0.
* src/gram.h (rule_number_as_item_number, item_number_as_rule_number):
Handle the `- 1' part in rule numbers from/to item numbers.
* src/conflicts.c (log_resolution): Fix the message which reversed
shift and reduce.
* src/output.c (action_row): Initialize default_rule to -1.
(token_actions): Adjust.
* tests/sets.at (Nullable, Firsts): Fix the previously bogus
expected output.
* tests/conflicts.at (Resolved SR Conflicts): Likewise.
This commit is contained in:
Akim Demaille
2002-07-25 21:21:02 +00:00
parent 4a2a22f4c0
commit 4b3d3a8e46
15 changed files with 124 additions and 104 deletions

View File

@@ -326,7 +326,7 @@ state 5
1 | exp OP exp . [$, OP]
$default reduce using rule 1 (exp)
Conflict between rule 2 and token OP resolved as shift (%left OP).
Conflict between rule 1 and token OP resolved as reduce (%left OP).
]])
AT_CLEANUP

View File

@@ -98,12 +98,12 @@ FIRSTS
e
FDERIVES
$axiom derives
1 e $
2 'e'
3 /* empty */
0 e $
1 'e'
2 /* empty */
e derives
2 'e'
3 /* empty */
1 'e'
2 /* empty */
]])
AT_CLEANUP
@@ -233,22 +233,22 @@ FIRSTS
exp
FDERIVES
$axiom derives
1 exp $
2 exp '<' exp
3 exp '>' exp
4 exp '+' exp
5 exp '-' exp
6 exp '^' exp
7 exp '=' exp
8 "exp"
0 exp $
1 exp '<' exp
2 exp '>' exp
3 exp '+' exp
4 exp '-' exp
5 exp '^' exp
6 exp '=' exp
7 "exp"
exp derives
2 exp '<' exp
3 exp '>' exp
4 exp '+' exp
5 exp '-' exp
6 exp '^' exp
7 exp '=' exp
8 "exp"
1 exp '<' exp
2 exp '>' exp
3 exp '+' exp
4 exp '-' exp
5 exp '^' exp
6 exp '=' exp
7 "exp"
]])
AT_CLEANUP