vm

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinOpExpr

type BinOpExpr struct {
	Op  string
	LHS Expr
	RHS Expr
}

BinOpExpr is a type for indicating binary operator.

type CallExpr

type CallExpr struct {
	Name  string
	Exprs []Expr
}

CallExpr is a type for indicating calling functions.

type Expr

type Expr interface {
}

Expr is a type for indicating expression.

type ForExpr

type ForExpr struct {
	LHS1 string
	LHS2 string
	RHS  Expr
}

ForExpr is a type for indicating expression.

type IdentExpr

type IdentExpr struct {
	Name string
}

IdentExpr is a type for indicating ident.

type ItemExpr

type ItemExpr struct {
	LHS   Expr
	Index Expr
}

ItemExpr is a type for indicating reference items in map.

type Lexer

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

Lexer is a lexer.

func (*Lexer) Error

func (l *Lexer) Error(e string)

func (*Lexer) Lex

func (l *Lexer) Lex(v *yySymType) int

Lex parse the token.

type LitExpr

type LitExpr struct {
	Value interface{}
}

LitExpr is a type for indicating literals.

type MemberExpr

type MemberExpr struct {
	LHS  Expr
	Name string
}

MemberExpr is a type for indicating reference member or fields.

type MethodCallExpr

type MethodCallExpr struct {
	LHS   Expr
	Name  string
	Exprs []Expr
}

MethodCallExpr is a type for indicating calling methods.

type VM

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

VM is a vertual machine.

func New

func New() *VM

New create the VM.

func (*VM) Compile

func (v *VM) Compile(s string) (Expr, error)

Compile compile the source.

func (*VM) Eval

func (v *VM) Eval(expr Expr) (interface{}, error)

Eval evaluate the expression.

func (*VM) Get

func (v *VM) Get(n string) (interface{}, bool)

Get get value named with name.

func (*VM) Set

func (v *VM) Set(n string, vv interface{})

Set set value with name.

Jump to

Keyboard shortcuts

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