Sha256: f5e66fa0863e46af4adca4ce89555a005a4401159794709dc403e96fb5314302

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module Basic101

  class Error < StandardError ; end

  class ArraySizeError < Error ; end
  class ForNextSequenceError < Error ; end
  class ForWithoutNext < Error ; end
  class IndexError < Error ; end
  class InputError < Error ; end
  class InternalError < Error ; end
  class InvalidArgumentError < Error ; end
  class NextWithoutFor < Error ; end
  class NoMoreInputError < Error ; end
  class OutOfDataError < Error ; end
  class ReturnWithoutGosub < Error ; end
  class TypeError < Error ; end
  class UndefinedLineNumberError < Error ; end

  class BadInputFormatError < InputError ; end
  class TooFewInputItemsError < InputError ; end

  class DuplicateReferenceInForStack < InternalError ; end

  class SyntaxError < Error

    def initialize(line, line_number, column_number, parse_error)
      @line = line
      @line_number = line_number
      @column_number = column_number
      @parse_error = parse_error
      super(message)
    end

    def to_s
      out = StringIO.new
      out.puts @parse_error
      out.puts @line
      out.puts '%*s' % [(@column_number), '^']
      out.string
    end

    private

    def message
      @parse_error
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basic101-0.4.0 lib/basic101/errors.rb
basic101-0.2.0 lib/basic101/errors.rb
basic101-0.1.0 lib/basic101/errors.rb