func (c *Compiler) parseFunctionCall(out bool, name string) string { output := "" c.expect("(") paramsStr, paramCount := c.parseParameter(false) c.expect(")") // buildin function buildin := types.GetFunction(name) if buildin != nil { if buildin.Type == types.NULL { output = name } else if buildin.Type == types.UNARY { output = c.parseUnaryFunction(name, paramsStr, paramCount) } else { output = c.parseBinaryFunction(name, paramsStr, buildin, paramCount) } } else { output = "[" + paramsStr + "] call " + name } if out { c.appendOut(output, false) } return output }
func TestTypesGetFunction(t *testing.T) { if err := types.LoadTypes("../../test/types"); err != nil { t.Error(err) } function := types.GetFunction("hint") if function == nil { t.Error("Function 'hint' not found in type list") } }
func (c *Compiler) parseFunction() { c.expect("func") // check for build in function if buildin := types.GetFunction(c.get().Token); buildin != nil { panic(errors.New(c.get().Token + " is a build in function, choose a different name")) } c.appendOut(c.get().Token+" = {", true) c.next() c.expect("(") c.parseFunctionParameter() c.expect(")") c.expect("{") c.parseBlock() c.expect("}") c.appendOut("};", true) }