interpreter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package interpreter ...

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTOMLDataType indicates unexpected data type passed to the function.
	ErrTOMLDataType = errors.New("wrong type error")
)

Functions

This section is empty.

Types

type Error

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

Error ...

func (*Error) Error

func (e *Error) Error() string

Error reports the Interpreter error with the data type and value followed by the name of the data filter that was to be applied to this data.

func (*Error) Is

func (e *Error) Is(target error) bool

Is allows to check if Error.err matches the target error.

type FilterFunc

type FilterFunc func(data ...any) ([]any, error)

FilterFunc specifies the data transformation function type.

type Interpreter

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

Interpreter interprets the tq query AST into a pipe-like sequence of filtering functions processing TOML input data as specified in the query.

func New

func New() *Interpreter

New returns a new instance of Interpreter.

func (*Interpreter) Interpret

func (i *Interpreter) Interpret(root ast.Expr) FilterFunc

Interpret extracts a sequence of filtering functions by traversing the AST. It returns an entry function that takes in deserialized TOML data and applies filtering functions in the sequence provided by the Interpreter.

func (*Interpreter) VisitFilter

func (i *Interpreter) VisitFilter(e ast.Expr)

VisitFilter interprets the Filter AST node.

func (*Interpreter) VisitIdentity

func (i *Interpreter) VisitIdentity(e ast.Expr)

VisitIdentity interprets the Identity AST node.

func (*Interpreter) VisitInteger

func (i *Interpreter) VisitInteger(e ast.Expr)

VisitInteger interprets the Integer AST node.

func (*Interpreter) VisitIterator

func (i *Interpreter) VisitIterator(e ast.Expr)

VisitIterator interprets the Iterator AST node.

func (*Interpreter) VisitQuery

func (i *Interpreter) VisitQuery(e ast.Expr)

VisitQuery interprets the Query AST node.

func (*Interpreter) VisitRoot

func (i *Interpreter) VisitRoot(e ast.Expr)

VisitRoot interprets the Root AST node.

func (*Interpreter) VisitSelector

func (i *Interpreter) VisitSelector(e ast.Expr)

VisitSelector interprets the Selector AST node.

func (*Interpreter) VisitSpan

func (i *Interpreter) VisitSpan(e ast.Expr)

VisitSpan interprets the Span AST node.

func (*Interpreter) VisitString

func (i *Interpreter) VisitString(e ast.Expr)

VisitString interprets the String AST node.

Jump to

Keyboard shortcuts

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