Documentation
¶
Overview ¶
Package lexgo implements a simple lexer.
Index ¶
- Variables
- type Config
- type Lexer
- func (lex *Lexer[T]) HasWhitespace() bool
- func (lex *Lexer[T]) Init(r io.Reader, config Config[T]) error
- func (lex *Lexer[T]) Newline() bool
- func (lex *Lexer[T]) Next() T
- func (lex *Lexer[T]) NextLine() string
- func (lex *Lexer[T]) Peek() T
- func (lex *Lexer[T]) ReadByte() (byte, error)
- func (lex *Lexer[T]) Reset(src io.Reader)
- type Location
- type ValueFormat
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config[T comparable] struct { // IsIdentChar determines if a given byte is part of an identifier based on its position within the string. // The default function matches digits (except as first char), lower and upper letters, underscore. IsIdentChar func(c byte, index int) bool // EscapeChar is used to unescape a character literal. EscapeChar func(escaped byte, r io.ByteReader) (unescaped byte, _ error) Invalid T Error T EOF T Unsigned T Signed T Float T String T Identifier T All map[T]string }
type Lexer ¶
type Lexer[T comparable] struct { Error error Location Location String string // identifier, comment, string literal ValueFormat ValueFormat Unsigned uint64 Signed int64 Float float64 // contains filtered or unexported fields }
func (*Lexer[T]) HasWhitespace ¶
HasWhitespace returns whether the next token is a whitespace without consuming it.
type ValueFormat ¶
type ValueFormat uint8
const ( Decimal ValueFormat = iota // 123 Hexadecimal // 0x Binary // 0b Character // ' ' )
func (ValueFormat) Format ¶
func (f ValueFormat) Format(v uint64) string
Click to show internal directories.
Click to hide internal directories.