diff options
Diffstat (limited to 'src/generator_lr0.cpp')
-rw-r--r-- | src/generator_lr0.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/generator_lr0.cpp b/src/generator_lr0.cpp index cbf051c..024f5fa 100644 --- a/src/generator_lr0.cpp +++ b/src/generator_lr0.cpp @@ -25,3 +25,25 @@ #include "generator_lr0.hpp" + + +namespace solar { + +bool generator_lr0_t::has_reduce_conflict(size_t from, const symbol_t &sym) { + (void)sym; + return reductions.count(from); +} + +void generator_lr0_t::add_reduction(size_t from, size_t to) { + if (reductions.count(from)) + throw conflict_error("reduce/reduce conflict"); + + for (const symbol_t &sym : get_terminals()) { + if (get_shifts().count(std::make_pair(from, sym))) + throw conflict_error("shift/reduce conflict"); + } + + reductions.insert(std::make_pair(from, to)); +} + +} |