lex

package
v0.0.0-...-e58c2a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

Methods returning a rune will return this sentinel value if the input has been exhausted.

Variables

This section is empty.

Functions

func IsAsciiAlpha

func IsAsciiAlpha(char rune) bool

Returns true if the current rune is an ASCII letter.

func IsAsciiAlphaNumeric

func IsAsciiAlphaNumeric(char rune) bool

Returns true if the current rune is an ASCII digit or letter.

func IsAsciiHexDigit

func IsAsciiHexDigit(char rune) bool

Returns true if the current rune is an hex digit

func IsAsciiLower

func IsAsciiLower(char rune) bool

Returns true if the current rune is an ASCII lowercase letter.

func IsAsciiNumeric

func IsAsciiNumeric(char rune) bool

Returns true if the current rune is an ASCII digit.

func IsAsciiUpper

func IsAsciiUpper(char rune) bool

Returns true if the current rune is an ASCII uppercase letter.

func IsOneOf

func IsOneOf(set string, char rune) bool

Returns true if the current rune is one of the given codepoints.

Types

type Cursor

type Cursor struct {
	Inner string
	// contains filtered or unexported fields
}

Cursor wraps an in-memory byte buffer and provides methods for matching its contents.

func New

func New(input string) Cursor

Creates a new cursor out of a string.

This method expects the input to be valid utf-8.

func (*Cursor) Consume

func (self *Cursor) Consume() rune

Consume the next codepoint from the input

func (*Cursor) ConsumeMatch

func (self *Cursor) ConsumeMatch(expected string) bool

Consumes as many bytes as there are in the expected string if the next few codepoints match it case-sensitively.

func (*Cursor) ConsumeMatchIgnoreCase

func (self *Cursor) ConsumeMatchIgnoreCase(expected string) bool

Consumes as many bytes as there are in the expected string if the next few codepoints match it case-insensitively.

func (*Cursor) LookAhead

func (self *Cursor) LookAhead(n uint) string

Returns the next n codepoints as a string.

Returns an empty string if there are not enough bytes in the string to accumulate n codepoints.

func (*Cursor) Peek

func (self *Cursor) Peek() rune

Returns the next codepoint without consuming it

func (*Cursor) Pos

func (self *Cursor) Pos() int

Returns the cursor's position with [Cursor.Inner]

func (*Cursor) Reconsume

func (self *Cursor) Reconsume()

Adjust the cursor's position within the input so that next time Cursor.Consume is called, it returns the same rune it just returned.

func (*Cursor) Remaining

func (self *Cursor) Remaining() string

Returns the chunk of the original input that is yet to be parsed.

func (*Cursor) Rewind

func (self *Cursor) Rewind()

Rewind to the last saved position.

func (*Cursor) Save

func (self *Cursor) Save()

Save the current position so we can later rewind to it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL