parse.c
static void ParseFunction(ParseContext *c)
{
    ParseTreeNode *function;
    Symbol *symbol;
    int tkn;

    if (c->currentFunction != c->mainFunction)
        ParseError(c, "nested function definitions not supported");
    else if (c->bptr->type != BLOCK_FUNCTION)
        ParseError(c, "function definition not allowed in another block");
        
    /* get the function name */
    FRequire(c, T_IDENTIFIER);

    /* enter the function name in the global symbol table */
    if (!(symbol = FindGlobal(c, c->token)))
        symbol = AddGlobal(c, c->token, SC_FUNCTION, &c->integerFunctionType, 0);
    else {
        if (symbol->storageClass != SC_FUNCTION || symbol->type != &c->integerFunctionType || symbol->placed)
            ParseError(c, "invalid definition of a forward referenced function");
    }
    
    /* create the function node */
    function = StartFunction(c, symbol);

    /* get the argument list */
    if ((tkn = GetToken(c)) == '(') {
        if ((tkn = GetToken(c)) != ')') {
            SaveToken(c, tkn);
            do {
                FRequire(c, T_IDENTIFIER);
                AddArgument(c, c->token, SC_VARIABLE, &c->integerType, function->u.functionDefinition.argumentOffset);
                ++function->u.functionDefinition.argumentOffset;
            } while ((tkn = GetToken(c)) == ',');
        }
        Require(c, tkn, ')');
    }
    else
        SaveToken(c, tkn);

    FRequire(c, T_EOL);
}
/* ParseFunction - parse the 'FUNCTION' statement */
parse the 'FUNCTION' statement
parse the ' FUNCTION ' statement
static void ParseFunction(ParseContext *c)
{
    ParseTreeNode *function;
    Symbol *symbol;
    int tkn;
    if (c->currentFunction != c->mainFunction)
        ParseError(c, "nested function definitions not supported");
    else if (c->bptr->type != BLOCK_FUNCTION)
        ParseError(c, "function definition not allowed in another block");
    FRequire(c, T_IDENTIFIER);
    if (!(symbol = FindGlobal(c, c->token)))
        symbol = AddGlobal(c, c->token, SC_FUNCTION, &c->integerFunctionType, 0);
    else {
        if (symbol->storageClass != SC_FUNCTION || symbol->type != &c->integerFunctionType || symbol->placed)
            ParseError(c, "invalid definition of a forward referenced function");
    }
    function = StartFunction(c, symbol);
    if ((tkn = GetToken(c)) == '(') {
        if ((tkn = GetToken(c)) != ')') {
            SaveToken(c, tkn);
            do {
                FRequire(c, T_IDENTIFIER);
                AddArgument(c, c->token, SC_VARIABLE, &c->integerType, function->u.functionDefinition.argumentOffset);
                ++function->u.functionDefinition.argumentOffset;
            } while ((tkn = GetToken(c)) == ',');
        }
        Require(c, tkn, ')');
    }
    else
        SaveToken(c, tkn);
    FRequire(c, T_EOL);
}
static void ParseFunction ( ParseContext * c ) { ParseTreeNode * function ; Symbol * symbol ; int tkn ; if ( c -> currentFunction != c -> mainFunction ) ParseError ( c , " " ) ; else if ( c -> bptr -> type != BLOCK_FUNCTION ) ParseError ( c , " " ) ; FRequire ( c , T_IDENTIFIER ) ; if ( ! ( symbol = FindGlobal ( c , c -> token ) ) ) symbol = AddGlobal ( c , c -> token , SC_FUNCTION , & c -> integerFunctionType , 0 ) ; else { if ( symbol -> storageClass != SC_FUNCTION || symbol -> type != & c -> integerFunctionType || symbol -> placed ) ParseError ( c , " " ) ; } function = StartFunction ( c , symbol ) ; if ( ( tkn = GetToken ( c ) ) == ' ' ) { if ( ( tkn = GetToken ( c ) ) != ' ' ) { SaveToken ( c , tkn ) ; do { FRequire ( c , T_IDENTIFIER ) ; AddArgument ( c , c -> token , SC_VARIABLE , & c -> integerType , function -> u . functionDefinition . argumentOffset ) ; ++ function -> u . functionDefinition . argumentOffset ; } while ( ( tkn = GetToken ( c ) ) == ' ' ) ; } Require ( c , tkn , ' ' ) ; } else SaveToken ( c , tkn ) ; FRequire ( c , T_EOL ) ; }
ParseFunction - parse the 'FUNCTION' statement
ParseFunction - parse the ' FUNCTION ' statement
/* get the function name */ /* enter the function name in the global symbol table */ /* create the function node */ /* get the argument list */