diff options
author | Patrick Simianer <p@simianer.de> | 2015-01-14 19:11:37 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2015-01-14 19:11:37 +0100 |
commit | 4056a888e184f1d4cada48b79370c52fc0e313b1 (patch) | |
tree | c77812f3aa267a73bde7560cba5afbad311ca99a /prototype/grammar.rb | |
parent | 16c0aaafae5847b0fc712fbd25a25b8f7ad61bad (diff) |
fixes to prototype
Diffstat (limited to 'prototype/grammar.rb')
-rw-r--r-- | prototype/grammar.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/prototype/grammar.rb b/prototype/grammar.rb index 05224f4..abccb15 100644 --- a/prototype/grammar.rb +++ b/prototype/grammar.rb @@ -42,7 +42,7 @@ class NT end class Rule - attr_accessor :lhs, :rhs, :target, :map, :f + attr_accessor :lhs, :rhs, :target, :map, :f, :arity def initialize lhs=NT.new, rhs=[], target=[], map=[], f=SparseVector.new, arity=0 @lhs = lhs @@ -116,7 +116,7 @@ class Grammar @rules.map { |r| r.to_s }.join "\n" end - def add_glue + def add_glue_rules @rules.map { |r| r.lhs.symbol }.select { |s| s != 'S' }.uniq.each { |symbol| @rules << Rule.new(NT.new('S'), [NT.new(symbol, 0)], [NT.new(symbol, 0)], [0]) @start_nt << @rules.last @@ -125,7 +125,7 @@ class Grammar } end - def add_pass_through a + def add_pass_through_rules a return if !a a.each { |word| @rules << Rule.new(NT.new('X'), [T.new(word)], [T.new(word)]) |