mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
Copy BYacc's nice way to report the grammar.
* src/gram.h, src/gram.c (grammar_rhs_print, grammar_rules_print): New. Don't print the rules' location, it is confusing and useless. (rule_print): Use grammar_rhs_print. * src/print.c (print_grammar): Use grammar_rules_print.
This commit is contained in:
36
src/symtab.c
36
src/symtab.c
@@ -20,6 +20,7 @@
|
||||
|
||||
|
||||
#include "system.h"
|
||||
#include "quotearg.h"
|
||||
#include "hash.h"
|
||||
#include "complain.h"
|
||||
#include "symtab.h"
|
||||
@@ -60,6 +61,41 @@ symbol_new (const char *tag, location_t location)
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------.
|
||||
| Return the tag of this SYMBOL in a printable form. Warning: use |
|
||||
| the first QUOTEARG slot: 0. |
|
||||
`-----------------------------------------------------------------*/
|
||||
|
||||
const char *
|
||||
symbol_tag_get (symbol_t *symbol)
|
||||
{
|
||||
return quotearg_style (escape_quoting_style, symbol->tag);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------.
|
||||
| Return the tag of this SYMBOL in a printable form. Use the |
|
||||
| QUOTEARG slot number N. |
|
||||
`------------------------------------------------------------*/
|
||||
|
||||
const char *
|
||||
symbol_tag_get_n (symbol_t *symbol, int n)
|
||||
{
|
||||
return quotearg_n_style (n, escape_quoting_style, symbol->tag);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------.
|
||||
| Print the tag of this SYMBOL. |
|
||||
`-------------------------------*/
|
||||
|
||||
void
|
||||
symbol_tag_print (symbol_t *symbol, FILE *out)
|
||||
{
|
||||
fputs (symbol_tag_get (symbol), out);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| Set the TYPE_NAME associated to SYMBOL. Does nothing if passed 0 |
|
||||
| as TYPE_NAME. |
|
||||
|
||||
Reference in New Issue
Block a user