auto

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package auto compiles a parsed validator grammar into a visual pushdown automaton and executes it. Compilation into a VPA may result in an exponential explosion, since fully converting a grammar to VPA is O(2^n^2). Rather use the mem package. It gives comparable speed and has no exponential behaviour. This package is just here to provide a benchmark against the mem package.

Index

Constants

This section is empty.

Variables

View Source
var ErrTooBig = errors.New("a state explosion has occured")

A maximum number is set for bitsets as an option, when it is exceeded the number of options to consider is too large and we recommend rather using the memoized version of katydid.

Functions

This section is empty.

Types

type Auto

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

Auto is the structure that represents the automaton.

func Compile

func Compile(g *ast.Grammar, options ...Option) (*Auto, error)

Compile compiles a parsed validator grammar ast into a visual pushdown automaton.

func (*Auto) MetricNumberOfStates added in v0.5.2

func (auto *Auto) MetricNumberOfStates() int

func (*Auto) Validate

func (auto *Auto) Validate(p parse.Parser) (bool, error)

Validate executes an automaton with the given parser and returns whether the parser is valid given the automaton's original grammar.

type Option added in v0.7.0

type Option func(o *options)

func WithFieldNameTable added in v0.7.0

func WithFieldNameTable() Option

creates a lookup strings found in field name expressions.

func WithMaxBitSetSize added in v0.7.0

func WithMaxBitSetSize(m int) Option

func WithRecordSimplificationRules added in v0.7.0

func WithRecordSimplificationRules() Option

compiles a parsed validator grammar and optimizes it for the case where the input structures are records, by shrinking space with extra simplification rules. Do not use with XML, but JSON, Reflect and Protobufs are safe.

type PatternsSet added in v0.6.3

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

func NewPatternsSet added in v0.6.3

func NewPatternsSet() PatternsSet

func (*PatternsSet) Add added in v0.7.0

func (this *PatternsSet) Add(x []*intern.Pattern) int

func (*PatternsSet) Get added in v0.7.0

func (this *PatternsSet) Get(i int) []*intern.Pattern

func (*PatternsSet) Index added in v0.7.0

func (this *PatternsSet) Index(x []*intern.Pattern) int

func (*PatternsSet) Len added in v0.7.0

func (this *PatternsSet) Len() int

Jump to

Keyboard shortcuts

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