style: rename endtoken as eoftoken

* src/symtab.h, src/symtab.c (endtoken): Rename as...
(eoftoken): this.
Adjust dependencies.
This commit is contained in:
Akim Demaille
2020-06-27 17:30:27 +02:00
parent d796e11f8f
commit feb0bb0a59
6 changed files with 21 additions and 29 deletions

8
TODO
View File

@@ -73,14 +73,6 @@ enough.
*** calc.at
Stop hard-coding "Calc". Adjust local.at (look for FIXME).
** Clean up
Rename endtoken as eoftoken.
Also do it in data/skeletons.
Don't rename in Bison 3.6 (it would be logical to do so) because that
would probably create many conflicts in Vincent's work (see previous point).
** A dev warning for b4_
Maybe we should check for m4_ and b4_ leaking out of the m4 processing, as
Autoconf does. It would have caught overquotation issues.

View File

@@ -198,9 +198,9 @@ static const char *
symbol_tag (const symbol *sym)
{
const bool eof_is_user_defined
= !endtoken->alias || STRNEQ (endtoken->alias->tag, "$end");
= !eoftoken->alias || STRNEQ (eoftoken->alias->tag, "$end");
if (!eof_is_user_defined && sym->content == endtoken->content)
if (!eof_is_user_defined && sym->content == eoftoken->content)
return "\"end of file\"";
else if (sym->content == undeftoken->content)
return "\"invalid token\"";

View File

@@ -776,18 +776,18 @@ check_and_convert_grammar (void)
if (nrules == 0)
complain (NULL, fatal, _("no rules in the input grammar"));
/* If the user did not define her ENDTOKEN, do it now. */
if (!endtoken)
/* If the user did not define her EOFTOKEN, do it now. */
if (!eoftoken)
{
endtoken = symbol_get ("YYEOF", empty_loc);
endtoken->content->class = token_sym;
endtoken->content->number = 0;
eoftoken = symbol_get ("YYEOF", empty_loc);
eoftoken->content->class = token_sym;
eoftoken->content->number = 0;
/* Value specified by POSIX. */
endtoken->content->code = 0;
eoftoken->content->code = 0;
{
symbol *alias = symbol_get ("$end", empty_loc);
symbol_class_set (alias, token_sym, empty_loc, false);
symbol_make_alias (endtoken, alias, empty_loc);
symbol_make_alias (eoftoken, alias, empty_loc);
}
}
@@ -809,7 +809,7 @@ check_and_convert_grammar (void)
symbol_list *p = symbol_list_sym_new (accept, empty_loc);
p->rhs_loc = grammar->rhs_loc;
p->next = symbol_list_sym_new (startsymbol, empty_loc);
p->next->next = symbol_list_sym_new (endtoken, empty_loc);
p->next->next = symbol_list_sym_new (eoftoken, empty_loc);
p->next->next->next = symbol_list_sym_new (NULL, empty_loc);
p->next->next->next->next = grammar;
nrules += 1;

View File

@@ -188,7 +188,7 @@ inaccessable_symbols (void)
/* These tokens (numbered 0, 1, and 2) are internal to Bison.
Consider them useful. */
bitset_set (V, endtoken->content->number); /* end-of-input token */
bitset_set (V, eoftoken->content->number); /* end-of-input token */
bitset_set (V, errtoken->content->number); /* error token */
bitset_set (V, undeftoken->content->number); /* some undefined token */

View File

@@ -58,7 +58,7 @@ static semantic_type **semantic_types_sorted = NULL;
symbol *errtoken = NULL;
symbol *undeftoken = NULL;
symbol *endtoken = NULL;
symbol *eoftoken = NULL;
symbol *accept = NULL;
symbol *startsymbol = NULL;
location startsymbol_loc;
@@ -78,9 +78,9 @@ static bool
symbol_is_user_defined (symbol *sym)
{
const bool eof_is_user_defined
= !endtoken->alias || STRNEQ (endtoken->alias->tag, "$end");
= !eoftoken->alias || STRNEQ (eoftoken->alias->tag, "$end");
return sym->tag[0] != '$'
&& (eof_is_user_defined || (sym != endtoken && sym->alias != errtoken))
&& (eof_is_user_defined || (sym != eoftoken && sym->alias != errtoken))
&& sym != errtoken && sym->alias != errtoken
&& sym != undeftoken && sym->alias != undeftoken;
}
@@ -595,14 +595,14 @@ symbol_code_set (symbol *sym, int code, location loc)
{
*codep = code;
/* User defined $end token? */
if (code == 0 && !endtoken)
if (code == 0 && !eoftoken)
{
endtoken = sym->content->symbol;
eoftoken = sym->content->symbol;
/* It is always mapped to 0, so it was already counted in
NTOKENS. */
if (endtoken->content->number != NUMBER_UNDEFINED)
if (eoftoken->content->number != NUMBER_UNDEFINED)
--ntokens;
endtoken->content->number = 0;
eoftoken->content->number = 0;
}
}
}
@@ -1163,9 +1163,9 @@ symbols_pack (void)
if (has_translations ())
{
const bool eof_is_user_defined
= !endtoken->alias || STRNEQ (endtoken->alias->tag, "$end");
= !eoftoken->alias || STRNEQ (eoftoken->alias->tag, "$end");
if (!eof_is_user_defined)
endtoken->alias->translatable = true;
eoftoken->alias->translatable = true;
undeftoken->alias->translatable = true;
errtoken->alias->translatable = true;
}

View File

@@ -241,7 +241,7 @@ extern symbol *errtoken;
/** The token for unknown tokens. */
extern symbol *undeftoken;
/** The end of input token. */
extern symbol *endtoken;
extern symbol *eoftoken;
/** The genuine start symbol.
$accept: start-symbol $end */