diff --git a/lib/lrama/grammar/symbol.rb b/lib/lrama/grammar/symbol.rb index cb230b42..f9dffcad 100644 --- a/lib/lrama/grammar/symbol.rb +++ b/lib/lrama/grammar/symbol.rb @@ -100,10 +100,6 @@ def comment alias_name || id.s_value end end - - def inspect - id.s_value - end end end end diff --git a/lib/lrama/state.rb b/lib/lrama/state.rb index 5d2b4382..a14de3eb 100644 --- a/lib/lrama/state.rb +++ b/lib/lrama/state.rb @@ -5,7 +5,6 @@ require_relative "state/resolved_conflict" require_relative "state/shift" require_relative "state/shift_reduce_conflict" -require_relative "state/inadequacy_annotation" module Lrama class State @@ -159,10 +158,6 @@ def rr_conflicts end end - def inspect - "#{id} -> #{@kernels.map(&:to_s).join(', ')}" - end - def propagate_lookaheads(next_state) next_state.kernels.to_h {|item| lookahead_sets = @@ -172,7 +167,6 @@ def propagate_lookaheads(next_state) kernel = kernels.find {|k| k.predecessor_item_of?(item) } item_lookahead_set[kernel] end - # pp next_state.lookahead_set_filters[item] [item, lookahead_sets & next_state.lookahead_set_filters[item]] } @@ -193,7 +187,6 @@ def compatible_lookahead?(filtered_lookahead) def lookahead_set_filters kernels.to_h {|kernel| - # pp @lalr_isocore.annotation_list.transform_keys(&:inspect) [kernel, @lalr_isocore.annotation_list.filter_map {|token, actions| filter = token.term? && actions.any? {|action, contributions| @@ -239,7 +232,6 @@ def inadequacy_list def annotation_list manifestations = annotate_manifestation predecessors = transitions.map {|_, next_state| next_state.annotate_predecessor(self) } - # pp self, manifestations, predecessors predecessors.reduce(manifestations) {|result, annotations| result.merge(annotations) {|_, actions_a, actions_b| if actions_a.nil? || actions_b.nil? @@ -330,7 +322,6 @@ def item_lookahead_set shift, next_state = prev_state.nterm_transitions.find {|shift, _| shift.next_sym == item.lhs } prev_state.goto_follows(shift, next_state) end - # pp self, item.inspect, value.inspect [item, value] } end diff --git a/lib/lrama/state/inadequacy_annotation.rb b/lib/lrama/state/inadequacy_annotation.rb deleted file mode 100644 index 7a1f518d..00000000 --- a/lib/lrama/state/inadequacy_annotation.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Lrama - class State - class InadequacyAnnotation < Struct.new(:token, :action, :item, :contributed, keyword_init: true) - def no_contributions? - item.nil? && !contributed - end - end - end -end diff --git a/lib/lrama/state/reduce.rb b/lib/lrama/state/reduce.rb index 65e6fa6c..a2b7c26c 100644 --- a/lib/lrama/state/reduce.rb +++ b/lib/lrama/state/reduce.rb @@ -17,10 +17,6 @@ def rule @item.rule end - def inspect - "(Reduce by rule #{item.inspect}, [#{(@look_ahead || []).map(&:inspect).join(', ')}])" - end - def look_ahead=(look_ahead) @look_ahead = look_ahead.freeze end diff --git a/lib/lrama/state/shift.rb b/lib/lrama/state/shift.rb index 7c22f688..81ef013a 100644 --- a/lib/lrama/state/shift.rb +++ b/lib/lrama/state/shift.rb @@ -10,10 +10,6 @@ def initialize(next_sym, next_items) @next_sym = next_sym @next_items = next_items end - - def inspect - "(Shift, #{@next_sym.inspect})" - end end end end diff --git a/lib/lrama/states.rb b/lib/lrama/states.rb index 1cc38d7e..f75a2c45 100644 --- a/lib/lrama/states.rb +++ b/lib/lrama/states.rb @@ -555,7 +555,6 @@ def split_states transition_queue = [] @states.each do |state| state.transitions.each do |shift, next_state| - # pp state, shift, next_state compute_state(state, shift, next_state) end end @@ -573,7 +572,6 @@ def merge_lookaheads(state, filtered_lookaheads) def compute_state(state, shift, next_state) filtered_lookaheads = state.propagate_lookaheads(next_state) - # pp filtered_lookaheads.transform_keys(&:to_s) s = next_state.ielr_isocores.find {|st| st.compatible_lookahead?(filtered_lookaheads) } if s.nil? diff --git a/lib/lrama/states/item.rb b/lib/lrama/states/item.rb index 0c5405f9..e89cb969 100644 --- a/lib/lrama/states/item.rb +++ b/lib/lrama/states/item.rb @@ -72,10 +72,6 @@ def to_s "#{lhs.id.s_value}: #{display_name}" end - def inspect - to_s - end - def display_name r = rhs.map(&:display_name).insert(position, "•").join(" ") "#{r} (rule #{rule_id})" diff --git a/sample/calc.y b/sample/calc.y index f9915d87..b4c4ca30 100644 --- a/sample/calc.y +++ b/sample/calc.y @@ -25,7 +25,6 @@ static int yyerror(YYLTYPE *loc, const char *str); %union { int val; } -%define lr.type ielr %token LF %token NUM %type expr diff --git a/spec/fixtures/integration/calculator.y b/spec/fixtures/integration/calculator.y index d3ec5c06..54b86b7a 100644 --- a/spec/fixtures/integration/calculator.y +++ b/spec/fixtures/integration/calculator.y @@ -16,7 +16,6 @@ static int yyerror(YYLTYPE *loc, const char *str); %type expr %left '+' '-' %left '*' '/' -%define lr.type ielr %locations diff --git a/spec/lrama/state_spec.rb b/spec/lrama/state_spec.rb deleted file mode 100644 index 0c6a994d..00000000 --- a/spec/lrama/state_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -RSpec.describe Lrama::State do - describe '#internal_dependencies' do - subject { state.internal_dependencies(*goto) } - - end -end