use constants for True and False instead of tokens

This commit is contained in:
Aidan 2020-06-30 20:36:45 -07:00
parent a216d9af41
commit 53adeacc6d
No known key found for this signature in database
GPG key ID: 327711E983899316
5 changed files with 25 additions and 19 deletions

View file

@ -17,11 +17,14 @@
package stdlib
import "gitlab.com/whom/shs/ast"
import (
"gitlab.com/whom/shs/ast"
"gitlab.com/whom/shs/log"
)
/* return one evaluated form or another based on the boolean statement
*/
func shs_if(in *ast.Token, vt VarTable, ft FuncTable) *ast.Token {
func shs_if(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
cond := in
t := cond.Next
f := t.Next
@ -53,7 +56,7 @@ func shs_if(in *ast.Token, vt VarTable, ft FuncTable) *ast.Token {
/* continually eval n forms while element #1 evals to T
*/
func shs_while(in *ast.Token, vt VarTable, ft FuncTable) *ast.Token {
func shs_while(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
cond := in
forms := in.Next
in.Next = nil
@ -68,14 +71,14 @@ func shs_while(in *ast.Token, vt VarTable, ft FuncTable) *ast.Token {
}
// slight downside here: doesnt log when the wrong tag is set
for eval.Tag == ast.BOOL && eval.Value() == 'T' {
for eval.Tag == ast.BOOL && eval.Value() == ast.TRUE {
// eval all forms
for i := forms; i != nil; i = i.Next {
res = i.Eval(ft, vt, false)
}
// retest eval
eval := cond.Eval(ft, vt, false)
eval = cond.Eval(ft, vt, false)
}
return res