namarara/exe/mm2ep-depend
2017-09-13 14:55:56 +02:00

35 lines
773 B
Ruby
Executable file

#!/usr/bin/env ruby
$:.insert(0, 'lib')
require 'thor'
require 'rly'
require 'pry'
require 'mm2ep_depend'
require 'pp'
module Mm2ep
module Depend
class ParseCli < Thor
desc 'parse INFILE VARS', 'Parse INFILE into tokens and evaluate vars'
def parse(infile, *vars)
line = File.read(infile).gsub(/\n/,'')
parser = Parser.new(Lexer.new)
vartruc = {}
vars.each do |var|
vartruc[var.split('=')[0]] = var.split('=')[1]
end
puts vartruc
parser.names(vartruc)
token = parser.parse(line.chomp, true)
pp token
puts "RAW : #{line}"
puts "EVAL: #{token.to_s}"
puts "RESULT: #{token.compute}"
end
end
end
end
Mm2ep::Depend::ParseCli.start(ARGV)