fix builds

This commit is contained in:
Aidan 2020-07-19 15:11:35 -07:00
parent ae9ca588d6
commit 26e331f331
No known key found for this signature in database
GPG key ID: 327711E983899316
4 changed files with 20 additions and 21 deletions

View file

@ -130,7 +130,7 @@ func DeleteVarTable(table VarTable) {
}
}
}
a
/* removes var from vartable
* if SyncTablesWithOSENviron is true, also unsets environment variable
*/

View file

@ -23,7 +23,13 @@ import (
"gitlab.com/whom/shs/ast"
)
func bool_cast(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
/* Takes one argument, must be a string
* attempts to cast to bool (T or F are valid values)
* returns nil on failure
*
* Example: (bool "F")
*/
func BoolCast(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
in = in.Eval(ft, vt, false)
if in.Tag == ast.LIST || in.Tag == ast.NUMBER {
log.Log(log.ERR,
@ -45,7 +51,7 @@ func bool_cast(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return res
}
func not(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
func Not(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
in = in.Eval(ft, vt, false)
if in.Tag != ast.BOOL {
@ -63,7 +69,7 @@ func not(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return t
}
func eq(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
func Eq(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
out := ast.TRUE
in = in.Eval(ft, vt, false)
@ -145,7 +151,7 @@ func eq(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return t
}
func lt(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
func Lt(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
out := ast.TRUE
second := in.Next
@ -168,7 +174,7 @@ func lt(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return t
}
func gt(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
func Gt(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
out := ast.TRUE
second := in.Next
@ -191,14 +197,14 @@ func gt(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return t
}
func ne(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return not(eq(in, vt, ft), vt, ft)
func Ne(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return Not(Eq(in, vt, ft), vt, ft)
}
func gte(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return not(lt(in, vt, ft), vt, ft)
func Gte(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return Not(Lt(in, vt, ft), vt, ft)
}
func lte(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return not(gt(in, vt, ft), vt, ft)
func Lte(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return Not(Gt(in, vt, ft), vt, ft)
}

View file

@ -116,7 +116,7 @@ func Fexists(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
*/
func Fread(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
in = in.Eval(ft, vt, false)
exists := fexists(in, vt, ft) // some waste, extra use of Eval
exists := Fexists(in, vt, ft) // some waste, extra use of Eval
if exists == nil || exists.Tag != ast.BOOL || exists.Value() == ast.FALSE {
log.Log(log.ERR,
"error calling fexists or file doesnt exist",
@ -199,7 +199,7 @@ func Fappend(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
return nil
}
exists := fexists(in, vt, ft)
exists := Fexists(in, vt, ft)
if exists.Value() == ast.FALSE {
log.Log(log.ERR,
"file "+in.Value()+" does not exist",

View file

@ -52,13 +52,6 @@ func GenFuncTable() ast.FuncTable {
Args: -1,
},
"eval": &ast.Function{
Function: Eval,
Name: "eval",
TimesCalled: 0,
Args: -1,
},
"func": &ast.Function{
Function: DeclFunc,
Name: "decl_func",