Exception: MilkTea::SemanticError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg = nil, line: nil, column: nil, length: nil, path: nil, suggestion: nil) ⇒ SemanticError

Returns a new instance of SemanticError.



24
25
26
27
28
29
30
31
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 24

def initialize(msg = nil, line: nil, column: nil, length: nil, path: nil, suggestion: nil)
  super(msg)
  @line = line
  @column = column
  @length = length
  @path = path
  @suggestion = suggestion
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



22
23
24
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 22

def column
  @column
end

#lengthObject (readonly)

Returns the value of attribute length.



22
23
24
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 22

def length
  @length
end

#lineObject (readonly)

Returns the value of attribute line.



22
23
24
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 22

def line
  @line
end

#pathObject (readonly)

Returns the value of attribute path.



22
23
24
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 22

def path
  @path
end

#suggestionObject (readonly)

Returns the value of attribute suggestion.



22
23
24
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 22

def suggestion
  @suggestion
end

Instance Method Details

#codeObject



33
34
35
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 33

def code
  "sema/error"
end

#to_diagnostic(path: nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/milk_tea/core/semantic_analyzer.rb', line 37

def to_diagnostic(path: nil)
  Diagnostic.new(
    path: @path || path,
    line: @line,
    column: @column,
    length: @length,
    code: "sema/error",
    message: message,
    severity: :error,
  )
end