ast

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	RuleTag   = "@rule"
	ChoiceTag = "@choice"
	SkipTag   = "@skip"
)

Variables

This section is empty.

Functions

func BuildTreeView added in v0.10.0

func BuildTreeView(rootname string, root Node, skipAtNodes bool) string

func Choice added in v0.11.0

func Choice(n Node) int

Choice attempts to check for the @choice tag, and if found returns the value The return is the 0-based index of the chosen option. -1 means there was no @choice tag

func NewExtRefTreeElement added in v0.13.0

func NewExtRefTreeElement(g parser.Grammar, node parser.TreeElement) parser.TreeElement

func ToParserNode added in v0.6.0

func ToParserNode(g parser.Grammar, branch Branch) parser.TreeElement

Types

type Branch

type Branch map[string]Children

func FromParserNode added in v0.6.0

func FromParserNode(g parser.Grammar, e parser.TreeElement) Branch

func (Branch) ContentEquals added in v0.14.0

func (b Branch) ContentEquals(other Node) bool

func (Branch) IsExtra added in v0.13.0

func (Branch) IsExtra()

func (Branch) Many added in v0.3.0

func (b Branch) Many(name string) []Node

func (Branch) One added in v0.3.0

func (b Branch) One(name string) Node

func (Branch) Scanner

func (b Branch) Scanner() parser.Scanner

func (Branch) String

func (b Branch) String() string

type Children

type Children interface {
	fmt.Stringer
	Scanner() parser.Scanner
	// contains filtered or unexported methods
}

func Which added in v0.10.0

func Which(b Branch, names ...string) (string, Children)

Which returns the first child of the branch from the list of names supplied

type Extra

type Extra struct {
	Data any
}

func (Extra) ContentEquals added in v0.14.0

func (e Extra) ContentEquals(other Node) bool

func (Extra) Many added in v0.3.0

func (Extra) Many(_ string) []Node

func (Extra) One added in v0.3.0

func (Extra) One(_ string) Node

func (Extra) Scanner

func (Extra) Scanner() parser.Scanner

func (Extra) String

func (e Extra) String() string

type Leaf

type Leaf parser.Scanner

func (Leaf) ContentEquals added in v0.14.0

func (l Leaf) ContentEquals(other Node) bool

func (Leaf) Many added in v0.3.0

func (Leaf) Many(_ string) []Node

func (Leaf) One added in v0.3.0

func (Leaf) One(_ string) Node

func (Leaf) Scanner

func (l Leaf) Scanner() parser.Scanner

func (Leaf) String

func (l Leaf) String() string

type Many

type Many []Node

func (Many) Scanner

func (c Many) Scanner() parser.Scanner

func (Many) String

func (c Many) String() string

type Node

type Node interface {
	fmt.Stringer
	One(name string) Node
	Many(name string) []Node
	Scanner() parser.Scanner
	ContentEquals(n Node) bool // true if scanner and extra data contents are equivalent
	// contains filtered or unexported methods
}

func All added in v0.11.0

func All(n Node, name string) []Node

All returns a list of Nodes for the given name even if only a single Node is found

func First added in v0.11.0

func First(n Node, name string) Node

First finds the first child of the given node with the named tag. nil if the named node does not exist

type One

type One struct {
	Node Node
}

func (One) Scanner

func (c One) Scanner() parser.Scanner

func (One) String

func (c One) String() string

Jump to

Keyboard shortcuts

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