mem

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: 9 Imported by: 1

Documentation

Overview

Package mem contains functions to interpret and memoize the execution of the grammar.

TODO: cleanup

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mem

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

Mem is the structure containing the memoized grammar.

func New

func New(g *ast.Grammar) (*Mem, error)

New creates a new memoizable grammar.

func NewRecord

func NewRecord(g *ast.Grammar) (*Mem, error)

New creates a new memoizable grammar which is optimized for records. A record can be json, protobuf, reflected go structures or any structure that have unique field names for each structure. XML would be an example of a structure for which this simplification is NOT appropriate.

func (*Mem) SetContext

func (mem *Mem) SetContext(context *funcs.Context)

func (*Mem) Validate

func (mem *Mem) Validate(p parser.Interface) (bool, error)

Validate interprets the grammar given the parser and returns whether the parser is valid given the grammar. The intermediate results are memoized to help with the speed of future executions.

NOTE: This is a naive implementation and it does not handle left recursion.

Jump to

Keyboard shortcuts

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