px

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseError

func ParseError[T tx.TokenKind](msg string, token tx.Token[T]) error

func VisitInOrder added in v0.7.0

func VisitInOrder[T tx.TokenKind, E NodeKind](node *Node[T, E], visit func(n *Node[T, E]))

func VisitPostOrder added in v0.7.0

func VisitPostOrder[T tx.TokenKind, E NodeKind](node *Node[T, E], visit func(n *Node[T, E]))

func VisitPreorder added in v0.7.0

func VisitPreorder[T tx.TokenKind, E NodeKind](node *Node[T, E], visit func(n *Node[T, E]))

Types

type Node

type Node[T tx.TokenKind, E NodeKind] struct {
	Token    tx.Token[T]
	Kind     E
	Parent   *Node[T, E]
	Children []*Node[T, E]
}

func (*Node[T, E]) Push

func (self *Node[T, E]) Push(nodes ...*Node[T, E])

func (*Node[T, E]) SetParent

func (self *Node[T, E]) SetParent(n Node[T, E])

func (*Node[T, E]) Value

func (self *Node[T, E]) Value() []byte

type NodeKind

type NodeKind interface{ comparable }

type Parser

type Parser[T tx.TokenKind] struct {
	Tokens []tx.Token[T]
	Next   tx.Token[T]
	Pos    int32
	Error  error
}

func NewParser

func NewParser[T tx.TokenKind](tokens []tx.Token[T]) *Parser[T]

func (*Parser[T]) Adv

func (self *Parser[T]) Adv()

func (*Parser[T]) Assert added in v0.7.0

func (self *Parser[T]) Assert(kinds ...T) (Token[T], bool)

func (*Parser[T]) Maybe added in v0.7.0

func (self *Parser[T]) Maybe(kinds ...T) (Token[T], bool)

func (*Parser[T]) Peek

func (self *Parser[T]) Peek(ahead int) tx.Token[T]

func (*Parser[T]) Revert

func (self *Parser[T]) Revert(clearError bool, snapshot int32)

func (*Parser[T]) Snapshot

func (self *Parser[T]) Snapshot() int32

type Token added in v0.7.0

type Token[T TokenKind] = tx.Token[T]

type TokenKind added in v0.7.0

type TokenKind = tx.TokenKind

Jump to

Keyboard shortcuts

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