From b733b0cc8103cf6d97d6118f94169a59e8b19d34 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 2 Mar 2016 20:52:18 -0800 Subject: [PATCH] Remove duplicate parse actions This has only come up for out-of-context states, but it seems possible now that there could be duplicate actions for any state, because of the possibility of multiple actions with different precedence or associativity that are otherwise the same --- src/compiler/build_tables/build_parse_table.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/compiler/build_tables/build_parse_table.cc b/src/compiler/build_tables/build_parse_table.cc index e96df059..5190c50d 100644 --- a/src/compiler/build_tables/build_parse_table.cc +++ b/src/compiler/build_tables/build_parse_table.cc @@ -230,6 +230,19 @@ class ParseTableBuilder { action.associativity = rules::AssociativityNone; } } + + for (auto i = entry.second.begin(); i != entry.second.end();) { + bool erased = false; + for (auto j = entry.second.begin(); j != i; j++) { + if (*j == *i) { + entry.second.erase(i); + erased = true; + break; + } + } + if (!erased) + ++i; + } } if (!symbols_with_multiple_actions.empty()) {