summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/generator_slr.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/generator_slr.cpp b/src/generator_slr.cpp
index a8e081a..2989ee1 100644
--- a/src/generator_slr.cpp
+++ b/src/generator_slr.cpp
@@ -92,31 +92,31 @@ void generator_slr_t::generate_follow_sets() {
const std::set<symbol_t> &lhs = follow_sets[item.get_lhs()];
std::set<symbol_t> &rhs = follow_sets[sym.get_value()];
+ bool has_empty = true;
item_t next = item;
- next.shift();
- bool next_empty = false;
+ while (has_empty) {
+ has_empty = false;
+ next.shift();
- if (next.has_next()) {
- const symbol_t &next_sym = next.get_next_symbol();
+ if (next.has_next()) {
+ const symbol_t &next_sym = next.get_next_symbol();
- if (next_sym.get_type() == SYMBOL_TYPE_NONTERM) {
- for (const symbol_t &sym2 : first_sets[next_sym.get_value()]) {
- if (sym2 == symbol_t::empty())
- next_empty = true;
- else
- changed = changed || rhs.insert(sym2).second;
+ if (next_sym.get_type() == SYMBOL_TYPE_NONTERM) {
+ for (const symbol_t &sym2 : first_sets[next_sym.get_value()]) {
+ if (sym2 == symbol_t::empty())
+ has_empty = true;
+ else
+ changed = changed || rhs.insert(sym2).second;
+ }
}
+ else {
+ changed = changed || rhs.insert(next_sym).second;
+ }
+
+ continue;
}
- else {
- changed = changed || rhs.insert(next_sym).second;
- }
- }
- else {
- next_empty = true;
- }
- if (next_empty) {
for (const symbol_t &sym2 : lhs)
changed = changed || rhs.insert(sym2).second;
}