diff options
Diffstat (limited to 'src/flint.cr')
| -rw-r--r-- | src/flint.cr | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/flint.cr b/src/flint.cr index 1c67cc9..f2323a2 100644 --- a/src/flint.cr +++ b/src/flint.cr @@ -24,7 +24,9 @@ module Flint memory_size = Brainfuck::DEFAULT_TAPE_SIZE parser.banner = "Useage: flint brainfuck [OPTIONS] [FILE]" - parser.on("-t CELLS", "--tape-size=CELLS", "specify the number of memory cells in the tape, defaults to 30,000") { nil } + 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("-h", "--help", "show this help and exit") do @@ -67,7 +69,7 @@ module Flint if chosen_language == :brainfuck bf_parser = Brainfuck::Parser.new(source_io) - program = Brainfuck::Program.new(bf_parser) + program = Brainfuck::Program.new(bf_parser, memory_size) end begin @@ -76,6 +78,9 @@ module Flint puts "Caught ParserError" puts ex.message exit(1) + rescue ex : Brainfuck::MemoryError + puts "Caught MemoryError" + puts ex.message end end end |
