Skip to content

Commit

Permalink
renamed functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ax4w committed Nov 13, 2023
1 parent de6fc37 commit 8e5ba2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ func convertBytesToFloat(v []byte) float64 {
return r
}

func eval(f *token) *token {
func evaluate(f *token) *token {
if f.left == nil && f.right == nil {
return f
}
l := eval(f.left)
l := evaluate(f.left)
m := f
r := eval(f.right)
r := evaluate(f.right)
switch string(m.value) {
case "<":
if !(r.tokenType == tokenTypeInt && l.tokenType == tokenTypeInt ||
Expand Down Expand Up @@ -330,13 +330,13 @@ func parse(f string) []*token {
return nodes
}

func runEval(f string) string {
func eval(f string) string {
p := parse(f)
t := toTree(p)
if len(t) == 0 {
panic("Error while runEval")
panic("Error while eval")
}
e := eval(t[0])
e := evaluate(t[0])
if e == nil {
panic("Eval returned nil")
}
Expand Down
6 changes: 3 additions & 3 deletions eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
func TestEval(t *testing.T) {
//println(float64(int(rune('a'))))
//f := fmt.Sprintf("'%s' = 'hallo welt' & %d = 3 & %d = 4", "hallo welt", 3, 4)
if runEval("( 'William' == 'William' && 2 == 2 ) || 85.5 >= 90.0") != "t" {
if eval("( 'William' == 'William' && 2 == 2 ) || 85.5 >= 90.0") != "t" {
t.Fatalf("Should return true")
}
if runEval("1 != 1") != "f" {
if eval("1 != 1") != "f" {
t.Fatalf("Should be false")
}
if runEval("( 'Hi' == 'hi' ) || ( 1 == 1 && ( 5 != 5 !& ( t == f ) ) ) && 1.0 < 1.1") != "t" {
if eval("( 'Hi' == 'hi' ) || ( 1 == 1 && ( 5 != 5 !& ( t == f ) ) ) && 1.0 < 1.1") != "t" {
t.Fatalf("Should be true")
}
//traverseTree(tr[0])
Expand Down
4 changes: 2 additions & 2 deletions gorageTable.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (g *GorageTable) AddColumn(name string, datatype int) *GorageTable {
}

/*
f is the eval string. See github README.md for examples
f is the evaluate string. See github README.md for examples
*/
func (g *GorageTable) Where(f string) *GorageTable {
g.Lock()
Expand Down Expand Up @@ -164,7 +164,7 @@ func (g *GorageTable) Where(f string) *GorageTable {
tmp = append(tmp, k)
}
q := strings.Join(tmp, " ")
if e := runEval(q); e == "t" {
if e := eval(q); e == "t" {
res.Rows = append(res.Rows, v)
}
}
Expand Down

0 comments on commit 8e5ba2a

Please sign in to comment.