expr

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(exprStr string) ([]byte, error)

func Parse

func Parse(filename string, b []byte, opts ...Option) (interface{}, error)

Parse parses the data from b using filename as information in the error messages.

func ParseFile

func ParseFile(filename string, opts ...Option) (interface{}, error)

ParseFile parses the file identified by filename.

func ParseReader

func ParseReader(filename string, r io.Reader, opts ...Option) (interface{}, error)

ParseReader parses the data from r using filename as information in the error messages.

Types

type Array

type Array []interface{}

func (Array) Bytes

func (arr Array) Bytes() ([]byte, error)

func (Array) String

func (t Array) String() string

type Byteful

type Byteful interface {
	Bytes() ([]byte, error)
}

type Bytes

type Bytes struct {
	Data           []byte
	LengthPrefixed bool
}

func NewBytes

func NewBytes(bz []byte, lengthPrefixed bool) Bytes

func (Bytes) Bytes

func (b Bytes) Bytes() ([]byte, error)

func (Bytes) String

func (b Bytes) String() string

type Numeric

type Numeric struct {
	Type   string
	Number string
}

func (Numeric) Bytes

func (n Numeric) Bytes() ([]byte, error)

type Option

type Option func(*parser) Option

Option is a function that can set an option on the parser. It returns the previous setting as an Option.

func Debug

func Debug(b bool) Option

Debug creates an Option to set the debug flag to b. When set to true, debugging information is printed to stdout while parsing.

The default is false.

func Memoize

func Memoize(b bool) Option

Memoize creates an Option to set the memoize flag to b. When set to true, the parser will cache all results so each expression is evaluated only once. This guarantees linear parsing time even for pathological cases, at the expense of more memory and slower times for typical cases.

The default is false.

func Recover

func Recover(b bool) Option

Recover creates an Option to set the recover flag to b. When set to true, this causes the parser to recover from panics and convert it to an error. Setting it to false can be useful while debugging to access the full stack trace.

The default is true.

type Placeholder

type Placeholder struct {
	Label string
}

func (Placeholder) Bytes

func (p Placeholder) Bytes() ([]byte, error)

func (Placeholder) String

func (p Placeholder) String() string

type String

type String struct {
	Text string
}

func NewString

func NewString(text string) String

func (String) Bytes

func (s String) Bytes() ([]byte, error)

func (String) String

func (s String) String() string

type Tuple

type Tuple []interface{}

func (Tuple) Bytes

func (t Tuple) Bytes() ([]byte, error)

func (Tuple) String

func (t Tuple) String() string

Jump to

Keyboard shortcuts

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