namarara/exe/mm2ep-depend

36 lines
773 B
Text
Raw Normal View History

2017-09-04 09:19:29 +00:00
#!/usr/bin/env ruby
$:.insert(0, 'lib')
require 'thor'
2017-09-07 15:05:06 +00:00
require 'rly'
require 'pry'
2017-09-12 13:32:50 +00:00
require 'mm2ep_depend'
2017-09-12 14:23:44 +00:00
require 'pp'
2017-09-04 09:19:29 +00:00
module Mm2ep
module Depend
class ParseCli < Thor
2017-09-13 12:55:56 +00:00
desc 'parse INFILE VARS', 'Parse INFILE into tokens and evaluate vars'
def parse(infile, *vars)
2017-09-12 14:35:11 +00:00
line = File.read(infile).gsub(/\n/,'')
parser = Parser.new(Lexer.new)
2017-09-13 12:55:56 +00:00
vartruc = {}
vars.each do |var|
vartruc[var.split('=')[0]] = var.split('=')[1]
end
puts vartruc
parser.names(vartruc)
2017-09-12 14:35:11 +00:00
token = parser.parse(line.chomp, true)
pp token
2017-09-12 14:35:59 +00:00
puts "RAW : #{line}"
puts "EVAL: #{token.to_s}"
2017-09-13 12:55:56 +00:00
puts "RESULT: #{token.compute}"
2017-09-04 09:19:29 +00:00
end
end
end
end
Mm2ep::Depend::ParseCli.start(ARGV)