Exception: MilkTea::ParseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/milk_tea/core/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, token:, path: nil) ⇒ ParseError

Returns a new instance of ParseError.



15
16
17
18
19
20
21
# File 'lib/milk_tea/core/parser.rb', line 15

def initialize(message, token:, path: nil)
  @token = token
  @path = path

  location = [path, "#{token.line}:#{token.column}"].compact.join(":")
  super(location.empty? ? message : "#{message} at #{location}")
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/milk_tea/core/parser.rb', line 13

def path
  @path
end

#tokenObject (readonly)

Returns the value of attribute token.



13
14
15
# File 'lib/milk_tea/core/parser.rb', line 13

def token
  @token
end

Instance Method Details

#codeObject



31
32
33
# File 'lib/milk_tea/core/parser.rb', line 31

def code
  "parse/error"
end

#columnObject



27
28
29
# File 'lib/milk_tea/core/parser.rb', line 27

def column
  @token.column
end

#lineObject



23
24
25
# File 'lib/milk_tea/core/parser.rb', line 23

def line
  @token.line
end