summaryrefslogtreecommitdiff
path: root/parse.rb
diff options
context:
space:
mode:
Diffstat (limited to 'parse.rb')
-rw-r--r--parse.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/parse.rb b/parse.rb
index fb14901..772edf5 100644
--- a/parse.rb
+++ b/parse.rb
@@ -42,9 +42,18 @@ class Item < Rule
attr_accessor :lhs, :rhs, :dot
def initialize rule_or_item, left, right, dot
- @lhs = rule_or_item.lhs.dup
- @rhs = rule_or_item.rhs.dup
+ @lhs = NT.new rule_or_item.lhs.symbol
@lhs.span = Span.new left, right
+ @rhs = []
+ rule_or_item.rhs.each { |x|
+ if x.class == T
+ @rhs << T.new(x.word)
+ end
+ if x.class == NT
+ @rhs << NT.new(x.symbol)
+ @rhs.last.span = Span.new x.span.left, x.span.right
+ end
+ }
@dot = dot
end