Skip to content

Commit

Permalink
Remove unnecessary codes
Browse files Browse the repository at this point in the history
  • Loading branch information
junk0612 committed Sep 25, 2024
1 parent 96dc20c commit 2621701
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 44 deletions.
4 changes: 0 additions & 4 deletions lib/lrama/grammar/symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ def comment
alias_name || id.s_value
end
end

def inspect
id.s_value
end
end
end
end
9 changes: 0 additions & 9 deletions lib/lrama/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand All @@ -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]]
}
Expand All @@ -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|
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions lib/lrama/state/inadequacy_annotation.rb

This file was deleted.

4 changes: 0 additions & 4 deletions lib/lrama/state/reduce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions lib/lrama/state/shift.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions lib/lrama/states.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down
4 changes: 0 additions & 4 deletions lib/lrama/states/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
Expand Down
1 change: 0 additions & 1 deletion sample/calc.y
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ static int yyerror(YYLTYPE *loc, const char *str);
%union {
int val;
}
%define lr.type ielr
%token LF
%token <val> NUM
%type <val> expr
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/integration/calculator.y
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ static int yyerror(YYLTYPE *loc, const char *str);
%type <val> expr
%left '+' '-'
%left '*' '/'
%define lr.type ielr

%locations

Expand Down
6 changes: 0 additions & 6 deletions spec/lrama/state_spec.rb

This file was deleted.

0 comments on commit 2621701

Please sign in to comment.