expr

package
v0.0.0-...-5eebaeb Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package expr 表达式指令的实现。 作为脚本系统的一个子指令,与上级指令处理有着较为紧密的关系, 因此这里直接抛出异常而非返回错误(包编码规约)。 而作为一个子包实现,是为了尽可能分离逻辑耦合,优化编码条理。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calculor

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

表达式执行器。 call() 会步进执行每一个指令,返回指令码值和指令执行后的原始返回值。 当表达式执行完后,再次调用 call() 返回 (-1, nil)。 注记: 如果表达式内调用的指令返回nil或空值,则这里的值存储为0。 如果表达式内指令返回多于1个值,则抛出错误。

func Calculator

func Calculator(call func() (int, []any)) *Calculor

创建一个计算器。 expr 为待执行的指令序列片段(小括号包围的部分)。 call 为上级提供的指令调用步进器。

func (*Calculor) Calc

func (c *Calculor) Calc() float64

执行器运行。

Jump to

Keyboard shortcuts

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