prototype repl
This commit is contained in:
parent
30481d4f78
commit
c40aea7326
7 changed files with 233 additions and 35 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue