diff options
author | Patrick Simianer <p@simianer.de> | 2014-05-08 17:56:31 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-05-08 17:56:31 +0200 |
commit | c8b4abf55672fb27eca97e921ca0e12057dcc0cf (patch) | |
tree | f29553541df4d63e45246f1f3415070dfbd2aa59 /grammar.rb | |
parent | 4400add706c01ebf1460701c651d66bbf592cfa5 (diff) |
correct, but still slow
Diffstat (limited to 'grammar.rb')
-rw-r--r-- | grammar.rb | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -69,11 +69,13 @@ class Grammar def initialize fn @rules = [] + @glue_rules = [] ReadFile.readlines_strip(fn).each_with_index { |s,j| - #STDERR.write '.' - #puts "\n" if j%100==0&&j>0 + STDERR.write '.' + STDERR.write "\n" if (j+1)%80==0 @rules << Rule.from_s(s) } + STDERR.write "\n" end def to_s @@ -83,9 +85,12 @@ class Grammar end def add_glue_rules + # see https://github.com/jweese/thrax/wiki/Glue-grammar @rules.map { |r| r.lhs.symbol }.reject { |s| s=='S' }.uniq.each { |s| @rules << Rule.new(NT.new('S'), [NT.new(s)]) + @glue_rules << @rules.last @rules << Rule.new(NT.new('S'), [NT.new('S'), NT.new('X')]) + @glue_rules << @rules.last } end |