retrofitted arithmetic functions
This commit is contained in:
parent
f3e39e156c
commit
7c630d5a38
4 changed files with 264 additions and 1 deletions
|
|
@ -24,6 +24,8 @@ import (
|
|||
)
|
||||
|
||||
func not(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
in = in.Eval(ft, vt)
|
||||
|
||||
if in.Tag != ast.BOOL {
|
||||
log.Log(log.ERR, "non-bool argument to 'not'", "not")
|
||||
return nil
|
||||
|
|
@ -96,10 +98,24 @@ func eq(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
out = "F"
|
||||
}
|
||||
|
||||
case ast.NUMBER, ast.STRING, ast.BOOL:
|
||||
case ast.STRING, ast.BOOL:
|
||||
if in.Value() != second.Value() {
|
||||
out = "F"
|
||||
}
|
||||
|
||||
case ast.NUMBER:
|
||||
l_val, parse_err := strconv.ParseFloat(in.Value(), 64)
|
||||
r_val, parse_err := strconv.ParseFloat(second.Value(), 64)
|
||||
if parse_err != nil {
|
||||
log.Log(log.ERR,
|
||||
"error parsing number: "+parse_err.Error(),
|
||||
"eq")
|
||||
return nil
|
||||
}
|
||||
|
||||
if l_val != r_val {
|
||||
out = "F"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue