summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/texec/eval.go18
-rw-r--r--src/texec/libtnsl.go7
-rw-r--r--src/tparse/tree-value.go27
3 files changed, 35 insertions, 17 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--
diff --git a/src/texec/libtnsl.go b/src/texec/libtnsl.go
index 581d15e..bb0ce7d 100644
--- a/src/texec/libtnsl.go
+++ b/src/texec/libtnsl.go
@@ -176,8 +176,11 @@ func tfile_close(file TVariable) {
// tnsl.io.File.read
func tfile_read(file TVariable) TVariable {
b := []byte{1}
- (file.Data).(*os.File).Read(b)
- return TVariable{tCharp, b[0]}
+ _, err := (file.Data).(*os.File).Read(b)
+ if err != nil {
+ return TVariable{tInt, -1}
+ }
+ return TVariable{tInt, int(b[0])}
}
// tnsl.io.File.write
diff --git a/src/tparse/tree-value.go b/src/tparse/tree-value.go
index 25982ff..7a0148a 100644
--- a/src/tparse/tree-value.go
+++ b/src/tparse/tree-value.go
@@ -69,27 +69,30 @@ var ORDER = map[string]int{
"!|": 6,
"!^": 6,
+ // Truthy equality
+ "==": 7,
+ "!==": 7,
+
// Boolean and
- "&&": 7,
+ "&&": 8,
// Boolean or
- "||": 7,
- // Truthy equals
- "==": 7,
+ "||": 8,
// Greater than
- ">": 7,
+ ">": 8,
// Less than
- "<": 7,
+ "<": 8,
- "!&&": 7,
- "!||": 7,
- "!==": 7,
+ "!>": 8,
+ "!<": 8,
+ ">==": 8,
+ "<==": 8,
- "!>": 7,
- "!<": 7,
+ "!&&": 8,
+ "!||": 8,
// Assignement
- "=": 8,
+ "=": 9,
}
// Works? Please test.