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



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ibex/runtime/parser.rb', line 62

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?



57
58
59
# File 'lib/ibex/runtime/parser.rb', line 57

def error_id
  @error_id
end

#expected_tokensObject (readonly)

: Array



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

def expected_tokens
  @expected_tokens
end

#locationObject (readonly)

: runtime_value



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

def location
  @location
end

#stateObject (readonly)

: Integer?



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

def state
  @state
end

#suggestionsObject (readonly)

: Array



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

def suggestions
  @suggestions
end

#token_idObject (readonly)

: Integer?



50
51
52
# File 'lib/ibex/runtime/parser.rb', line 50

def token_id
  @token_id
end

#token_nameObject (readonly)

: String?



51
52
53
# File 'lib/ibex/runtime/parser.rb', line 51

def token_name
  @token_name
end

#token_valueObject (readonly)

: runtime_value



52
53
54
# File 'lib/ibex/runtime/parser.rb', line 52

def token_value
  @token_value
end

Instance Method Details

#location_labelObject



87
88
89
90
91
92
# File 'lib/ibex/runtime/parser.rb', line 87

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