v2

package
v0.0.0-...-e926abf Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseNothing

func ParseNothing(s Scanner) (Node, Scanner)

ParseNothing is a parser that will reject all input as invalid. It will not create a node for any input and return the scanner unchanged.

func Walk

func Walk(root Node) chan Node

Types

type Cursor

type Cursor int

type Identifier

type Identifier string

type Node

type Node interface {
	Name() string
	Children() []Node
	Value() string
	Source() Source
	IsTerminal() bool
}

func NewNonTerminal

func NewNonTerminal() Node

func NewTerminal

func NewTerminal(name string, value string, source Source) Node

NewTerminal will create and return a new terminal node.

func QueryFilter

func QueryFilter(root Node, predicate NodePredicate) []Node

func QueryMany

func QueryMany(root Node, query QueryString) []Node

func QueryOne

func QueryOne(root Node, query QueryString) Node

func QueryTerminals

func QueryTerminals(root Node) []Node

func TransformAll

func TransformAll(root Node, transform NodeTransformer) Node

func TransformMatch

func TransformMatch(root Node, predicate NodePredicate, transform NodeTransformer) Node

func TransformMatches

func TransformMatches(root Node, matchers []struct {
	NodePredicate
	NodeTransformer
}) Node

type NodeGenerator

type NodeGenerator func(Node, []Output) Output

type NodePredicate

type NodePredicate func(Node) bool

func IsA

func IsA(name string) NodePredicate

type NodeTransformer

type NodeTransformer func(Node) Node

type Output

type Output interface{}

func FoldUp

func FoldUp(root Node, generators []struct {
	NodePredicate
	NodeGenerator
}) Output

func GenerateAll

func GenerateAll(root Node, generator NodeGenerator) Output

func Map

func Map(nodes []Node, generator NodeGenerator) []Output

type Parser

type Parser func(Scanner) (Node, Scanner)

Parser function parses input text encapsulated by Scanner, higher order parsers are constructed using combinators.

func And

func And(name Identifier, parsers ...interface{}) Parser

func Atom

func Atom(name Identifier, atom string) Parser

func AtomExact

func AtomExact(name Identifier, atom string) Parser

func Char

func Char(name Identifier) Parser

func End

func End() Parser

func Hex

func Hex(name Identifier) Parser

func Ident

func Ident(name Identifier) Parser

func Int

func Int(name Identifier) Parser

func Kleen

func Kleen(name Identifier, parser interface{}) Parser

func Many

func Many(name Identifier, parser interface{}) Parser

func ManyUntil

func ManyUntil(name Identifier, itemParser interface{}, stopParser interface{}) Parser

func Maybe

func Maybe(name Identifier, parser interface{}) Parser

func NotEnd

func NotEnd() Parser

func Oct

func Oct(name Identifier) Parser

func Or

func Or(name Identifier, parsers ...interface{}) Parser

func OrToken

func OrToken(name Identifier, r Regex) Parser

func ShortCircuit

func ShortCircuit(parser Parser, callback ShortCircuitCallback) Parser

func String

func String(name Identifier) Parser

func Token

func Token(name string, pattern Regex) Parser

func TokenExact

func TokenExact(name Identifier, r Regex) Parser

type QueryString

type QueryString string

type Regex

type Regex string

type Scanner

type Scanner parsec.Scanner

type ShortCircuitCallback

type ShortCircuitCallback func(Node, parsec.Scanner) Node

type Source

type Source struct {
	File   string
	Line   int
	Index  int
	Cursor int
}

Jump to

Keyboard shortcuts

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