class RewriteFormulaeToAst

Public Class Methods

rewrite(input,output) click to toggle source
# File src/rewrite/rewrite_formulae_to_ast.rb, line 5
def self.rewrite(input,output)
  self.new.rewrite(input,output)
end

Public Instance Methods

rewrite(input,output) click to toggle source

input should be in the form: 'thingtthingtformulan' where the last field is always a forumla output will be in the form 'thingtthingtastn'

# File src/rewrite/rewrite_formulae_to_ast.rb, line 11
def rewrite(input,output)
  input.each_line.with_index do |line,i|
    line =~ /^(.*\t)(.*?)$/
    output.write $1
    ast =  Formula.parse($2)
    if ast
      output.puts ast.to_ast[1].to_s
    else
      $stderr.puts "Formula not parsed on line #{i+1}: #{line}"
      output.puts "[:parse_error,#{line.inspect}]"
    end
  end
end