syncing unfinished work with dev
This commit is contained in:
parent
4ce1f7137c
commit
6afd01da2a
2 changed files with 14 additions and 7 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue