From 8c01b70ce75af86644246c21875e13a2430e25d0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sat, 13 Feb 2016 14:01:42 -0800 Subject: [PATCH] Don't skip tokens that are not the start of any non-terminal --- .../build_tables/symbols_by_first_symbol_spec.cc | 10 ++++++++++ src/compiler/build_tables/symbols_by_first_symbol.cc | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/spec/compiler/build_tables/symbols_by_first_symbol_spec.cc b/spec/compiler/build_tables/symbols_by_first_symbol_spec.cc index 19508063..b0059212 100644 --- a/spec/compiler/build_tables/symbols_by_first_symbol_spec.cc +++ b/spec/compiler/build_tables/symbols_by_first_symbol_spec.cc @@ -61,6 +61,11 @@ describe("symbols_by_first_symbol", [&]() { Symbol(2), } }, + { + Symbol(12, true), { + Symbol(12, true), + } + }, { Symbol(13, true), { Symbol(13, true), @@ -69,6 +74,11 @@ describe("symbols_by_first_symbol", [&]() { Symbol(2), } }, + { + Symbol(14, true), { + Symbol(14, true), + } + }, { Symbol(15, true), { Symbol(15, true), diff --git a/src/compiler/build_tables/symbols_by_first_symbol.cc b/src/compiler/build_tables/symbols_by_first_symbol.cc index f1da78b4..3c2a7c56 100644 --- a/src/compiler/build_tables/symbols_by_first_symbol.cc +++ b/src/compiler/build_tables/symbols_by_first_symbol.cc @@ -21,7 +21,10 @@ map> symbols_by_first_symbol(const SyntaxGrammar &grammar) { if (!production.empty()) { Symbol first_symbol = production[0].symbol; result[first_symbol].insert(symbol); - result[first_symbol].insert(first_symbol); + + for (const ProductionStep &step : production) { + result[step.symbol].insert(step.symbol); + } } }