Compare commits
No commits in common. "8ab2c28343546e5de9b525bf42c9add21be15a51" and "4d94a7ad5965d163c4a20585e1897636a9f27af7" have entirely different histories.
8ab2c28343
...
4d94a7ad59
10
README.adoc
10
README.adoc
@ -58,8 +58,6 @@ A few examples to get started.
|
|||||||
|
|
||||||
[source,go]
|
[source,go]
|
||||||
----
|
----
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
@ -215,7 +213,7 @@ Currently, boolean operations are evaluated using _short cut evaluation_. This m
|
|||||||
#TODO: List operations#
|
#TODO: List operations#
|
||||||
|
|
||||||
=== Variables
|
=== Variables
|
||||||
#TODO: variables#
|
#TODO: List operations#
|
||||||
|
|
||||||
=== Other operations
|
=== Other operations
|
||||||
|
|
||||||
@ -309,13 +307,13 @@ The table below shows all supported operators by decreasing priorities.
|
|||||||
=== Functions
|
=== Functions
|
||||||
|
|
||||||
==== Function calls
|
==== Function calls
|
||||||
#TODO: function calls operations#
|
#TODO: List operations#
|
||||||
|
|
||||||
==== Function definitions
|
==== Function definitions
|
||||||
#TODO: function definitions operations#
|
#TODO: List operations#
|
||||||
|
|
||||||
==== Builtins
|
==== Builtins
|
||||||
#TODO: builtins#
|
#TODO: List operations#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,16 +19,16 @@ func EvalString(ctx ExprContext, source string) (result any, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
type Arg struct {
|
type EvalArg struct {
|
||||||
name string
|
name string
|
||||||
value any
|
value any
|
||||||
}
|
}
|
||||||
|
|
||||||
func EvalStringA(source string, args ...Arg) (result any, err error) {
|
func EvalStringA(source string, args ...EvalArg) (result any, err error) {
|
||||||
return EvalStringV(source, args)
|
return EvalStringV(source, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EvalStringV(source string, args []Arg) (result any, err error) {
|
func EvalStringV(source string, args []EvalArg) (result any, err error) {
|
||||||
ctx := NewSimpleFuncStore()
|
ctx := NewSimpleFuncStore()
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
if isFunc(arg.value) {
|
if isFunc(arg.value) {
|
||||||
|
@ -24,7 +24,7 @@ func subtract(ctx ExprContext, name string, args []any) (result any, err error)
|
|||||||
func TestEvalStringA(t *testing.T) {
|
func TestEvalStringA(t *testing.T) {
|
||||||
|
|
||||||
source := `a + b * subtract(4,2)`
|
source := `a + b * subtract(4,2)`
|
||||||
args := []Arg{
|
args := []EvalArg{
|
||||||
{"a", uint8(1)},
|
{"a", uint8(1)},
|
||||||
{"b", int8(2)},
|
{"b", int8(2)},
|
||||||
{"subtract", FuncTemplate(subtract)},
|
{"subtract", FuncTemplate(subtract)},
|
||||||
|
Loading…
Reference in New Issue
Block a user