summaryrefslogtreecommitdiff
path: root/src/texec/eval.go
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-04-10 17:30:30 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-04-10 17:30:30 -0400
commited2f9793fae7d1c018e3de463617339c68faa3c0 (patch)
tree241b65e29d9944873e1ac4825ef025bfdf222cd3 /src/texec/eval.go
parentad84b1068494872db2166bd81ce1f3831ead2c6b (diff)
A few fixes
+ Fix an error with if statements inside loops + Fix a parser bug with boolean operators ~ Change libtnsl stub to return integers when reading a file ~ Change libtnsl stub to return -1 on EOF or file read error
Diffstat (limited to 'src/texec/eval.go')
-rw-r--r--src/texec/eval.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/texec/eval.go b/src/texec/eval.go
index fa187ef..c39d704 100644
--- a/src/texec/eval.go
+++ b/src/texec/eval.go
@@ -994,10 +994,16 @@ func evalValue(v tparse.Node, ctx *VarMap) *TVariable {
case "<":
out.Type = tBool
out.Data = a.Data.(float64) < b.Data.(float64)
- case ">=":
+ case "!>":
+ out.Type = tBool
+ out.Data = a.Data.(float64) <= b.Data.(float64)
+ case "!<":
out.Type = tBool
out.Data = a.Data.(float64) >= b.Data.(float64)
- case "<=":
+ case ">==":
+ out.Type = tBool
+ out.Data = a.Data.(float64) >= b.Data.(float64)
+ case "<==":
out.Type = tBool
out.Data = a.Data.(float64) <= b.Data.(float64)
}
@@ -1081,7 +1087,13 @@ func evalCF(v tparse.Node, ctx *VarMap) (bool, TVariable, int) {
if val.Data.(bool) == true {
i++
- for ;i < len(v.Sub) && getNames(v.Sub[i])[0] == "else"; i++ {}
+ for ;i < len(v.Sub) && v.Sub[i].Data.Data == "block"; {
+ if getNames(v.Sub[i])[0] == "else" {
+ i++
+ } else {
+ break
+ }
+ }
if i < len(v.Sub) {
i--