syncing unfinished work with dev

This commit is contained in:
Aidan 2020-08-22 12:37:06 -07:00
parent 4ce1f7137c
commit 6afd01da2a
No known key found for this signature in database
GPG key ID: 327711E983899316
2 changed files with 14 additions and 7 deletions

View file

@ -18,6 +18,7 @@
package ast package ast
import ( import (
"fmt"
"gitlab.com/whom/shs/log" "gitlab.com/whom/shs/log"
) )
@ -64,7 +65,7 @@ func (f Function) ParseFunction(args *Token) bool {
total := len(f.Args) total := len(f.Args)
for iter := args; iter != nil; iter = iter.Next { for iter := args; iter != nil; iter = iter.Next {
total -= 1 total -= 1
if total <= 0 { if total < 0 {
log.Log(log.ERR, log.Log(log.ERR,
"too many arguments", "too many arguments",
"ftable") "ftable")
@ -80,6 +81,13 @@ func (f Function) ParseFunction(args *Token) bool {
} }
} }
if total > 0 {
log.Log(log.ERR,
"not enough args given",
"ftable")
return false
}
return true return true
} }
@ -127,13 +135,14 @@ func (f Function) CallFunction(args *Token, vt VarTable, ft FuncTable) *Token {
passes = f.ParseFunction(args) passes = f.ParseFunction(args)
} }
if passes { if !passes {
log.Log(log.ERR, log.Log(log.ERR,
"Couldnt call " + f.Name, "Couldnt call " + f.Name,
"eval") "eval")
return nil return nil
} }
fmt.Printf("ARGS: %+v", *args)
f.TimesCalled += 1 f.TimesCalled += 1
return f.Function(args, vt, ft) return f.Function(args, vt, ft)
} }

View file

@ -102,10 +102,8 @@ func GenFuncTable() ast.FuncTable {
Function: Export, Function: Export,
Name: "export", Name: "export",
EvalLazy: true, EvalLazy: true,
Args: []ast.Token_t{ ArgLazy: true,
ast.STRING, NumArgs: 2,
ast.LIST,
},
}, },
"input": &ast.Function{ "input": &ast.Function{