mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 16:53:02 +00:00
Use $accept and $end, as BYacc and BTYacc do, instead of $axiom and $.
* src/symtab.h, src/symtab.c (eoftoken, axiom): Rename as... (endtoken, accept): these. * src/reader.c (reader): Set endtoken's default tag to "$end". Set undeftoken's tag to "$undefined" instead of "$undefined.". * doc/bison.texinfo (Table of Symbols): Mention $accept and $end. Adjust.
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2002-07-29 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
Use $accept and $end, as BYacc and BTYacc do, instead of $axiom and $.
|
||||||
|
|
||||||
|
* src/symtab.h, src/symtab.c (eoftoken, axiom): Rename as...
|
||||||
|
(endtoken, accept): these.
|
||||||
|
* src/reader.c (reader): Set endtoken's default tag to "$end".
|
||||||
|
Set undeftoken's tag to "$undefined" instead of "$undefined.".
|
||||||
|
* doc/bison.texinfo (Table of Symbols): Mention $accept and $end.
|
||||||
|
Adjust.
|
||||||
|
|
||||||
2002-07-29 Akim Demaille <akim@epita.fr>
|
2002-07-29 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/reduce.c (reduce_grammar): When the language is empty,
|
* src/reduce.c (reduce_grammar): When the language is empty,
|
||||||
|
|||||||
12
TODO
12
TODO
@@ -4,6 +4,11 @@
|
|||||||
Write a first documentation for C++ output.
|
Write a first documentation for C++ output.
|
||||||
|
|
||||||
|
|
||||||
|
* Documentation
|
||||||
|
Before releasing, make sure the documentation refers to the current
|
||||||
|
`output' format.
|
||||||
|
|
||||||
|
|
||||||
* Error messages
|
* Error messages
|
||||||
Some are really funky. For instance
|
Some are really funky. For instance
|
||||||
|
|
||||||
@@ -121,13 +126,6 @@ this issue. Does anybody have it?
|
|||||||
|
|
||||||
* Documentation
|
* Documentation
|
||||||
|
|
||||||
** Vocabulary
|
|
||||||
Explain $axiom (and maybe change its name: BTYacc names it `goal',
|
|
||||||
byacc `$accept' probably based on AT&T Yacc, Meta `Start'...).
|
|
||||||
Complete the glossary (item, axiom, ?). Should we also rename `$'?
|
|
||||||
BYacc uses `$end'. `$eof' is attracting, but after all we may be
|
|
||||||
parsing a string, a stream etc.
|
|
||||||
|
|
||||||
** History/Bibliography
|
** History/Bibliography
|
||||||
Some history of Bison and some bibliography would be most welcome.
|
Some history of Bison and some bibliography would be most welcome.
|
||||||
Are there any Texinfo standards for bibliography?
|
Are there any Texinfo standards for bibliography?
|
||||||
|
|||||||
@@ -3553,9 +3553,9 @@ Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure
|
|||||||
Generate an array of token names in the parser file. The name of the
|
Generate an array of token names in the parser file. The name of the
|
||||||
array is @code{yytname}; @code{yytname[@var{i}]} is the name of the
|
array is @code{yytname}; @code{yytname[@var{i}]} is the name of the
|
||||||
token whose internal Bison token code number is @var{i}. The first
|
token whose internal Bison token code number is @var{i}. The first
|
||||||
three elements of @code{yytname} are always @code{"$"}, @code{"error"},
|
three elements of @code{yytname} are always @code{"$end"},
|
||||||
and @code{"$undefined."}; after these come the symbols defined in the
|
@code{"error"}, and @code{"$undefined"}; after these come the symbols
|
||||||
grammar file.
|
defined in the grammar file.
|
||||||
|
|
||||||
For single-character literal tokens and literal string tokens, the name
|
For single-character literal tokens and literal string tokens, the name
|
||||||
in the table includes the single-quote or double-quote characters: for
|
in the table includes the single-quote or double-quote characters: for
|
||||||
@@ -5276,12 +5276,19 @@ useless: STR;
|
|||||||
%%
|
%%
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@command{bison} reports that @samp{calc.y contains 1 useless nonterminal
|
@command{bison} reports:
|
||||||
and 1 useless rule} and that @samp{calc.y contains 7 shift/reduce
|
|
||||||
conflicts}. When given @option{--report=state}, in addition to
|
@example
|
||||||
@file{calc.tab.c}, it creates a file @file{calc.output} with contents
|
calc.y: warning: 1 useless nonterminal and 1 useless rule
|
||||||
detailed below. The order of the output and the exact presentation
|
calc.y:11.1-7: warning: useless nonterminal: useless
|
||||||
might vary, but the interpretation is the same.
|
calc.y:11.8-12: warning: useless rule: useless: STR
|
||||||
|
calc.y contains 7 shift/reduce conflicts.
|
||||||
|
@end example
|
||||||
|
|
||||||
|
When given @option{--report=state}, in addition to @file{calc.tab.c}, it
|
||||||
|
creates a file @file{calc.output} with contents detailed below. The
|
||||||
|
order of the output and the exact presentation might vary, but the
|
||||||
|
interpretation is the same.
|
||||||
|
|
||||||
The first section includes details on conflicts that were solved thanks
|
The first section includes details on conflicts that were solved thanks
|
||||||
to precedence and/or associativity:
|
to precedence and/or associativity:
|
||||||
@@ -5334,7 +5341,7 @@ The next section reproduces the exact grammar that Bison used:
|
|||||||
Grammar
|
Grammar
|
||||||
|
|
||||||
Number, Line, Rule
|
Number, Line, Rule
|
||||||
0 5 $axiom -> exp $
|
0 5 $accept -> exp $end
|
||||||
1 5 exp -> exp '+' exp
|
1 5 exp -> exp '+' exp
|
||||||
2 6 exp -> exp '-' exp
|
2 6 exp -> exp '-' exp
|
||||||
3 7 exp -> exp '*' exp
|
3 7 exp -> exp '*' exp
|
||||||
@@ -5348,7 +5355,7 @@ and reports the uses of the symbols:
|
|||||||
@example
|
@example
|
||||||
Terminals, with rules where they appear
|
Terminals, with rules where they appear
|
||||||
|
|
||||||
$ (0) 0
|
$end (0) 0
|
||||||
'*' (42) 3
|
'*' (42) 3
|
||||||
'+' (43) 1
|
'+' (43) 1
|
||||||
'-' (45) 2
|
'-' (45) 2
|
||||||
@@ -5358,7 +5365,7 @@ NUM (258) 5
|
|||||||
|
|
||||||
Nonterminals, with rules where they appear
|
Nonterminals, with rules where they appear
|
||||||
|
|
||||||
$axiom (8)
|
$accept (8)
|
||||||
on left: 0
|
on left: 0
|
||||||
exp (9)
|
exp (9)
|
||||||
on left: 1 2 3 4 5, on right: 0 1 2 3 4
|
on left: 1 2 3 4 5, on right: 0 1 2 3 4
|
||||||
@@ -5376,7 +5383,7 @@ that the input cursor.
|
|||||||
@example
|
@example
|
||||||
state 0
|
state 0
|
||||||
|
|
||||||
$axiom -> . exp $ (rule 0)
|
$accept -> . exp $ (rule 0)
|
||||||
|
|
||||||
NUM shift, and go to state 1
|
NUM shift, and go to state 1
|
||||||
|
|
||||||
@@ -5407,7 +5414,7 @@ be derived:
|
|||||||
@example
|
@example
|
||||||
state 0
|
state 0
|
||||||
|
|
||||||
$axiom -> . exp $ (rule 0)
|
$accept -> . exp $ (rule 0)
|
||||||
exp -> . exp '+' exp (rule 1)
|
exp -> . exp '+' exp (rule 1)
|
||||||
exp -> . exp '-' exp (rule 2)
|
exp -> . exp '-' exp (rule 2)
|
||||||
exp -> . exp '*' exp (rule 3)
|
exp -> . exp '*' exp (rule 3)
|
||||||
@@ -5439,7 +5446,7 @@ jump to state 2 (@samp{exp: go to state 2}).
|
|||||||
@example
|
@example
|
||||||
state 2
|
state 2
|
||||||
|
|
||||||
$axiom -> exp . $ (rule 0)
|
$accept -> exp . $ (rule 0)
|
||||||
exp -> exp . '+' exp (rule 1)
|
exp -> exp . '+' exp (rule 1)
|
||||||
exp -> exp . '-' exp (rule 2)
|
exp -> exp . '-' exp (rule 2)
|
||||||
exp -> exp . '*' exp (rule 3)
|
exp -> exp . '*' exp (rule 3)
|
||||||
@@ -5466,7 +5473,7 @@ state}:
|
|||||||
@example
|
@example
|
||||||
state 3
|
state 3
|
||||||
|
|
||||||
$axiom -> exp $ . (rule 0)
|
$accept -> exp $ . (rule 0)
|
||||||
|
|
||||||
$default accept
|
$default accept
|
||||||
@end example
|
@end example
|
||||||
@@ -6006,7 +6013,7 @@ would instead be named @file{foo_tab.c}.
|
|||||||
@table @code
|
@table @code
|
||||||
@item @@$
|
@item @@$
|
||||||
In an action, the location of the left-hand side of the rule.
|
In an action, the location of the left-hand side of the rule.
|
||||||
@xref{Locations, , Locations Overview}.
|
@xref{Locations, , Locations Overview}.
|
||||||
|
|
||||||
@item @@@var{n}
|
@item @@@var{n}
|
||||||
In an action, the location of the @var{n}-th symbol of the right-hand
|
In an action, the location of the @var{n}-th symbol of the right-hand
|
||||||
@@ -6020,6 +6027,20 @@ In an action, the semantic value of the left-hand side of the rule.
|
|||||||
In an action, the semantic value of the @var{n}-th symbol of the
|
In an action, the semantic value of the @var{n}-th symbol of the
|
||||||
right-hand side of the rule. @xref{Actions}.
|
right-hand side of the rule. @xref{Actions}.
|
||||||
|
|
||||||
|
@item $accept
|
||||||
|
The predefined nonterminal whose only rule is @samp{$accept: @var{start}
|
||||||
|
$end}, where @var{start} is the start symbol. @xref{Start Decl, , The
|
||||||
|
Start-Symbol}. It cannot be used in the grammar.
|
||||||
|
|
||||||
|
@item $end
|
||||||
|
The predefined token marking the end of the token stream. It cannot be
|
||||||
|
used in the grammar.
|
||||||
|
|
||||||
|
@item $undefined
|
||||||
|
The predefined token onto which all undefined values returned by
|
||||||
|
@code{yylex} are mapped. It cannot be used in the grammar, rather, use
|
||||||
|
@code{error}.
|
||||||
|
|
||||||
@item error
|
@item error
|
||||||
A token name reserved for error recovery. This token may be used in
|
A token name reserved for error recovery. This token may be used in
|
||||||
grammar rules so as to allow the Bison parser to recognize an error in
|
grammar rules so as to allow the Bison parser to recognize an error in
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ state_list_append (symbol_number_t symbol,
|
|||||||
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
|
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
|
||||||
nstates, symbol, symbols[symbol]->tag);
|
nstates, symbol, symbols[symbol]->tag);
|
||||||
|
|
||||||
/* If this is the eoftoken, and this is not the initial state, then
|
/* If this is the endtoken, and this is not the initial state, then
|
||||||
this is the final state. */
|
this is the final state. */
|
||||||
if (symbol == 0 && first_state)
|
if (symbol == 0 && first_state)
|
||||||
final_state = state;
|
final_state = state;
|
||||||
@@ -283,7 +283,7 @@ save_reductions (state_t *state)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* If this is the final state, we want it to have no reductions at
|
/* If this is the final state, we want it to have no reductions at
|
||||||
all, although it has one for `START_SYMBOL EOF .'. */
|
all, although it has one for `START_SYMBOL $end .'. */
|
||||||
if (final_state && state->number == final_state->number)
|
if (final_state && state->number == final_state->number)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
16
src/gram.h
16
src/gram.h
@@ -36,16 +36,16 @@
|
|||||||
|
|
||||||
The rules receive rule numbers 1 to NRULES in the order they are
|
The rules receive rule numbers 1 to NRULES in the order they are
|
||||||
written. More precisely Bison augments the grammar with the
|
written. More precisely Bison augments the grammar with the
|
||||||
initial rule, `$axiom: START-SYMBOL EOF', which is numbered 1, all
|
initial rule, `$accept: START-SYMBOL $end', which is numbered 1,
|
||||||
the user rules are 2, 3 etc. Each time a rule number is presented
|
all the user rules are 2, 3 etc. Each time a rule number is
|
||||||
to the user, we subtract 1, so *displayed* rule numbers are 0, 1,
|
presented to the user, we subtract 1, so *displayed* rule numbers
|
||||||
2...
|
are 0, 1, 2...
|
||||||
|
|
||||||
Internally, we cannot use the number 0 for a rule because for
|
Internally, we cannot use the number 0 for a rule because for
|
||||||
instance RITEM stores both symbol (the RHS) and rule numbers: the
|
instance RITEM stores both symbol (the RHS) and rule numbers: the
|
||||||
symbols are shorts >= 0, and rule number are stored negative.
|
symbols are shorts >= 0, and rule number are stored negative.
|
||||||
Therefore 0 cannot be used, since it would be both the rule number
|
Therefore 0 cannot be used, since it would be both the rule number
|
||||||
0, and the token EOF).
|
0, and the token $end).
|
||||||
|
|
||||||
Actions are accessed via the rule number.
|
Actions are accessed via the rule number.
|
||||||
|
|
||||||
@@ -68,9 +68,11 @@
|
|||||||
|
|
||||||
RULES[R].assoc -- the associativity of R.
|
RULES[R].assoc -- the associativity of R.
|
||||||
|
|
||||||
RULES[R].dprec -- the dynamic precedence level of R (for GLR parsing).
|
RULES[R].dprec -- the dynamic precedence level of R (for GLR
|
||||||
|
parsing).
|
||||||
|
|
||||||
RULES[R].merger -- index of merging function for R (for GLR parsing).
|
RULES[R].merger -- index of merging function for R (for GLR
|
||||||
|
parsing).
|
||||||
|
|
||||||
RULES[R].line -- the line where R was defined.
|
RULES[R].line -- the line where R was defined.
|
||||||
|
|
||||||
|
|||||||
28
src/reader.c
28
src/reader.c
@@ -475,10 +475,10 @@ reader (void)
|
|||||||
/* Initialize the symbol table. */
|
/* Initialize the symbol table. */
|
||||||
symbols_new ();
|
symbols_new ();
|
||||||
|
|
||||||
/* Construct the axiom symbol. */
|
/* Construct the accept symbol. */
|
||||||
axiom = symbol_get ("$axiom", empty_location);
|
accept = symbol_get ("$accept", empty_location);
|
||||||
axiom->class = nterm_sym;
|
accept->class = nterm_sym;
|
||||||
axiom->number = nvars++;
|
accept->number = nvars++;
|
||||||
|
|
||||||
/* Construct the error token */
|
/* Construct the error token */
|
||||||
errtoken = symbol_get ("error", empty_location);
|
errtoken = symbol_get ("error", empty_location);
|
||||||
@@ -487,7 +487,7 @@ reader (void)
|
|||||||
|
|
||||||
/* Construct a token that represents all undefined literal tokens.
|
/* Construct a token that represents all undefined literal tokens.
|
||||||
It is always token number 2. */
|
It is always token number 2. */
|
||||||
undeftoken = symbol_get ("$undefined.", empty_location);
|
undeftoken = symbol_get ("$undefined", empty_location);
|
||||||
undeftoken->class = token_sym;
|
undeftoken->class = token_sym;
|
||||||
undeftoken->number = ntokens++;
|
undeftoken->number = ntokens++;
|
||||||
|
|
||||||
@@ -515,25 +515,25 @@ reader (void)
|
|||||||
/* Report any undefined symbols and consider them nonterminals. */
|
/* Report any undefined symbols and consider them nonterminals. */
|
||||||
symbols_check_defined ();
|
symbols_check_defined ();
|
||||||
|
|
||||||
/* If the user did not define her EOFTOKEN, do it now. */
|
/* If the user did not define her ENDTOKEN, do it now. */
|
||||||
if (!eoftoken)
|
if (!endtoken)
|
||||||
{
|
{
|
||||||
eoftoken = symbol_get ("$", empty_location);
|
endtoken = symbol_get ("$end", empty_location);
|
||||||
eoftoken->class = token_sym;
|
endtoken->class = token_sym;
|
||||||
eoftoken->number = 0;
|
endtoken->number = 0;
|
||||||
/* Value specified by POSIX. */
|
/* Value specified by POSIX. */
|
||||||
eoftoken->user_token_number = 0;
|
endtoken->user_token_number = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the initial rule, which line is that of the first rule
|
/* Insert the initial rule, which line is that of the first rule
|
||||||
(not that of the start symbol):
|
(not that of the start symbol):
|
||||||
|
|
||||||
axiom: %start EOF. */
|
accept: %start EOF. */
|
||||||
{
|
{
|
||||||
symbol_list_t *p = symbol_list_new (axiom, empty_location);
|
symbol_list_t *p = symbol_list_new (accept, empty_location);
|
||||||
p->location = grammar->location;
|
p->location = grammar->location;
|
||||||
p->next = symbol_list_new (startsymbol, empty_location);
|
p->next = symbol_list_new (startsymbol, empty_location);
|
||||||
p->next->next = symbol_list_new (eoftoken, empty_location);
|
p->next->next = symbol_list_new (endtoken, empty_location);
|
||||||
p->next->next->next = symbol_list_new (NULL, empty_location);
|
p->next->next->next = symbol_list_new (NULL, empty_location);
|
||||||
p->next->next->next->next = grammar;
|
p->next->next->next->next = grammar;
|
||||||
nrules += 1;
|
nrules += 1;
|
||||||
|
|||||||
10
src/reduce.c
10
src/reduce.c
@@ -161,9 +161,9 @@ inaccessable_symbols (void)
|
|||||||
Pp = bitset_create (nrules, BITSET_FIXED);
|
Pp = bitset_create (nrules, BITSET_FIXED);
|
||||||
|
|
||||||
/* If the start symbol isn't useful, then nothing will be useful. */
|
/* If the start symbol isn't useful, then nothing will be useful. */
|
||||||
if (bitset_test (N, axiom->number - ntokens))
|
if (bitset_test (N, accept->number - ntokens))
|
||||||
{
|
{
|
||||||
bitset_set (V, axiom->number);
|
bitset_set (V, accept->number);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@@ -194,7 +194,7 @@ inaccessable_symbols (void)
|
|||||||
V = Vp;
|
V = Vp;
|
||||||
|
|
||||||
/* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */
|
/* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */
|
||||||
bitset_set (V, eoftoken->number); /* end-of-input token */
|
bitset_set (V, endtoken->number); /* end-of-input token */
|
||||||
bitset_set (V, errtoken->number); /* error token */
|
bitset_set (V, errtoken->number); /* error token */
|
||||||
bitset_set (V, undeftoken->number); /* some undefined token */
|
bitset_set (V, undeftoken->number); /* some undefined token */
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ nonterminals_reduce (void)
|
|||||||
if (ISVAR (*rhsp))
|
if (ISVAR (*rhsp))
|
||||||
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp]);
|
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp]);
|
||||||
}
|
}
|
||||||
axiom->number = nontermmap[axiom->number];
|
accept->number = nontermmap[accept->number];
|
||||||
}
|
}
|
||||||
|
|
||||||
nsyms -= nuseless_nonterminals;
|
nsyms -= nuseless_nonterminals;
|
||||||
@@ -438,7 +438,7 @@ reduce_grammar (void)
|
|||||||
|
|
||||||
reduce_print ();
|
reduce_print ();
|
||||||
|
|
||||||
if (!bitset_test (N, axiom->number - ntokens))
|
if (!bitset_test (N, accept->number - ntokens))
|
||||||
fatal_at (startsymbol_location,
|
fatal_at (startsymbol_location,
|
||||||
_("start symbol %s does not derive any sentence"),
|
_("start symbol %s does not derive any sentence"),
|
||||||
startsymbol->tag);
|
startsymbol->tag);
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ reductions_new (int num, rule_number_t *reductions)
|
|||||||
|
|
||||||
state_number_t nstates = 0;
|
state_number_t nstates = 0;
|
||||||
/* FINAL_STATE is properly set by new_state when it recognizes its
|
/* FINAL_STATE is properly set by new_state when it recognizes its
|
||||||
accessing symbol: EOF. */
|
accessing symbol: $end. */
|
||||||
state_t *final_state = NULL;
|
state_t *final_state = NULL;
|
||||||
|
|
||||||
#define STATE_ALLOC(Nitems) \
|
#define STATE_ALLOC(Nitems) \
|
||||||
|
|||||||
16
src/symtab.c
16
src/symtab.c
@@ -32,8 +32,8 @@
|
|||||||
|
|
||||||
symbol_t *errtoken = NULL;
|
symbol_t *errtoken = NULL;
|
||||||
symbol_t *undeftoken = NULL;
|
symbol_t *undeftoken = NULL;
|
||||||
symbol_t *eoftoken = NULL;
|
symbol_t *endtoken = NULL;
|
||||||
symbol_t *axiom = NULL;
|
symbol_t *accept = NULL;
|
||||||
symbol_t *startsymbol = NULL;
|
symbol_t *startsymbol = NULL;
|
||||||
location_t startsymbol_location;
|
location_t startsymbol_location;
|
||||||
|
|
||||||
@@ -181,11 +181,11 @@ symbol_user_token_number_set (symbol_t *symbol,
|
|||||||
symbol->tag);
|
symbol->tag);
|
||||||
|
|
||||||
symbol->user_token_number = user_token_number;
|
symbol->user_token_number = user_token_number;
|
||||||
/* User defined EOF token? */
|
/* User defined $end token? */
|
||||||
if (user_token_number == 0)
|
if (user_token_number == 0)
|
||||||
{
|
{
|
||||||
eoftoken = symbol;
|
endtoken = symbol;
|
||||||
eoftoken->number = 0;
|
endtoken->number = 0;
|
||||||
/* It is always mapped to 0, so it was already counted in
|
/* It is always mapped to 0, so it was already counted in
|
||||||
NTOKENS. */
|
NTOKENS. */
|
||||||
--ntokens;
|
--ntokens;
|
||||||
@@ -322,7 +322,7 @@ symbol_pack (symbol_t *this)
|
|||||||
prec and assoc fields and make both the same */
|
prec and assoc fields and make both the same */
|
||||||
if (this->number == NUMBER_UNDEFINED)
|
if (this->number == NUMBER_UNDEFINED)
|
||||||
{
|
{
|
||||||
if (this == eoftoken || this->alias == eoftoken)
|
if (this == endtoken || this->alias == endtoken)
|
||||||
this->number = this->alias->number = 0;
|
this->number = this->alias->number = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -540,8 +540,8 @@ symbols_token_translations_init (void)
|
|||||||
token_translations = XCALLOC (symbol_number_t, max_user_token_number + 1);
|
token_translations = XCALLOC (symbol_number_t, max_user_token_number + 1);
|
||||||
|
|
||||||
/* Initialize all entries for literal tokens to 2, the internal
|
/* Initialize all entries for literal tokens to 2, the internal
|
||||||
token number for $undefined., which represents all invalid
|
token number for $undefined, which represents all invalid inputs.
|
||||||
inputs. */
|
*/
|
||||||
for (i = 0; i < max_user_token_number + 1; i++)
|
for (i = 0; i < max_user_token_number + 1; i++)
|
||||||
token_translations[i] = undeftoken->number;
|
token_translations[i] = undeftoken->number;
|
||||||
symbols_do (symbol_translation, NULL);
|
symbols_do (symbol_translation, NULL);
|
||||||
|
|||||||
@@ -127,8 +127,8 @@ void symbol_user_token_number_set PARAMS ((symbol_t *symbol,
|
|||||||
*/
|
*/
|
||||||
extern symbol_t *errtoken;
|
extern symbol_t *errtoken;
|
||||||
extern symbol_t *undeftoken;
|
extern symbol_t *undeftoken;
|
||||||
extern symbol_t *eoftoken;
|
extern symbol_t *endtoken;
|
||||||
extern symbol_t *axiom;
|
extern symbol_t *accept;
|
||||||
extern symbol_t *startsymbol;
|
extern symbol_t *startsymbol;
|
||||||
extern location_t startsymbol_location;
|
extern location_t startsymbol_location;
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ thing(10): 'x'(10)
|
|||||||
sending: ';' (value = 11, line 110)
|
sending: ';' (value = 11, line 110)
|
||||||
line(10): thing(10) ';'
|
line(10): thing(10) ';'
|
||||||
sending: 'y' (value = 12, line 120)
|
sending: 'y' (value = 12, line 120)
|
||||||
120: parse error, unexpected $undefined., expecting $ or error or 'x'
|
120: parse error, unexpected $undefined, expecting $end or error or 'x'
|
||||||
sending: EOF
|
sending: EOF
|
||||||
Freeing nterm line (10 from 100)
|
Freeing nterm line (10 from 100)
|
||||||
Freeing nterm line (7 from 70)
|
Freeing nterm line (7 from 70)
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ _AT_CHECK_CALC_ERROR([$1], [0 0], [11],
|
|||||||
_AT_CHECK_CALC_ERROR([$1], [1//2], [15],
|
_AT_CHECK_CALC_ERROR([$1], [1//2], [15],
|
||||||
[1.3-1.4: parse error, unexpected '/', expecting "number" or '-' or '('])
|
[1.3-1.4: parse error, unexpected '/', expecting "number" or '-' or '('])
|
||||||
_AT_CHECK_CALC_ERROR([$1], [error], [4],
|
_AT_CHECK_CALC_ERROR([$1], [error], [4],
|
||||||
[1.1-1.2: parse error, unexpected $undefined., expecting "number" or '-' or '\n' or '('])
|
[1.1-1.2: parse error, unexpected $undefined, expecting "number" or '-' or '\n' or '('])
|
||||||
_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [22],
|
_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [22],
|
||||||
[1.7-1.8: parse error, unexpected '='])
|
[1.7-1.8: parse error, unexpected '='])
|
||||||
_AT_CHECK_CALC_ERROR([$1],
|
_AT_CHECK_CALC_ERROR([$1],
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ AT_CHECK([cat input.output], [],
|
|||||||
|
|
||||||
Grammar
|
Grammar
|
||||||
|
|
||||||
0 $axiom: exp $
|
0 $accept: exp $end
|
||||||
|
|
||||||
1 exp: exp OP exp
|
1 exp: exp OP exp
|
||||||
2 | NUM
|
2 | NUM
|
||||||
@@ -158,7 +158,7 @@ Grammar
|
|||||||
|
|
||||||
Terminals, with rules where they appear
|
Terminals, with rules where they appear
|
||||||
|
|
||||||
$ (0) 0
|
$end (0) 0
|
||||||
error (256)
|
error (256)
|
||||||
NUM (258) 2
|
NUM (258) 2
|
||||||
OP (259) 1
|
OP (259) 1
|
||||||
@@ -166,7 +166,7 @@ OP (259) 1
|
|||||||
|
|
||||||
Nonterminals, with rules where they appear
|
Nonterminals, with rules where they appear
|
||||||
|
|
||||||
$axiom (5)
|
$accept (5)
|
||||||
on left: 0
|
on left: 0
|
||||||
exp (6)
|
exp (6)
|
||||||
on left: 1 2, on right: 0 1
|
on left: 1 2, on right: 0 1
|
||||||
@@ -174,7 +174,7 @@ exp (6)
|
|||||||
|
|
||||||
state 0
|
state 0
|
||||||
|
|
||||||
0 $axiom: . exp $
|
0 $accept: . exp $end
|
||||||
1 exp: . exp OP exp
|
1 exp: . exp OP exp
|
||||||
2 | . NUM
|
2 | . NUM
|
||||||
|
|
||||||
@@ -192,16 +192,16 @@ state 1
|
|||||||
|
|
||||||
state 2
|
state 2
|
||||||
|
|
||||||
0 $axiom: exp . $
|
0 $accept: exp . $end
|
||||||
1 exp: exp . OP exp
|
1 exp: exp . OP exp
|
||||||
|
|
||||||
$ shift, and go to state 3
|
$end shift, and go to state 3
|
||||||
OP shift, and go to state 4
|
OP shift, and go to state 4
|
||||||
|
|
||||||
|
|
||||||
state 3
|
state 3
|
||||||
|
|
||||||
0 $axiom: exp $ .
|
0 $accept: exp $end .
|
||||||
|
|
||||||
$default accept
|
$default accept
|
||||||
|
|
||||||
@@ -219,8 +219,8 @@ state 4
|
|||||||
|
|
||||||
state 5
|
state 5
|
||||||
|
|
||||||
1 exp: exp . OP exp [$, OP]
|
1 exp: exp . OP exp [$end, OP]
|
||||||
1 | exp OP exp . [$, OP]
|
1 | exp OP exp . [$end, OP]
|
||||||
|
|
||||||
OP shift, and go to state 4
|
OP shift, and go to state 4
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ AT_CHECK([bison input.y -o input.c --report=all])
|
|||||||
AT_CHECK([cat input.output], [],
|
AT_CHECK([cat input.output], [],
|
||||||
[[Grammar
|
[[Grammar
|
||||||
|
|
||||||
0 $axiom: exp $
|
0 $accept: exp $end
|
||||||
|
|
||||||
1 exp: exp OP exp
|
1 exp: exp OP exp
|
||||||
2 | NUM
|
2 | NUM
|
||||||
@@ -261,7 +261,7 @@ AT_CHECK([cat input.output], [],
|
|||||||
|
|
||||||
Terminals, with rules where they appear
|
Terminals, with rules where they appear
|
||||||
|
|
||||||
$ (0) 0
|
$end (0) 0
|
||||||
error (256)
|
error (256)
|
||||||
NUM (258) 2
|
NUM (258) 2
|
||||||
OP (259) 1
|
OP (259) 1
|
||||||
@@ -269,7 +269,7 @@ OP (259) 1
|
|||||||
|
|
||||||
Nonterminals, with rules where they appear
|
Nonterminals, with rules where they appear
|
||||||
|
|
||||||
$axiom (5)
|
$accept (5)
|
||||||
on left: 0
|
on left: 0
|
||||||
exp (6)
|
exp (6)
|
||||||
on left: 1 2, on right: 0 1
|
on left: 1 2, on right: 0 1
|
||||||
@@ -277,7 +277,7 @@ exp (6)
|
|||||||
|
|
||||||
state 0
|
state 0
|
||||||
|
|
||||||
0 $axiom: . exp $
|
0 $accept: . exp $end
|
||||||
1 exp: . exp OP exp
|
1 exp: . exp OP exp
|
||||||
2 | . NUM
|
2 | . NUM
|
||||||
|
|
||||||
@@ -295,16 +295,16 @@ state 1
|
|||||||
|
|
||||||
state 2
|
state 2
|
||||||
|
|
||||||
0 $axiom: exp . $
|
0 $accept: exp . $end
|
||||||
1 exp: exp . OP exp
|
1 exp: exp . OP exp
|
||||||
|
|
||||||
$ shift, and go to state 3
|
$end shift, and go to state 3
|
||||||
OP shift, and go to state 4
|
OP shift, and go to state 4
|
||||||
|
|
||||||
|
|
||||||
state 3
|
state 3
|
||||||
|
|
||||||
0 $axiom: exp $ .
|
0 $accept: exp $end .
|
||||||
|
|
||||||
$default accept
|
$default accept
|
||||||
|
|
||||||
@@ -322,8 +322,8 @@ state 4
|
|||||||
|
|
||||||
state 5
|
state 5
|
||||||
|
|
||||||
1 exp: exp . OP exp [$, OP]
|
1 exp: exp . OP exp [$end, OP]
|
||||||
1 | exp OP exp . [$, OP]
|
1 | exp OP exp . [$end, OP]
|
||||||
|
|
||||||
$default reduce using rule 1 (exp)
|
$default reduce using rule 1 (exp)
|
||||||
Conflict between rule 1 and token OP resolved as reduce (%left OP).
|
Conflict between rule 1 and token OP resolved as reduce (%left OP).
|
||||||
@@ -339,19 +339,19 @@ AT_CLEANUP
|
|||||||
# When there are RR conflicts, some rules are disabled. Usually it is
|
# When there are RR conflicts, some rules are disabled. Usually it is
|
||||||
# simply displayed as:
|
# simply displayed as:
|
||||||
#
|
#
|
||||||
# $ reduce using rule 3 (num)
|
# $end reduce using rule 3 (num)
|
||||||
# $ [reduce using rule 4 (id)]
|
# $end [reduce using rule 4 (id)]
|
||||||
#
|
#
|
||||||
# But when `reduce 3' is the default action, we'd produce:
|
# But when `reduce 3' is the default action, we'd produce:
|
||||||
#
|
#
|
||||||
# $ [reduce using rule 4 (id)]
|
# $end [reduce using rule 4 (id)]
|
||||||
# $default reduce using rule 3 (num)
|
# $default reduce using rule 3 (num)
|
||||||
#
|
#
|
||||||
# In this precise case (a reduction is masked by the default
|
# In this precise case (a reduction is masked by the default
|
||||||
# reduction), we make the `reduce 3' explicit:
|
# reduction), we make the `reduce 3' explicit:
|
||||||
#
|
#
|
||||||
# $ reduce using rule 3 (num)
|
# $end reduce using rule 3 (num)
|
||||||
# $ [reduce using rule 4 (id)]
|
# $end [reduce using rule 4 (id)]
|
||||||
# $default reduce using rule 3 (num)
|
# $default reduce using rule 3 (num)
|
||||||
#
|
#
|
||||||
# Maybe that's not the best display, but then, please propose something
|
# Maybe that's not the best display, but then, please propose something
|
||||||
@@ -379,7 +379,7 @@ AT_CHECK([cat input.output], [],
|
|||||||
|
|
||||||
Grammar
|
Grammar
|
||||||
|
|
||||||
0 $axiom: exp $
|
0 $accept: exp $end
|
||||||
|
|
||||||
1 exp: num
|
1 exp: num
|
||||||
2 | id
|
2 | id
|
||||||
@@ -391,14 +391,14 @@ Grammar
|
|||||||
|
|
||||||
Terminals, with rules where they appear
|
Terminals, with rules where they appear
|
||||||
|
|
||||||
$ (0) 0
|
$end (0) 0
|
||||||
'0' (48) 3 4
|
'0' (48) 3 4
|
||||||
error (256)
|
error (256)
|
||||||
|
|
||||||
|
|
||||||
Nonterminals, with rules where they appear
|
Nonterminals, with rules where they appear
|
||||||
|
|
||||||
$axiom (4)
|
$accept (4)
|
||||||
on left: 0
|
on left: 0
|
||||||
exp (5)
|
exp (5)
|
||||||
on left: 1 2, on right: 0
|
on left: 1 2, on right: 0
|
||||||
@@ -410,7 +410,7 @@ id (7)
|
|||||||
|
|
||||||
state 0
|
state 0
|
||||||
|
|
||||||
0 $axiom: . exp $
|
0 $accept: . exp $end
|
||||||
1 exp: . num
|
1 exp: . num
|
||||||
2 | . id
|
2 | . id
|
||||||
3 num: . '0'
|
3 num: . '0'
|
||||||
@@ -425,19 +425,19 @@ state 0
|
|||||||
|
|
||||||
state 1
|
state 1
|
||||||
|
|
||||||
3 num: '0' . [$]
|
3 num: '0' . [$end]
|
||||||
4 id: '0' . [$]
|
4 id: '0' . [$end]
|
||||||
|
|
||||||
$ reduce using rule 3 (num)
|
$end reduce using rule 3 (num)
|
||||||
$ [reduce using rule 4 (id)]
|
$end [reduce using rule 4 (id)]
|
||||||
$default reduce using rule 3 (num)
|
$default reduce using rule 3 (num)
|
||||||
|
|
||||||
|
|
||||||
state 2
|
state 2
|
||||||
|
|
||||||
0 $axiom: exp . $
|
0 $accept: exp . $end
|
||||||
|
|
||||||
$ shift, and go to state 5
|
$end shift, and go to state 5
|
||||||
|
|
||||||
|
|
||||||
state 3
|
state 3
|
||||||
@@ -456,7 +456,7 @@ state 4
|
|||||||
|
|
||||||
state 5
|
state 5
|
||||||
|
|
||||||
0 $axiom: exp $ .
|
0 $accept: exp $end .
|
||||||
|
|
||||||
$default accept
|
$default accept
|
||||||
]])
|
]])
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ AT_CHECK([bison input.y -o input.c -v])
|
|||||||
AT_CHECK([cat input.output], [],
|
AT_CHECK([cat input.output], [],
|
||||||
[[Grammar
|
[[Grammar
|
||||||
|
|
||||||
0 $axiom: expr $
|
0 $accept: expr $end
|
||||||
|
|
||||||
1 @1: /* empty */
|
1 @1: /* empty */
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ AT_CHECK([cat input.output], [],
|
|||||||
|
|
||||||
Terminals, with rules where they appear
|
Terminals, with rules where they appear
|
||||||
|
|
||||||
$ (0) 0
|
$end (0) 0
|
||||||
'a' (97) 2
|
'a' (97) 2
|
||||||
'b' (98) 2
|
'b' (98) 2
|
||||||
'c' (99) 4
|
'c' (99) 4
|
||||||
@@ -172,7 +172,7 @@ error (256)
|
|||||||
|
|
||||||
Nonterminals, with rules where they appear
|
Nonterminals, with rules where they appear
|
||||||
|
|
||||||
$axiom (6)
|
$accept (6)
|
||||||
on left: 0
|
on left: 0
|
||||||
expr (7)
|
expr (7)
|
||||||
on left: 2 4, on right: 0
|
on left: 2 4, on right: 0
|
||||||
@@ -184,7 +184,7 @@ expr (7)
|
|||||||
|
|
||||||
state 0
|
state 0
|
||||||
|
|
||||||
0 $axiom: . expr $
|
0 $accept: . expr $end
|
||||||
|
|
||||||
'a' shift, and go to state 1
|
'a' shift, and go to state 1
|
||||||
|
|
||||||
@@ -205,9 +205,9 @@ state 1
|
|||||||
|
|
||||||
state 2
|
state 2
|
||||||
|
|
||||||
0 $axiom: expr . $
|
0 $accept: expr . $end
|
||||||
|
|
||||||
$ shift, and go to state 5
|
$end shift, and go to state 5
|
||||||
|
|
||||||
|
|
||||||
state 3
|
state 3
|
||||||
@@ -226,7 +226,7 @@ state 4
|
|||||||
|
|
||||||
state 5
|
state 5
|
||||||
|
|
||||||
0 $axiom: expr $ .
|
0 $accept: expr $end .
|
||||||
|
|
||||||
$default accept
|
$default accept
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ AT_CHECK([bison -v input.y])
|
|||||||
AT_CHECK([cat input.output], 0,
|
AT_CHECK([cat input.output], 0,
|
||||||
[[Grammar
|
[[Grammar
|
||||||
|
|
||||||
0 $axiom: CONST_DEC_PART $
|
0 $accept: CONST_DEC_PART $end
|
||||||
|
|
||||||
1 CONST_DEC_PART: CONST_DEC_LIST
|
1 CONST_DEC_PART: CONST_DEC_LIST
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ AT_CHECK([cat input.output], 0,
|
|||||||
|
|
||||||
Terminals, with rules where they appear
|
Terminals, with rules where they appear
|
||||||
|
|
||||||
$ (0) 0
|
$end (0) 0
|
||||||
';' (59) 5
|
';' (59) 5
|
||||||
'=' (61) 5
|
'=' (61) 5
|
||||||
error (256)
|
error (256)
|
||||||
@@ -395,7 +395,7 @@ const_id_tok (259) 5
|
|||||||
|
|
||||||
Nonterminals, with rules where they appear
|
Nonterminals, with rules where they appear
|
||||||
|
|
||||||
$axiom (7)
|
$accept (7)
|
||||||
on left: 0
|
on left: 0
|
||||||
CONST_DEC_PART (8)
|
CONST_DEC_PART (8)
|
||||||
on left: 1, on right: 0
|
on left: 1, on right: 0
|
||||||
@@ -409,7 +409,7 @@ CONST_DEC (10)
|
|||||||
|
|
||||||
state 0
|
state 0
|
||||||
|
|
||||||
0 $axiom: . CONST_DEC_PART $
|
0 $accept: . CONST_DEC_PART $end
|
||||||
|
|
||||||
$default reduce using rule 4 (@1)
|
$default reduce using rule 4 (@1)
|
||||||
|
|
||||||
@@ -421,9 +421,9 @@ state 0
|
|||||||
|
|
||||||
state 1
|
state 1
|
||||||
|
|
||||||
0 $axiom: CONST_DEC_PART . $
|
0 $accept: CONST_DEC_PART . $end
|
||||||
|
|
||||||
$ shift, and go to state 5
|
$end shift, and go to state 5
|
||||||
|
|
||||||
|
|
||||||
state 2
|
state 2
|
||||||
@@ -454,7 +454,7 @@ state 4
|
|||||||
|
|
||||||
state 5
|
state 5
|
||||||
|
|
||||||
0 $axiom: CONST_DEC_PART $ .
|
0 $accept: CONST_DEC_PART $end .
|
||||||
|
|
||||||
$default accept
|
$default accept
|
||||||
|
|
||||||
@@ -584,8 +584,8 @@ static const unsigned char yyrline[] =
|
|||||||
};
|
};
|
||||||
static const char *const yytname[] =
|
static const char *const yytname[] =
|
||||||
{
|
{
|
||||||
"$", "error", "$undefined.", "\"if\"", "\"const\"", "\"then\"",
|
"$end", "error", "$undefined", "\"if\"", "\"const\"", "\"then\"",
|
||||||
"\"else\"", "$axiom", "statement", "struct_stat", "if", "else", 0
|
"\"else\"", "$accept", "statement", "struct_stat", "if", "else", 0
|
||||||
};
|
};
|
||||||
static const unsigned short yytoknum[] =
|
static const unsigned short yytoknum[] =
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,23 +82,23 @@ AT_CHECK([[bison --trace input.y]], [], [], [stderr])
|
|||||||
AT_EXTRACT_SETS([stderr], [sets])
|
AT_EXTRACT_SETS([stderr], [sets])
|
||||||
AT_CHECK([[cat sets]], [],
|
AT_CHECK([[cat sets]], [],
|
||||||
[[DERIVES
|
[[DERIVES
|
||||||
$axiom derives
|
$accept derives
|
||||||
0 e $
|
0 e $end
|
||||||
e derives
|
e derives
|
||||||
1 'e'
|
1 'e'
|
||||||
2 /* empty */
|
2 /* empty */
|
||||||
NULLABLE
|
NULLABLE
|
||||||
$axiom: no
|
$accept: no
|
||||||
e: yes
|
e: yes
|
||||||
FIRSTS
|
FIRSTS
|
||||||
$axiom firsts
|
$accept firsts
|
||||||
$axiom
|
$accept
|
||||||
e
|
e
|
||||||
e firsts
|
e firsts
|
||||||
e
|
e
|
||||||
FDERIVES
|
FDERIVES
|
||||||
$axiom derives
|
$accept derives
|
||||||
0 e $
|
0 e $end
|
||||||
1 'e'
|
1 'e'
|
||||||
2 /* empty */
|
2 /* empty */
|
||||||
e derives
|
e derives
|
||||||
@@ -212,8 +212,8 @@ AT_CHECK([[bison --trace input.y]], [], [], [stderr])
|
|||||||
AT_EXTRACT_SETS([stderr], [sets])
|
AT_EXTRACT_SETS([stderr], [sets])
|
||||||
AT_CHECK([[cat sets]], [],
|
AT_CHECK([[cat sets]], [],
|
||||||
[[DERIVES
|
[[DERIVES
|
||||||
$axiom derives
|
$accept derives
|
||||||
0 exp $
|
0 exp $end
|
||||||
exp derives
|
exp derives
|
||||||
1 exp '<' exp
|
1 exp '<' exp
|
||||||
2 exp '>' exp
|
2 exp '>' exp
|
||||||
@@ -223,17 +223,17 @@ AT_CHECK([[cat sets]], [],
|
|||||||
6 exp '=' exp
|
6 exp '=' exp
|
||||||
7 "exp"
|
7 "exp"
|
||||||
NULLABLE
|
NULLABLE
|
||||||
$axiom: no
|
$accept: no
|
||||||
exp: no
|
exp: no
|
||||||
FIRSTS
|
FIRSTS
|
||||||
$axiom firsts
|
$accept firsts
|
||||||
$axiom
|
$accept
|
||||||
exp
|
exp
|
||||||
exp firsts
|
exp firsts
|
||||||
exp
|
exp
|
||||||
FDERIVES
|
FDERIVES
|
||||||
$axiom derives
|
$accept derives
|
||||||
0 exp $
|
0 exp $end
|
||||||
1 exp '<' exp
|
1 exp '<' exp
|
||||||
2 exp '>' exp
|
2 exp '>' exp
|
||||||
3 exp '+' exp
|
3 exp '+' exp
|
||||||
|
|||||||
Reference in New Issue
Block a user