mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 21:33:04 +00:00
* src/LR0.c (new_state): Recognize the final state by the fact it
is reached by eoftoken. (insert_start_shifting_state, insert_eof_shifting_state) (insert_accepting_state, augment_automaton): Remove, since now these states are automatically computed from the initial state. (generate_states): Adjust. * src/print.c: When reporting a rule number to the user, substract 1, so that the axiom rule is rule 0, and the first user rule is 1. * src/reduce.c: Likewise. * src/print_graph.c (print_core): For the time being, just as for the report, depend upon --trace-flags to dump the full set of items. * src/reader.c (readgram): Once the grammar read, insert the rule 0: `$axiom: START-SYMBOL $'. * tests/set.at: Adjust: rule 0 is now displayed, and since the number of the states has changed (the final state is no longer necessarily the last), catch up.
This commit is contained in:
18
src/reader.c
18
src/reader.c
@@ -71,6 +71,7 @@ static int lastprec;
|
||||
static bucket *errtoken = NULL;
|
||||
static bucket *undeftoken = NULL;
|
||||
static bucket *eoftoken = NULL;
|
||||
static bucket *axiom = NULL;
|
||||
|
||||
static symbol_list *
|
||||
symbol_list_new (bucket *sym)
|
||||
@@ -1450,6 +1451,18 @@ readgram (void)
|
||||
t = lex ();
|
||||
}
|
||||
|
||||
/* Insert the initial rule:
|
||||
|
||||
axiom: %start EOF. */
|
||||
p = symbol_list_new (axiom);
|
||||
p->next = symbol_list_new (startval);
|
||||
p->next->next = symbol_list_new (eoftoken);
|
||||
p->next->next->next = symbol_list_new (NULL);
|
||||
p->next->next->next->next = grammar;
|
||||
nrules += 1;
|
||||
nitems += 3;
|
||||
grammar = p;
|
||||
startval = axiom;
|
||||
|
||||
/* grammar has been read. Do some checking */
|
||||
|
||||
@@ -1807,6 +1820,11 @@ reader (void)
|
||||
/* Initialize the symbol table. */
|
||||
tabinit ();
|
||||
|
||||
/* Construct the axiom symbol. */
|
||||
axiom = getsym ("$axiom");
|
||||
axiom->class = nterm_sym;
|
||||
axiom->value = nvars++;
|
||||
|
||||
/* Construct the error token */
|
||||
errtoken = getsym ("error");
|
||||
errtoken->class = token_sym;
|
||||
|
||||
Reference in New Issue
Block a user