lib/lrama/counterexamples/example.rb in lrama-0.6.10 vs lib/lrama/counterexamples/example.rb in lrama-0.6.11

- old
+ new

@@ -36,13 +36,14 @@ end private def _derivations(paths) - derivation = nil + derivation = nil #: Derivation current = :production - lookahead_sym = paths.last.to.item.end_of_rule? ? @conflict_symbol : nil + last_path = paths.last #: Path + lookahead_sym = last_path.to.item.end_of_rule? ? @conflict_symbol : nil paths.reverse_each do |path| item = path.to.item case current @@ -55,16 +56,18 @@ derivation = Derivation.new(item, derivation) current = :transition when ProductionPath derivation = Derivation.new(item, derivation) current = :production + else + raise "Unexpected. #{path}" end if lookahead_sym && item.next_next_sym && item.next_next_sym.first_set.include?(lookahead_sym) state_item = @counterexamples.transitions[[path.to, item.next_sym]] derivation2 = find_derivation_for_symbol(state_item, lookahead_sym) - derivation.right = derivation2 + derivation.right = derivation2 # steep:ignore lookahead_sym = nil end when :transition case path @@ -87,10 +90,10 @@ derivation end def find_derivation_for_symbol(state_item, sym) - queue = [] + queue = [] #: Array[Array[StateItem]] queue << [state_item] while (sis = queue.shift) si = sis.last next_sym = si.item.next_sym