Exception: Brainfucktt::ParserError

Inherits:
Error
  • Object
show all
Defined in:
lib/brainfucktt/errors.rb

Overview

Raised when the code being parsed has a syntax error.

Instance Method Summary collapse

Constructor Details

#initialize(language_parser) ⇒ ParserError

Returns a new instance of ParserError.

Parameters:

  • language_parser (Brainfucktt::LanguageParser)

Raises:

  • (TypeError)


44
45
46
47
48
# File 'lib/brainfucktt/errors.rb', line 44

def initialize(language_parser)
  raise TypeError unless language_parser.instance_of?(Brainfucktt::LanguageParser)
    
  @language_parser = language_parser
end

Instance Method Details

#columnString

Returns:

  • (String)


66
67
68
# File 'lib/brainfucktt/errors.rb', line 66

def column
  @language_parser.failure_column
end

#lineString

Returns:

  • (String)


61
62
63
# File 'lib/brainfucktt/errors.rb', line 61

def line
  @language_parser.failure_line
end

#reasonString

Returns:

  • (String)


56
57
58
# File 'lib/brainfucktt/errors.rb', line 56

def reason
  @language_parser.failure_reason
end

#to_sString

Returns:

  • (String)


51
52
53
# File 'lib/brainfucktt/errors.rb', line 51

def to_s
  "Error at column #{column}, line #{line} - '#{reason}'"
end