struct

Mica::Core::Position

Inherits Struct < Value < Object

A place in a format's input, carried by every Mica::ParseError.

byte_offset is 0-based and counts bytes of the original input, before any transcoding (a byte order mark included). line and column are 1-based for text formats (the column counts characters) and 0 for formats without lines.

Mica::Core::Position.new(42_i64, 3, 7).to_s # => "line 3, column 7, byte 42"
Mica::Core::Position.new(42_i64).to_s       # => "byte 42"

Constructors

new(byte_offset : Int64, line : Int32 = 0, column : Int32 = 0)
Source

Instance methods

byte_offset
clone
Source
column
copy_with(byte_offset _byte_offset = @byte_offset, line _line = @line, column _column = @column)
Source
line
text?

Returns true when the position has a line and column.

Source
to_s(io : IO) : Nil

Same as #inspect(io).

Source