template

package
v0.0.0-...-65f6afe Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package template provides the code templates that are emitted to generate the parser.

Each template handler is tested independently in isolation.

This package as given implements the following grammar:

Literal <- "abc"
CharClass <- [ \n\r\t]
Star <- CharClass *
Group <- Star < Literal > Star
Predicate <- & Group
... etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureEndHandler

func CaptureEndHandler(r *Result, pos int) (int, error)

func CaptureStartHandler

func CaptureStartHandler(r *Result, pos int) (int, error)

func CharClassAlnumHandler

func CharClassAlnumHandler(r *Result, pos int) (int, error)

func CharClassHandler

func CharClassHandler(r *Result, pos int) (int, error)

func ChoiceHandler

func ChoiceHandler(r *Result, pos int) (int, error)

func DotHandler

func DotHandler(r *Result, pos int) (int, error)

func GroupHandler

func GroupHandler(r *Result, pos int) (int, error)

func LiteralHandler

func LiteralHandler(r *Result, pos int) (int, error)

LiteralHandler is a template code for literal handlers in the generated parser.

func PlusHandler

func PlusHandler(r *Result, pos int) (int, error)

func PredicateHandler

func PredicateHandler(r *Result, pos int) (int, error)

func QuestionHandler

func QuestionHandler(r *Result, pos int) (int, error)

func RuleHandler

func RuleHandler(r *Result, pos int) (int, error)

func StarHandler

func StarHandler(r *Result, pos int) (int, error)

Types

type Node

type Node = parser.Node

type NodeStack

type NodeStack []*Node

func (*NodeStack) Pop

func (s *NodeStack) Pop() *Node

func (*NodeStack) Push

func (s *NodeStack) Push(n *Node)

type Result

type Result struct {
	Source string
	Memo   map[int]map[int]*Node
	Level  int
	// Final AST.
	Tree *parser.Node
	NodeStack
}

Result encapsulates one parse result.

func Parse

func Parse(source string) (*Result, error)

func (*Result) Attach

func (r *Result) Attach(n *Node)

func (*Result) TopNode

func (r *Result) TopNode() *Node

Jump to

Keyboard shortcuts

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