diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2020-08-05 07:56:14 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2020-08-07 07:30:06 +0200 |
commit | 6aae4a7378a3a2faece927d6fad1cf165827edfe (patch) | |
tree | 8de6df5d934b62e86aebe56104f89d5ee493fce9 | |
parent | 7d4a4300c2af867926b5420e2f62c1f3c342647d (diff) | |
download | bison-6aae4a7378a3a2faece927d6fad1cf165827edfe.tar.gz |
style: fix comments and more debug trace
* src/location.c, src/symtab.h, src/symtab.c: here.
-rw-r--r-- | src/location.c | 4 | ||||
-rw-r--r-- | src/parse-gram.c | 3 | ||||
-rw-r--r-- | src/parse-gram.y | 3 | ||||
-rw-r--r-- | src/symtab.c | 20 | ||||
-rw-r--r-- | src/symtab.h | 2 |
5 files changed, 20 insertions, 12 deletions
diff --git a/src/location.c b/src/location.c index 1c0aa1fd..418a728d 100644 --- a/src/location.c +++ b/src/location.c @@ -155,7 +155,9 @@ int location_print (location loc, FILE *out) { int res = 0; - if (trace_flag & trace_locations) + if (location_empty (loc)) + res += fprintf (out, "(empty location)"); + else if (trace_flag & trace_locations) { res += boundary_print (&loc.start, out); res += fprintf (out, "-"); diff --git a/src/parse-gram.c b/src/parse-gram.c index fae69b50..d8eb81cc 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -3147,8 +3147,7 @@ char_name (char c) } } -static -void +static void current_lhs (symbol *sym, location loc, named_ref *ref) { current_lhs_symbol = sym; diff --git a/src/parse-gram.y b/src/parse-gram.y index cd706263..925e0773 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -1158,8 +1158,7 @@ char_name (char c) } } -static -void +static void current_lhs (symbol *sym, location loc, named_ref *ref) { current_lhs_symbol = sym; diff --git a/src/symtab.c b/src/symtab.c index 678f4def..6c416b0b 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -243,7 +243,11 @@ semantic_type_new (uniqstr tag, const location *loc) | Print a symbol. | `-----------------*/ -#define SYMBOL_ATTR_PRINT(Attr) \ +#define SYMBOL_INT_ATTR_PRINT(Attr) \ + if (s->content) \ + fprintf (f, " %s = %d", #Attr, s->content->Attr) + +#define SYMBOL_STR_ATTR_PRINT(Attr) \ if (s->content && s->content->Attr) \ fprintf (f, " %s { %s }", #Attr, s->content->Attr) @@ -264,7 +268,11 @@ symbol_print (symbol const *s, FILE *f) : c == nterm_sym ? "nterm" : NULL, /* abort. */ s->tag); - SYMBOL_ATTR_PRINT (type_name); + putc (' ', f); + location_print (s->location, f); + SYMBOL_INT_ATTR_PRINT (code); + SYMBOL_INT_ATTR_PRINT (number); + SYMBOL_STR_ATTR_PRINT (type_name); SYMBOL_CODE_PRINT (destructor); SYMBOL_CODE_PRINT (printer); } @@ -573,9 +581,9 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring) } -/*------------------------------------------------. -| Set the USER_TOKEN_NUMBER associated with SYM. | -`------------------------------------------------*/ +/*----------------------------. +| Set the token code of SYM. | +`----------------------------*/ void symbol_code_set (symbol *sym, int code, location loc) @@ -1000,7 +1008,7 @@ symbol_cmp (void const *a, void const *b) } /* Store in *SORTED an array of pointers to the symbols contained in - TABLE, sorted (alphabetically) by tag. */ + TABLE, sorted by order of appearance (i.e., by location). */ static void table_sort (struct hash_table *table, symbol ***sorted) diff --git a/src/symtab.h b/src/symtab.h index 7bfd310c..e85e5468 100644 --- a/src/symtab.h +++ b/src/symtab.h @@ -227,7 +227,7 @@ void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc); void symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring); -/** Set the \c code associated with \c sym. */ +/** Set the token \c code of \c sym, specified by the user at \c loc. */ void symbol_code_set (symbol *sym, int code, location loc); |