Include each symbol's numeric value in generated code

Sometimes these are useful for debugging
This commit is contained in:
Max Brunsfeld 2016-08-26 17:40:22 -07:00
parent fbad21be15
commit 4182de2975

View file

@ -121,15 +121,12 @@ class CCodeGenerator {
void add_symbol_enum() {
line("enum {");
indent([&]() {
bool at_start = true;
size_t i = 1;
for (const auto &entry : parse_table.symbols) {
const rules::Symbol &symbol = entry.first;
if (!symbol.is_built_in()) {
if (at_start)
line(symbol_id(symbol) + " = ts_builtin_sym_start,");
else
line(symbol_id(symbol) + ",");
at_start = false;
line(symbol_id(symbol) + " = " + to_string(i) + ",");
i++;
}
}
});