Exception: Kumi::Parser::ParseError
- Inherits:
-
StandardError
- Object
- StandardError
- Kumi::Parser::ParseError
- Defined in:
- lib/kumi/parser/parse_error.rb
Overview
A syntax error detected during the parse phase — lexing or AST construction — and nothing past it. Parse errors are about shape: an unexpected character, a missing ‘end`, a hash key that isn’t a symbol or string. Anything that needs to know what a name means (types, axes, whether a referenced declaration exists) is a semantic concern and belongs to kumi-core’s analyzer, not here.
The error knows the byte offset where parsing got stuck and a plain-English description of what was expected versus what was found. The Source renders the caret frame; we keep a reference so callers that want a fully formatted message (file:line:col + frame) can get one without re-deriving locations.
Instance Attribute Summary collapse
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#short_message ⇒ Object
readonly
The bare “what/why” without location or frame — used where a caller wants to compose its own message.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #column ⇒ Object
-
#initialize(message, source:, offset:) ⇒ ParseError
constructor
A new instance of ParseError.
- #line ⇒ Object
- #location ⇒ Object
Constructor Details
#initialize(message, source:, offset:) ⇒ ParseError
Returns a new instance of ParseError.
19 20 21 22 23 24 |
# File 'lib/kumi/parser/parse_error.rb', line 19 def initialize(, source:, offset:) @source = source @offset = offset @short_message = super(()) end |
Instance Attribute Details
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
17 18 19 |
# File 'lib/kumi/parser/parse_error.rb', line 17 def offset @offset end |
#short_message ⇒ Object (readonly)
The bare “what/why” without location or frame — used where a caller wants to compose its own message.
40 41 42 |
# File 'lib/kumi/parser/parse_error.rb', line 40 def @short_message end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
17 18 19 |
# File 'lib/kumi/parser/parse_error.rb', line 17 def source @source end |
Instance Method Details
#column ⇒ Object
34 35 36 |
# File 'lib/kumi/parser/parse_error.rb', line 34 def column location.column end |
#line ⇒ Object
30 31 32 |
# File 'lib/kumi/parser/parse_error.rb', line 30 def line location.line end |
#location ⇒ Object
26 27 28 |
# File 'lib/kumi/parser/parse_error.rb', line 26 def location source.location(offset) end |