From 4182de297578df9c6e9ecc7f71aacd6233268d55 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 26 Aug 2016 17:40:22 -0700 Subject: [PATCH] Include each symbol's numeric value in generated code Sometimes these are useful for debugging --- src/compiler/generate_code/c_code.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/compiler/generate_code/c_code.cc b/src/compiler/generate_code/c_code.cc index f747332e..f0cfa129 100644 --- a/src/compiler/generate_code/c_code.cc +++ b/src/compiler/generate_code/c_code.cc @@ -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++; } } });