Exception: Ibex::Runtime::ParseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/ibex/runtime/parser.rb

Overview

Raised by the default parser error handler.

Direct Known Subclasses

ResourceLimitError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, token_id: nil, token_name: nil, token_value: nil, expected_tokens: [], location: nil, state: nil, suggestions: [], error_id: nil, detail: nil) ⇒ ParseError

rubocop:disable Layout/LineLength rubocop:enable Layout/LineLength



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ibex/runtime/parser.rb', line 28

def initialize(
  message = nil,
  token_id: nil,
  token_name: nil,
  token_value: nil,
  expected_tokens: [],
  location: nil,
  state: nil,
  suggestions: [],
  error_id: nil,
  detail: nil
)
  @token_id = token_id
  @token_name = token_name
  @token_value = token_value
  @expected_tokens = expected_tokens.dup.freeze
  @location = location
  @state = state
  @suggestions = suggestions.dup.freeze
  @error_id = error_id&.dup&.freeze
  @detail = detail
  super(message || diagnostic_message)
end

Instance Attribute Details

#error_idObject (readonly)

: String?



23
24
25
# File 'lib/ibex/runtime/parser.rb', line 23

def error_id
  @error_id
end

#expected_tokensObject (readonly)

: Array



19
20
21
# File 'lib/ibex/runtime/parser.rb', line 19

def expected_tokens
  @expected_tokens
end

#locationObject (readonly)

: untyped



20
21
22
# File 'lib/ibex/runtime/parser.rb', line 20

def location
  @location
end

#stateObject (readonly)

: Integer?



21
22
23
# File 'lib/ibex/runtime/parser.rb', line 21

def state
  @state
end

#suggestionsObject (readonly)

: Array



22
23
24
# File 'lib/ibex/runtime/parser.rb', line 22

def suggestions
  @suggestions
end

#token_idObject (readonly)

: Integer?



16
17
18
# File 'lib/ibex/runtime/parser.rb', line 16

def token_id
  @token_id
end

#token_nameObject (readonly)

: String?



17
18
19
# File 'lib/ibex/runtime/parser.rb', line 17

def token_name
  @token_name
end

#token_valueObject (readonly)

: untyped



18
19
20
# File 'lib/ibex/runtime/parser.rb', line 18

def token_value
  @token_value
end

Instance Method Details

#location_labelObject



53
54
55
56
57
58
# File 'lib/ibex/runtime/parser.rb', line 53

def location_label
  file = location_value(:file) || "(input)"
  line = location_value(:line) || 1
  column = location_value(:column) || 1
  "#{file}:#{line}:#{column}"
end