+void *Parse_FunctionDefinition(tAST_Script *Script, tSpiderVariant *Variant, tParser *Parser, int Type)
+{
+ tAST_Function *fcn;
+ char *name;
+ int type;
+
+ SyntaxAssert(Parser, GetToken(Parser), TOK_IDENT );
+
+ name = strndup( Parser->TokenStr, Parser->TokenLen );
+ fcn = AST_AppendFunction( Script, name, Type );
+ #if DEBUG
+ printf("DefFCN %s\n", name);
+ #endif
+ free(name);
+
+ // Get arguments
+ SyntaxAssert(Parser, GetToken(Parser), TOK_PAREN_OPEN );
+ if( LookAhead(Parser) != TOK_PAREN_CLOSE )
+ {
+ do {
+ type = SS_DATATYPE_DYNAMIC;
+ GetToken(Parser);
+ // Non dynamic typed variants must use data types
+ if( !Variant->bDyamicTyped ) {
+ TOKEN_GET_DATATYPE(type, Parser->Token);
+ GetToken(Parser);
+ }
+ AST_AppendFunctionArg(fcn, Parse_GetVarDef(Parser, type));
+ } while(GetToken(Parser) == TOK_COMMA);
+ }
+ else
+ GetToken(Parser);
+ SyntaxAssert(Parser, Parser->Token, TOK_PAREN_CLOSE );
+
+ AST_SetFunctionCode( fcn, Parse_DoCodeBlock(Parser) );
+
+ return fcn;
+}
+