summaryrefslogtreecommitdiff
path: root/parse.rb
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-05-25 17:17:58 +0200
committerPatrick Simianer <p@simianer.de>2014-05-25 17:17:58 +0200
commit660c715491c9d2079401a26d3ba9d329ff8b52e4 (patch)
treed2905b434cc360a1d6f98e7b9e91b0b7145f4508 /parse.rb
parente97fbb5a38b79e18699719634d8156a590a3bf3d (diff)
fix
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