Sha256: 47234dca93d7532e196fbdf2e9ce2258358b4414d2ed2b704646f4a3b205ad8f
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
#!/usr/bin/env ruby require 'optparse' require File.join(File.expand_path(File.dirname(__FILE__)), '/../lib/p-lang') options = OptionParser.new do|opts| opts.banner = "Usage: p-lang [option]" opts.version = "0.2.0" opts.on("-e", "-e 'COMMAND'", "interp one line of script.") do |command| sa = PLang::Parser::SyntaxAnalyser.new(command) vm = PLang::VM::Interpreter.new(sa.parse) vm.execute! end opts.on("-i", "-i", "interactive p shell.") do shell = PLang::IPS::Shell.new shell.start end opts.on("-f", "-f FILE", "interp a script file.") do |file| begin program = File.readlines(file).join("") rescue puts "No such file (LoadError)" exit end begin sa = PLang::Parser::SyntaxAnalyser.new program vm = PLang::VM::Interpreter.new(sa.parse) vm.execute! rescue Exception => e puts "#{file}:#{e}" end end end argv = ARGV begin if ARGV.length > 0 if options.parse!(ARGV).length > 0 options.parse!(["-f" + ARGV[0]]) end else # without arguments options.parse!(["-i"]) end rescue puts "p-lang: unrecognized option" end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
p-lang-0.3.1 | bin/p-lang |
p-lang-0.3.0 | bin/p-lang |