executor

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecimalRoot

func DecimalRoot(d1, d2 decimal.Decimal) decimal.Decimal

Types

type Executor

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

func NewExecutor

func NewExecutor(debugger *debugger.Debugger) *Executor

func (*Executor) Execute

func (e *Executor) Execute(expr string) (string, *ExprError)

type ExprError

type ExprError struct {
	Message string
	Loc     Location
}

func NewExprErr

func NewExprErr(text string, loc Location) *ExprError

func (*ExprError) Error

func (e *ExprError) Error() string

type Lexer

type Lexer struct{}

func NewLexer

func NewLexer() *Lexer

func (*Lexer) Tokenize

func (l *Lexer) Tokenize(text string) ([]Token, *ExprError)

type Location

type Location struct {
	Start int
	End   int
}

func (Location) Size

func (l Location) Size() int

type OpType

type OpType string
const (
	TypeNoOp   OpType = "no-op"
	TypeUnary  OpType = "unary"
	TypeBinary OpType = "binary"
)

type Operator

type Operator int
const (
	OpNoOp Operator = iota
	OpOpenParent
	OpCloseParent
	OpPlus
	OpMinus
	OpUnaryMinus
	OpMultiply
	OpDivide
	OpPower
	OpInc
	OpDec
	OpMod
	OpRoot
	OpRound
	OpFloor
	OpCeil
	OpAbs
)

type Token

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

func (Token) String

func (t Token) String() string

type TokenKind

type TokenKind string
const (
	KindIdentifier TokenKind = "identifier" // `abc`, `a12`, `a_b_1`
	KindNumber     TokenKind = "number"     // `123`, `1.12`, `12`, `1_2_3`
	KindOperator   TokenKind = "operator"   // `+`, `-`, `^`, `(`
)

type Vars

type Vars map[Token]decimal.Decimal

Jump to

Keyboard shortcuts

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