From 12c75e35cd39d888c615d8814001b0c6bfc207d1 Mon Sep 17 00:00:00 2001 From: Little_Rubyist Date: Fri, 20 Dec 2024 18:42:29 +0900 Subject: [PATCH] Fix Ruby::UnannotatedEmptyCollection error --- lib/lrama/counterexamples.rb | 10 +++++----- lib/lrama/counterexamples/derivation.rb | 2 +- lib/lrama/counterexamples/example.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/lrama/counterexamples.rb b/lib/lrama/counterexamples.rb index 11076478..ee2b5d59 100644 --- a/lib/lrama/counterexamples.rb +++ b/lib/lrama/counterexamples.rb @@ -50,7 +50,7 @@ def setup_transitions @reverse_transitions = {} @states.states.each do |src_state| - trans = {} + trans = {} #: Hash[Grammar::Symbol, State] src_state.transitions.each do |shift, next_state| trans[shift.next_sym] = next_state @@ -85,7 +85,7 @@ def setup_productions @states.states.each do |state| # LHS => Set(Item) - h = {} + h = {} #: Hash[Grammar::Symbol, Set[States::Item]] state.closure.each do |item| sym = item.lhs @@ -165,7 +165,7 @@ def find_shift_conflict_shortest_state_items(reduce_path, conflict_state, confli end if target_state_item.item.beginning_of_rule? - queue = [] + queue = [] #: Array[Array[StateItem]] queue << [target_state_item] # Find reverse production @@ -234,8 +234,8 @@ def build_paths_from_state_items(state_items) def shortest_path(conflict_state, conflict_reduce_item, conflict_term) # queue: is an array of [Triple, [Path]] - queue = [] - visited = {} + queue = [] #: Array[[Triple, Array[StartPath|TransitionPath|ProductionPath]]] + visited = {} #: Hash[Triple, true] start_state = @states.states.first #: Lrama::State raise "BUG: Start state should be just one kernel." if start_state.kernels.count != 1 diff --git a/lib/lrama/counterexamples/derivation.rb b/lib/lrama/counterexamples/derivation.rb index 436b2b79..368d7f10 100644 --- a/lib/lrama/counterexamples/derivation.rb +++ b/lib/lrama/counterexamples/derivation.rb @@ -18,7 +18,7 @@ def to_s alias :inspect :to_s def render_strings_for_report - result = [] + result = [] #: Array[String] _render_for_report(self, 0, result, 0) result.map(&:rstrip) end diff --git a/lib/lrama/counterexamples/example.rb b/lib/lrama/counterexamples/example.rb index d4840fd5..01995abe 100644 --- a/lib/lrama/counterexamples/example.rb +++ b/lib/lrama/counterexamples/example.rb @@ -92,7 +92,7 @@ def _derivations(paths) end def find_derivation_for_symbol(state_item, sym) - queue = [] + queue = [] #: Array[Array[StateItem]] queue << [state_item] while (sis = queue.shift)