From 4056a888e184f1d4cada48b79370c52fc0e313b1 Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Wed, 14 Jan 2015 19:11:37 +0100 Subject: fixes to prototype --- prototype/grammar.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'prototype/grammar.rb') 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)]) -- cgit v1.2.3