Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into inline-index
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Apr 15, 2024
2 parents 9b37f6a + 1d9f17b commit 4967ded
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions lib/lrama/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,38 +70,16 @@ def set_look_ahead(rule, look_ahead)
reduce.look_ahead = look_ahead
end

# Returns array of [Shift, next_state]
def nterm_transitions
return @nterm_transitions if @nterm_transitions

@nterm_transitions = []

shifts.each do |shift|
next if shift.next_sym.term?

@nterm_transitions << [shift, @items_to_state[shift.next_items]]
end

@nterm_transitions
@nterm_transitions ||= transitions.select {|shift, _| shift.next_sym.nterm? }
end

# Returns array of [Shift, next_state]
def term_transitions
return @term_transitions if @term_transitions

@term_transitions = []

shifts.each do |shift|
next if shift.next_sym.nterm?

@term_transitions << [shift, @items_to_state[shift.next_items]]
end

@term_transitions
@term_transitions ||= transitions.select {|shift, _| shift.next_sym.term? }
end

def transitions
term_transitions + nterm_transitions
@transitions ||= shifts.map {|shift| [shift, @items_to_state[shift.next_items]] }
end

def selected_term_transitions
Expand Down

0 comments on commit 4967ded

Please sign in to comment.