px

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 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

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]) SeqBreadthFirst

func (self *Node[T, E]) SeqBreadthFirst() iter.Seq[*Node[T, E]]

SeqBreadthFirst performs a breadth-first traversal of the tree beginning at 'Node' 'self'. Each node is yielded one time.

Considering the below tree structure, in breadth-first order the sequence of nodes produced by the iterator would be: A, B, C, D, E, F, G, H.

       A
     ╱   ╲
    B     C
   ╱ ╲   ╱ ╲
  D   E F   G
 ╱
H

func (*Node[T, E]) SeqDepthFirst

func (self *Node[T, E]) SeqDepthFirst() iter.Seq[*Node[T, E]]

SeqBreadthFirst performs a depth-first traversal of the tree beginning at 'Node' 'self'. Each node is yielded one time.

Considering the below tree structure, in depth-first order the sequence of nodes produced by the iterator would be: H, D, E, B, F, G, C, A.

       A
     ╱   ╲
    B     C
   ╱ ╲   ╱ ╲
  D   E F   G
 ╱
H

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
}

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]) Peek

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

func (*Parser[T]) Revert

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

func (*Parser[T]) Snapshot

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

Jump to

Keyboard shortcuts

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