peg

package module
v0.0.0-...-9e5f7f4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2013 License: BSD-2-Clause Imports: 1 Imported by: 138

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AndPredicate

type AndPredicate struct {
	*Parser
	Expression Exp
}

func (*AndPredicate) Match

func (this *AndPredicate) Match(start int) (int, *Result)

And Predicate

func (*AndPredicate) String

func (this *AndPredicate) String() string

type Exp

type Exp interface {
	Match(int) (int, *Result)
}

Expressions

type ExpressionTree

type ExpressionTree struct {
	Name     string
	Children []*ExpressionTree
	Value    int
}

func (*ExpressionTree) String

func (this *ExpressionTree) String() string

type NonTerminal

type NonTerminal struct {
	*Parser
	Name       string
	Expression Exp
}

func (*NonTerminal) Match

func (this *NonTerminal) Match(offset int) (int, *Result)

Non Terminal

func (*NonTerminal) String

func (this *NonTerminal) String() string

type NotPredicate

type NotPredicate struct {
	*Parser
	Expression Exp
}

func (*NotPredicate) Match

func (this *NotPredicate) Match(start int) (int, *Result)

Not Predicate

func (*NotPredicate) String

func (this *NotPredicate) String() string

type OneOrMore

type OneOrMore struct {
	*Parser
	Expression Exp
}

func (*OneOrMore) Match

func (this *OneOrMore) Match(offset int) (int, *Result)

One or More

func (*OneOrMore) String

func (this *OneOrMore) String() string

type Optional

type Optional struct {
	*Parser
	Expression Exp
}

func (*Optional) Match

func (this *Optional) Match(start int) (int, *Result)

Optional

func (*Optional) String

func (this *Optional) String() string

type OrderedChoice

type OrderedChoice struct {
	*Parser
	Expressions []Exp
}

func (*OrderedChoice) Match

func (this *OrderedChoice) Match(start int) (int, *Result)

Ordered Choice

func (*OrderedChoice) String

func (this *OrderedChoice) String() string

type Parser

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

func NewParser

func NewParser() *Parser

Create a new PEG Parser

func (*Parser) AndPredicate

func (this *Parser) AndPredicate(exp Exp) *AndPredicate

func (*Parser) NonTerminal

func (this *Parser) NonTerminal(name string) *NonTerminal

func (*Parser) NotPredicate

func (this *Parser) NotPredicate(exp Exp) *NotPredicate

func (*Parser) OneOrMore

func (this *Parser) OneOrMore(exp Exp) *OneOrMore

func (*Parser) Optional

func (this *Parser) Optional(exp Exp) *Optional

func (*Parser) OrderedChoice

func (this *Parser) OrderedChoice(exps ...Exp) *OrderedChoice

func (*Parser) Parse

func (this *Parser) Parse(text string) *ExpressionTree

func (*Parser) Range

func (this *Parser) Range(start, end int) *OrderedChoice

Extensions for easier construction

func (*Parser) Sequence

func (this *Parser) Sequence(exps ...Exp) *Sequence

func (*Parser) Terminal

func (this *Parser) Terminal(ch int) *Terminal

func (*Parser) ZeroOrMore

func (this *Parser) ZeroOrMore(exp Exp) *ZeroOrMore

type Result

type Result struct {
	*Parser
	Valid      bool
	Offset     int
	Length     int
	Expression Exp
	Children   []*Result
}

type Sequence

type Sequence struct {
	*Parser
	Expressions []Exp
}

func (*Sequence) Match

func (this *Sequence) Match(offset int) (int, *Result)

Sequence

func (*Sequence) String

func (this *Sequence) String() string

type Terminal

type Terminal struct {
	*Parser
	Character int
}

func (*Terminal) Match

func (this *Terminal) Match(offset int) (int, *Result)

Terminal

func (*Terminal) String

func (this *Terminal) String() string

type ZeroOrMore

type ZeroOrMore struct {
	*Parser
	Expression Exp
}

func (*ZeroOrMore) Match

func (this *ZeroOrMore) Match(offset int) (int, *Result)

Zero or More

func (*ZeroOrMore) String

func (this *ZeroOrMore) String() string

Directories

Path Synopsis
examples
math command

Jump to

Keyboard shortcuts

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