parse

package
v0.0.0-...-59377f0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EOF = newTerm().As("EOF")
	SOF = newTerm().As("SOF")
)

Functions

This section is empty.

Types

type Alt

type Alt struct {
	*R
	Rules
	// contains filtered or unexported fields
}

func (Alt) String

func (a Alt) String() string

type Alts

type Alts []*Alt

func (Alts) String

func (as Alts) String() string

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder() *Builder

func (*Builder) Con

func (b *Builder) Con(rs ...interface{}) *R

func (*Builder) Or

func (b *Builder) Or(rs ...interface{}) *R

func (*Builder) Term

func (b *Builder) Term(name string) *R

type Node

type Node struct {
	// contains filtered or unexported fields
}

func (*Node) Child

func (n *Node) Child(i int) *Node

func (*Node) ChildCount

func (n *Node) ChildCount() int

func (*Node) Each

func (n *Node) Each(visit func(*Node))

func (*Node) EachItem

func (n *Node) EachItem(visit func(*Node))

func (*Node) Find

func (s *Node) Find(rule *R) *Node

func (*Node) Get

func (n *Node) Get(r *R) string

func (*Node) ID

func (n *Node) ID() int

func (*Node) Is

func (n *Node) Is(r *R) bool

func (*Node) LastChild

func (n *Node) LastChild() *Node

func (*Node) Pos

func (n *Node) Pos() int

func (*Node) Rule

func (n *Node) Rule() *R

func (*Node) String

func (n *Node) String() string

func (*Node) Value

func (n *Node) Value() []byte

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func New

func New(r *R) *Parser

func (*Parser) Error

func (p *Parser) Error() error

func (*Parser) Parse

func (p *Parser) Parse(t *Token, tr *R) bool

func (*Parser) Reset

func (p *Parser) Reset()

func (*Parser) Results

func (p *Parser) Results() []*Node

type R

type R struct {
	Alts
	// contains filtered or unexported fields
}

R is a BNF production rule

func NewRule

func NewRule() *R

func (*R) As

func (r *R) As(name string) *R

func (*R) AtLeast

func (r *R) AtLeast(n int) *R

func (*R) Define

func (r *R) Define(o *R) *R

func (*R) InitTermSet

func (r *R) InitTermSet()

func (*R) Name

func (r *R) Name() string

func (*R) Repeat

func (r *R) Repeat(limit ...int) *R

func (*R) String

func (r *R) String() string

type Rules

type Rules []*R

type Token

type Token struct {
	ID    int
	Value []byte
	Pos   int
}

Jump to

Keyboard shortcuts

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