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
import (
"fmt"
"gitlab.com/whom/shs/log"
)
@ -64,7 +65,7 @@ func (f Function) ParseFunction(args *Token) bool {
total := len(f.Args)
for iter := args; iter != nil; iter = iter.Next {
total -= 1
if total <= 0 {
if total < 0 {
log.Log(log.ERR,
"too many arguments",
"ftable")
@ -74,12 +75,19 @@ func (f Function) ParseFunction(args *Token) bool {
if iter.Tag != f.Args[len(f.Args) - total] {
log.Log(log.ERR,
"argument is " + GetTagAsStr(iter.Tag) +
"should be " + GetTagAsStr(f.Args[len(f.Args) - total]),
" should be " + GetTagAsStr(f.Args[len(f.Args) - total]),
"ftable")
return false
}
}
if total > 0 {
log.Log(log.ERR,
"not enough args given",
"ftable")
return false
}
return true
}
@ -127,13 +135,14 @@ func (f Function) CallFunction(args *Token, vt VarTable, ft FuncTable) *Token {
passes = f.ParseFunction(args)
}
if passes {
if !passes {
log.Log(log.ERR,
"Couldnt call " + f.Name,
"eval")
return nil
}
fmt.Printf("ARGS: %+v", *args)
f.TimesCalled += 1
return f.Function(args, vt, ft)
}

View file

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