mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 15:23:02 +00:00
style: factor complex expressions
* src/print-xml.c, src/print.c: Introduce a variable pointing to the current symbol.
This commit is contained in:
@@ -382,9 +382,10 @@ print_grammar (FILE *out, int level)
|
|||||||
for (int i = 0; i < max_code + 1; i++)
|
for (int i = 0; i < max_code + 1; i++)
|
||||||
if (token_translations[i] != undeftoken->content->number)
|
if (token_translations[i] != undeftoken->content->number)
|
||||||
{
|
{
|
||||||
char const *tag = symbols[token_translations[i]]->tag;
|
symbol const *sym = symbols[token_translations[i]];
|
||||||
int precedence = symbols[token_translations[i]]->content->prec;
|
char const *tag = sym->tag;
|
||||||
assoc associativity = symbols[token_translations[i]]->content->assoc;
|
int precedence = sym->content->prec;
|
||||||
|
assoc associativity = sym->content->assoc;
|
||||||
xml_indent (out, level + 2);
|
xml_indent (out, level + 2);
|
||||||
fprintf (out,
|
fprintf (out,
|
||||||
"<terminal symbol-number=\"%d\" token-number=\"%d\""
|
"<terminal symbol-number=\"%d\" token-number=\"%d\""
|
||||||
@@ -404,7 +405,8 @@ print_grammar (FILE *out, int level)
|
|||||||
xml_puts (out, level + 1, "<nonterminals>");
|
xml_puts (out, level + 1, "<nonterminals>");
|
||||||
for (symbol_number i = ntokens; i < nsyms + nuseless_nonterminals; i++)
|
for (symbol_number i = ntokens; i < nsyms + nuseless_nonterminals; i++)
|
||||||
{
|
{
|
||||||
char const *tag = symbols[i]->tag;
|
symbol const *sym = symbols[i];
|
||||||
|
char const *tag = sym->tag;
|
||||||
xml_printf (out, level + 2,
|
xml_printf (out, level + 2,
|
||||||
"<nonterminal symbol-number=\"%d\" name=\"%s\""
|
"<nonterminal symbol-number=\"%d\" name=\"%s\""
|
||||||
" usefulness=\"%s\"/>",
|
" usefulness=\"%s\"/>",
|
||||||
|
|||||||
15
src/print.c
15
src/print.c
@@ -377,11 +377,11 @@ print_terminal_symbols (FILE *out)
|
|||||||
for (int i = 0; i < max_code + 1; ++i)
|
for (int i = 0; i < max_code + 1; ++i)
|
||||||
if (token_translations[i] != undeftoken->content->number)
|
if (token_translations[i] != undeftoken->content->number)
|
||||||
{
|
{
|
||||||
const char *tag = symbols[token_translations[i]]->tag;
|
const symbol *sym = symbols[token_translations[i]];
|
||||||
|
const char *tag = sym->tag;
|
||||||
fprintf (out, "%4s%s", "", tag);
|
fprintf (out, "%4s%s", "", tag);
|
||||||
if (symbols[token_translations[i]]->content->type_name)
|
if (sym->content->type_name)
|
||||||
fprintf (out, " <%s>",
|
fprintf (out, " <%s>", sym->content->type_name);
|
||||||
symbols[token_translations[i]]->content->type_name);
|
|
||||||
fprintf (out, " (%d)", i);
|
fprintf (out, " (%d)", i);
|
||||||
|
|
||||||
for (rule_number r = 0; r < nrules; r++)
|
for (rule_number r = 0; r < nrules; r++)
|
||||||
@@ -403,7 +403,8 @@ print_nonterminal_symbols (FILE *out)
|
|||||||
fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear"));
|
fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear"));
|
||||||
for (symbol_number i = ntokens; i < nsyms; i++)
|
for (symbol_number i = ntokens; i < nsyms; i++)
|
||||||
{
|
{
|
||||||
const char *tag = symbols[i]->tag;
|
const symbol *sym = symbols[i];
|
||||||
|
const char *tag = sym->tag;
|
||||||
bool on_left = false;
|
bool on_left = false;
|
||||||
bool on_right = false;
|
bool on_right = false;
|
||||||
|
|
||||||
@@ -418,9 +419,9 @@ print_nonterminal_symbols (FILE *out)
|
|||||||
|
|
||||||
int column = 4 + mbswidth (tag, 0);
|
int column = 4 + mbswidth (tag, 0);
|
||||||
fprintf (out, "%4s%s", "", tag);
|
fprintf (out, "%4s%s", "", tag);
|
||||||
if (symbols[i]->content->type_name)
|
if (sym->content->type_name)
|
||||||
column += fprintf (out, " <%s>",
|
column += fprintf (out, " <%s>",
|
||||||
symbols[i]->content->type_name);
|
sym->content->type_name);
|
||||||
fprintf (out, " (%d)\n", i);
|
fprintf (out, " (%d)\n", i);
|
||||||
|
|
||||||
if (on_left)
|
if (on_left)
|
||||||
|
|||||||
Reference in New Issue
Block a user