class Sthx::Cursor
- Sthx::Cursor
- Reference
- Object
Defined in:
synthax/cursor.crConstructors
- .new(source : String, char_index : Int32, byte_index : Int32)
-
.new(source : String, char_index : Int32)
Computes byte index from char index for you, otherwise the same as the other overload of
.new
.
Instance Method Summary
-
#byte_index : Int32
Returns the index of the byte pointed at by this cursor, within the source string.
-
#capture(byte_start : Int, byte_end : Int) : Bytes
Returns a byteslice between byte_start and byte_end byte indices.
-
#char_index : Int32
Returns the index of the character pointed at by this cursor, within the source string.
-
#max_err_byte_index : Int32
Returns the byte index of the error with most progress into the source string.
-
#thru?(& : Char -> Bool) : Bool
Advances this cursor to the next character if the block returns
true
for the current one. -
#thru?(bytes : Bytes) : Bool
Attempts to advance the cursor past bytes matching those in bytes.
Constructor Detail
Computes byte index from char index for you, otherwise the same as
the other overload of .new
.
Raises IndexError
if char index is out of bounds.
Instance Method Detail
Returns the index of the byte pointed at by this cursor, within the source string.
Returns a byteslice between byte_start and byte_end byte indices.
- The byte at byte_start is included in the returned slice.
- The byte at byte_end is excluded from the returned slice.
Returns the index of the character pointed at by this cursor, within the source string.
Returns the byte index of the error with most progress into the source string.
Advances this cursor to the next character if the block returns true
for
the current one.
Returns true
if advanced, false
if the position did not change.
Attempts to advance the cursor past bytes matching those in bytes.
Returns true
if advanced, false
if the position did not change.