From e97fbb5a38b79e18699719634d8156a590a3bf3d Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sun, 25 May 2014 16:37:58 +0200 Subject: fix --- parse.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'parse.rb') diff --git a/parse.rb b/parse.rb index e075b8e..fb14901 100644 --- a/parse.rb +++ b/parse.rb @@ -42,7 +42,7 @@ class Item < Rule attr_accessor :lhs, :rhs, :dot def initialize rule_or_item, left, right, dot - @lhs = rule_or_item.lhs + @lhs = rule_or_item.lhs.dup @rhs = rule_or_item.rhs.dup @lhs.span = Span.new left, right @dot = dot @@ -111,6 +111,7 @@ def parse input, n, active_chart, passive_chart, grammar if passive_chart.has active_item.rhs[active_item.dot].symbol, k, l if k == active_item.lhs.span.right new_item = Item.new active_item, active_item.lhs.span.left, l, active_item.dot+1 + new_item.rhs[new_item.dot-1].span = Span.new k, l if scan new_item, input, j, passive_chart if new_item.dot == new_item.rhs.size if new_item.lhs.span.left == i && new_item.lhs.span.right == j @@ -140,6 +141,7 @@ def parse input, n, active_chart, passive_chart, grammar next if active_item.rhs[active_item.dot].class!=NT if active_item.rhs[active_item.dot].symbol == s new_item = Item.new active_item, i, j, active_item.dot+1 + new_item.rhs[new_item.dot-1].span = Span.new i, j new_symbols << new_item.lhs.symbol if !new_symbols.include? new_item.lhs.symbol passive_chart.add new_item, i, j if new_item.dot==new_item.rhs.size end -- cgit v1.2.3