interpreter

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: Apache-2.0 Imports: 6 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// InsertSemis options
	InsertSemis = &Options{ScanMode: tpl.InsertSemis}
)

Functions

func GetValue

func GetValue(t reflect.Type, lit string) (ret reflect.Value, err error)

GetValue parses a literal.

func ParseFloat

func ParseFloat(lit string) (v float64, err error)

ParseFloat parses a float value.

func ParseInt

func ParseInt(lit string) (v int64, err error)

ParseInt parses an integer value.

Types

type Engine

type Engine struct {
	*tpl.CompileRet
	Interpreter interpreter.Interface
	// contains filtered or unexported fields
}

Engine represents an interpreter.

func New

func New(ipt interpreter.Interface, options *Options) (p *Engine, err error)

New creates an interpreter.

func (*Engine) EvalCode

func (p *Engine) EvalCode(fn interpreter.Interface, name string, src interface{}) error

EvalCode evals src code.

func (*Engine) FileLine

func (p *Engine) FileLine(src interface{}) (f interpreter.FileLine)

FileLine returns file name and line number of src.

func (*Engine) Source

func (p *Engine) Source(src interface{}) (text []byte)

Source returns the source text of src.

type Options

type Options struct {
	Scanner  tpl.Tokener
	ScanMode tpl.ScanMode
}

Options is options of an interpreter.

type RuntimeError

type RuntimeError struct {
	Grammar tpl.Grammar
	Ctx     tpl.Context
	Err     error
	Src     []tpl.Token
}

RuntimeError represents a runtime error.

func (*RuntimeError) Error

func (p *RuntimeError) Error() string

Jump to

Keyboard shortcuts

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