diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-04-27 16:41:07 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-04-27 18:27:04 +0200 |
commit | 7ea108fa6749d3e3dc688c1499fbabf636de1e84 (patch) | |
tree | f0c9b972f8635c3bb104b8ac77aba75125a38d9e /src | |
parent | 386cf2508891ebd2338b83b084bfabe469f510a9 (diff) | |
download | bison-7ea108fa6749d3e3dc688c1499fbabf636de1e84.tar.gz |
traces: use colors for the semantic values
This makes reading the trace slightly easier. It would be very nice
to highlight the "big steps", especially reductions. But this is a
private experiment: do not use it.
* data/diagnostics.css (value): New.
* src/parse-gram.y: Use no delimiters and no c quotation for strings
to facilitate debugging.
(tron, troff, TRACE): New.
Not very elegant, but until there is support for printf-formats in
libtextstyle, it shall be enough.
Diffstat (limited to 'src')
-rw-r--r-- | src/parse-gram.y | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/parse-gram.y b/src/parse-gram.y index 1c2199dc..263db619 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -112,6 +112,10 @@ #define YYTYPE_INT8 int_fast8_t #define YYTYPE_UINT16 uint_fast16_t #define YYTYPE_UINT8 uint_fast8_t + + /* Add style to semantic values in traces. */ + static void tron (FILE *yyo); + static void troff (FILE *yyo); } %define api.header.include {"parse-gram.h"} @@ -202,12 +206,15 @@ %token TAG_ANY "<*>" %token TAG_NONE "<>" + /* Experimental feature, don't rely on it. */ +%code pre-printer {tron (yyo);} +%code post-printer {troff (yyo);} + %type <unsigned char> CHAR %printer { fputs (char_name ($$), yyo); } <unsigned char> %type <char*> "{...}" "%?{...}" "%{...%}" EPILOGUE STRING -%printer { fputs (quotearg_style (c_quoting_style, $$), yyo); } STRING -%printer { fprintf (yyo, "{\n%s\n}", $$); } <char*> +%printer { fputs ($$, yyo); } <char*> %type <uniqstr> BRACKETED_ID ID ID_COLON @@ -1054,3 +1061,13 @@ current_lhs (symbol *sym, location loc, named_ref *ref) free (current_lhs_named_ref); current_lhs_named_ref = ref; } + +static void tron (FILE *yyo) +{ + begin_use_class ("value", yyo); +} + +static void troff (FILE *yyo) +{ + end_use_class ("value", yyo); +} |