diff options
Diffstat (limited to 'src/flint.cr')
| -rw-r--r-- | src/flint.cr | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/flint.cr b/src/flint.cr index f2323a2..8f11223 100644 --- a/src/flint.cr +++ b/src/flint.cr @@ -4,10 +4,10 @@ require "option_parser" require "./util.cr" require "./brainfuck/*" -require "./brainfuck/parser.cr" +require "./thue/*" module Flint - VERSION = "0.1.0" + VERSION = "0.1.1" def self.main execution_mode = :interpret @@ -23,12 +23,19 @@ module Flint chosen_language = :brainfuck memory_size = Brainfuck::DEFAULT_TAPE_SIZE - parser.banner = "Useage: flint brainfuck [OPTIONS] [FILE]" + parser.banner = "Usage: flint brainfuck [OPTIONS] [FILE]" parser.on("-t CELLS", "--tape-size=CELLS", "specify the number of memory cells in the tape, defaults to 30,000") do |_cells| memory_size = _cells.to_i end end + parser.on("thue", "select Thue as the language") do + chosen_language = :thue + + parser.banner = "Usage: flint thue [OPTIONS] [FILE]" + # no thue-specific options yet + end + parser.on("-h", "--help", "show this help and exit") do puts parser exit(0) @@ -48,12 +55,6 @@ module Flint parser.parse - if chosen_language.nil? - puts "ERROR: No language chosen" - puts parser - exit(1) - end - if read_stdin source_io = STDIN elsif source_file @@ -62,14 +63,20 @@ module Flint else puts "ERROR: No source file chosen" puts parser - puts source_file.nil? - puts (!read_stdin) exit(1) end - if chosen_language == :brainfuck + case chosen_language + when :brainfuck bf_parser = Brainfuck::Parser.new(source_io) program = Brainfuck::Program.new(bf_parser, memory_size) + when :thue + thue_parser = Thue::Parser.new(source_io) + program = Thue::Program.new(thue_parser) + else + puts "ERROR: No language chosen" + puts parser + exit(1) end begin |
