Version: v0.12.0 Latest Latest

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

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 4 Imported by: 0



Package ast provides the parser for WDTE.



This section is empty.


This section is empty.


This section is empty.


type Epsilon

type Epsilon struct {
	// contains filtered or unexported fields

An Epsilon is a special terminal which represnts a non-action.

func (Epsilon) Children

func (e Epsilon) Children() []Node

func (Epsilon) Parent

func (e Epsilon) Parent() Node

type NTerm

type NTerm struct {
	// contains filtered or unexported fields

An NTerm is a Node that represents a non-terminal. NTerms are always parent nodes.

func (*NTerm) AddChild

func (nt *NTerm) AddChild(n Node)

AddChild adds a child to the right-hand side of the NTerm's list of children.

func (NTerm) Children

func (nt NTerm) Children() []Node

func (NTerm) Name

func (nt NTerm) Name() string

Name returns the name of the non-terminal, minus the surrounding `<` and `>`.

func (NTerm) Parent

func (nt NTerm) Parent() Node

type Node

type Node interface {
	// Parent returns the Node's parent, or nil if it is the root node.
	Parent() Node

	// Children returns the node's children in left-to-right order.
	Children() []Node

A Node represents a node of the AST.

func Parse

func Parse(r io.Reader, macros scanner.MacroMap) (Node, error)

Parse parses a full script, returning the root node of the AST.

type ParseError

type ParseError struct {
	Line, Col int
	Err       error

A ParseError is returned if an error happens during parsing.

func (ParseError) Error

func (err ParseError) Error() string

type Term

type Term struct {
	// contains filtered or unexported fields

A Term is a Node that represents a terminal, such as a string or a keyword. Terms are always leaf nodes.

func (Term) Children

func (t Term) Children() []Node

func (Term) Parent

func (t Term) Parent() Node

func (Term) Tok

func (t Term) Tok() scanner.Token

Tok returns the scanner token that the node was generated from.


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to