private Function funcDecl() throws Exception
    {
        Function rval = new Function();
        currentFunction = rval;
        currentBB = new BasicBlock(null);
        currentJoinBlock = null;
        rval.entryPoint = currentBB;
        env.enter();
        if(!(scan.sym == Token.function || scan.sym == Token.procedure)) {
            throw new Exception("Function declaration: incorrect keyword");
        }
        // sym matches function or procedure
        scan.next();
        rval.name = ident();
        if(scan.sym != Token.semicolon) {
            formalParam();
        }
        // still need to look for this since formalParam may have
        // parsed successfully, but there could still be a syntax
        // error if no ';'
        if(scan.sym == Token.semicolon) {
            scan.next();
            funcBody();
            if(scan.sym == Token.semicolon) {
                scan.next();
                env.exit();
                return rval;
            } else {
                throw new Exception("Function declaration: no ';' after function body");
            }
        } else {
            throw new Exception("Function declaration: no ';' after formal parameters");
        }
    }