prototype repl

This commit is contained in:
Aidan 2020-06-21 01:30:54 -07:00
parent 30481d4f78
commit c40aea7326
No known key found for this signature in database
GPG key ID: 327711E983899316
7 changed files with 233 additions and 35 deletions

View file

@ -21,6 +21,7 @@ type Operation func(*Token) *Token
type Function struct {
function Operation
name string
timesCalled int
args int // TODO: Make this a list of expected types (TAGs)
}
@ -40,7 +41,9 @@ func (f Function) ParseFunction(args *Token) bool {
}
if i != 0 {
// TODO: log error here
log.Log(log.ERR,
"Incorrect number of arguments",
"eval")
return false
}
@ -49,6 +52,9 @@ func (f Function) ParseFunction(args *Token) bool {
func (f Function) CallFunction(args *Token) *Token {
if !f.ParseFunction(args) {
log.Log(log.Err,
"Couldnt call " + f.name,
"eval")
return nil
}
@ -59,6 +65,9 @@ func (f Function) CallFunction(args *Token) *Token {
func (table FuncTable) GetFunction(arg string) *Function {
target, ok := table[arg]
if !ok {
log.Log(log.DEBUG,
"function " + arg + " not found",
"eval")
return nil
}