intern

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const And = PatternType(6)
View Source
const Concat = PatternType(4)
View Source
const Contains = PatternType(11)
View Source
const Empty = PatternType(1)
View Source
const Interleave = PatternType(13)
View Source
const Node = PatternType(2)
View Source
const Not = PatternType(9)
View Source
const Optional = PatternType(12)
View Source
const Or = PatternType(5)
View Source
const Reference = PatternType(8)
View Source
const ZAny = PatternType(10)
View Source
const ZeroOrMore = PatternType(7)

Variables

This section is empty.

Functions

func Interpret

func Interpret(g *ast.Grammar, record bool, parser parser.Interface) (bool, error)

Interpret interprets the grammar given the parser and returns whether the parser is valid given the grammar. Interpret uses derivatives and simplification to recusively derive the resulting grammar. This resulting grammar's nullability then represents the result of the function. This implementation does not handle immediate recursion, see the HasRecursion function.

Types

type Construct

type Construct interface {
	AddGrammar(g *ast.Grammar) (*Pattern, error)
	AddPatternDecl(name string, p *ast.Pattern) (*Pattern, error)
	SetContext(context *funcs.Context)
	Deref(name string) *Pattern
	NewPattern(this *ast.Pattern) (*Pattern, error)
	NewConcat(ps []*Pattern) (*Pattern, error)
	NewOr(ps []*Pattern) (*Pattern, error)
	NewAnd(ps []*Pattern) (*Pattern, error)
	NewInterleave(ps []*Pattern) (*Pattern, error)
	NewZAny() *Pattern
	NewEmpty() *Pattern
	NewNotZAny() *Pattern
	NewNot(*Pattern) (*Pattern, error)
	NewZeroOrMore(*Pattern) (*Pattern, error)
}

func NewConstructor

func NewConstructor() Construct

func NewConstructorOptimizedForRecords

func NewConstructorOptimizedForRecords() Construct

type IfExpr

type IfExpr struct {
	Cond funcs.Bool
	Thn  *Pattern
	Els  *Pattern
}

func DeriveCalls

func DeriveCalls(construct Construct, patterns []*Pattern) []*IfExpr

func NewIfExpr

func NewIfExpr(c funcs.Bool, thn, els *Pattern) *IfExpr

type Pattern

type Pattern struct {
	Type     PatternType
	Func     funcs.Bool
	Patterns []*Pattern
	Ref      string
	// contains filtered or unexported fields
}

func DeriveReturns

func DeriveReturns(c Construct, originals []*Pattern, evaluated []bool) ([]*Pattern, error)

func (*Pattern) Equal

func (p *Pattern) Equal(pp *Pattern) bool

func (*Pattern) GoString

func (p *Pattern) GoString() string

func (*Pattern) NewAst

func (p *Pattern) NewAst() *ast.Pattern

func (*Pattern) Nullable

func (p *Pattern) Nullable() bool

func (*Pattern) SetHash

func (p *Pattern) SetHash()

func (*Pattern) String

func (p *Pattern) String() string

type PatternType

type PatternType int

type Patterns

type Patterns struct {
	Patterns []*Pattern
	Index    int

	Escapable bool
	Accept    bool
	NullIndex int

	IndexOfZippedPatterns int
	IndexOfZippedIndexes  int
}

type SetOfPatterns

type SetOfPatterns struct {
	List            []*Patterns
	Hashes          map[uint64][]int
	SetOfBits       sets.BitsSet
	SetOfZipIndexes sets.Ints
}

SetOfPatterns represents an indexed list of list of Patterns. It reverse maps a list of Patterns into a single int.

func NewSetOfPatterns

func NewSetOfPatterns() *SetOfPatterns

func (*SetOfPatterns) Add

func (this *SetOfPatterns) Add(ps []*Pattern) int

func (*SetOfPatterns) Get

func (this *SetOfPatterns) Get(i int) *Patterns

type ZippedPatterns

type ZippedPatterns struct {
	Patterns []*Pattern
	Indexes  []int
}

func Zip

func Zip(patterns []*Pattern) *ZippedPatterns

func (*ZippedPatterns) Unzip

func (z *ZippedPatterns) Unzip() []*Pattern

Jump to

Keyboard shortcuts

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