Skip to content

Commit

Permalink
Use def_delegators in Lrama::States::Item
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Jan 28, 2024
1 parent 5561e09 commit 085cd4e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/lrama/states/item.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# TODO: Validate position is not over rule rhs

require "forwardable"

module Lrama
class States
class Item < Struct.new(:rule, :position, keyword_init: true)
extend Forwardable

def_delegators "rule", :lhs, :rhs

# Optimization for States#setup_state
def hash
[rule_id, position].hash
Expand All @@ -20,14 +26,6 @@ def number_of_rest_symbols
rhs.count - position
end

def lhs
rule.lhs
end

def rhs
rule.rhs
end

def next_sym
rhs[position]
end
Expand Down

0 comments on commit 085cd4e

Please sign in to comment.