Documentation
¶
Index ¶
- func UnexpectedAt(where string, unexpected error) error
- type Grammar
- type InflixParselet
- type InvalidToken
- type LexFn
- type Parselet
- type Parser
- func (p *Parser[T]) Consume()
- func (p *Parser[T]) Expect(n TokenType) bool
- func (p *Parser[T]) ExpectOrError(n TokenType) error
- func (p *Parser[T]) HasMore() bool
- func (p *Parser[T]) NextPrecedence() Precedence
- func (p *Parser[T]) Parse() (T, error)
- func (p *Parser[T]) ParseAt(prd Precedence) (T, error)
- type Pos
- type Precedence
- type StringLexer
- func (l *StringLexer) AcceptManyOf(chars string)
- func (l *StringLexer) AcceptOneOf(chars string) bool
- func (l *StringLexer) AcceptWhile(a func(rune) bool)
- func (l *StringLexer) Discard()
- func (l *StringLexer) Emit(typ TokenType) LexFn
- func (l *StringLexer) Error(format string, args ...any) LexFn
- func (l *StringLexer) Init(input string, initial LexFn, state any)
- func (l *StringLexer) Next() rune
- func (l *StringLexer) NextToken() Token
- func (l *StringLexer) Peek() rune
- func (l *StringLexer) Prev()
- func (l *StringLexer) Word() string
- type Token
- type TokenType
- type UnexpectedToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnexpectedAt ¶
Types ¶
type Grammar ¶
type Grammar[T any] struct { // contains filtered or unexported fields }
func NewGrammar ¶
func (Grammar[T]) Infix ¶
func (g Grammar[T]) Infix(p Precedence, i InflixParselet[T], ts ...TokenType)
func (Grammar[T]) Precedence ¶
func (g Grammar[T]) Precedence(t TokenType) Precedence
type InflixParselet ¶
type InflixParselet[T any] func(*Parser[T], T, Precedence) (T, error)
type InvalidToken ¶
func (InvalidToken) Error ¶
func (e InvalidToken) Error() string
type LexFn ¶
type LexFn func(*StringLexer, any) LexFn
type Parser ¶
func (*Parser[T]) ExpectOrError ¶
func (*Parser[T]) NextPrecedence ¶
func (p *Parser[T]) NextPrecedence() Precedence
func (*Parser[T]) ParseAt ¶
func (p *Parser[T]) ParseAt(prd Precedence) (T, error)
type StringLexer ¶
type StringLexer struct {
// contains filtered or unexported fields
}
func (*StringLexer) AcceptManyOf ¶
func (l *StringLexer) AcceptManyOf(chars string)
func (*StringLexer) AcceptOneOf ¶
func (l *StringLexer) AcceptOneOf(chars string) bool
func (*StringLexer) AcceptWhile ¶
func (l *StringLexer) AcceptWhile(a func(rune) bool)
func (*StringLexer) Discard ¶
func (l *StringLexer) Discard()
func (*StringLexer) Emit ¶
func (l *StringLexer) Emit(typ TokenType) LexFn
func (*StringLexer) Next ¶
func (l *StringLexer) Next() rune
func (*StringLexer) NextToken ¶
func (l *StringLexer) NextToken() Token
func (*StringLexer) Peek ¶
func (l *StringLexer) Peek() rune
func (*StringLexer) Prev ¶
func (l *StringLexer) Prev()
func (*StringLexer) Word ¶
func (l *StringLexer) Word() string
type UnexpectedToken ¶
type UnexpectedToken struct {
Have Token
}
func (UnexpectedToken) Error ¶
func (u UnexpectedToken) Error() string
Click to show internal directories.
Click to hide internal directories.