summaryrefslogtreecommitdiff
path: root/grammar.rb
diff options
context:
space:
mode:
Diffstat (limited to 'grammar.rb')
-rw-r--r--grammar.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/grammar.rb b/grammar.rb
index 0b2bc61..2506d61 100644
--- a/grammar.rb
+++ b/grammar.rb
@@ -39,13 +39,14 @@ class NT
end
class Rule
- attr_accessor :lhs, :rhs, :target, :map
+ attr_accessor :lhs, :rhs, :target, :map, :f
- def initialize lhs=nil, rhs=nil, target=nil, map=nil
+ def initialize lhs=nil, rhs=nil, target=nil, map=nil, f=SparseVector.new
@lhs = lhs
@rhs = rhs
@target = target
@map = (map ? map : [])
+ @f = f
@arity_ = nil
end
@@ -73,10 +74,11 @@ class Rule
end
def from_s s
- lhs, rhs, target = splitpipe s, 3
+ lhs, rhs, target, f = splitpipe s, 3
@lhs = NT.from_s lhs
@rhs = read_right_ rhs
@target = read_right_ target, true
+ @f = (f ? SparseVector.from_kv(f) : nil)
end
def self.from_s_x s