parse.c
static void ParseFor(ParseContext *c)
{
    ParseTreeNode *node = NewParseTreeNode(c, NodeTypeForStatement);
    int tkn;

    AddNodeToList(c, &c->bptr->pNextStatement, node);

    PushBlock(c, BLOCK_FOR, node);
    c->bptr->pNextStatement = &node->u.forStatement.bodyStatements;

    /* get the control variable */
    FRequire(c, T_IDENTIFIER);
    node->u.forStatement.var = GetSymbolRef(c, c->token);

    /* parse the starting value expression */
    FRequire(c, '=');
    node->u.forStatement.startExpr = ParseExpr(c);

    /* parse the TO expression and generate the loop termination test */
    FRequire(c, T_TO);
    node->u.forStatement.endExpr = ParseExpr(c);

    /* get the STEP expression */
    if ((tkn = GetToken(c)) == T_STEP) {
        node->u.forStatement.stepExpr = ParseExpr(c);
        tkn = GetToken(c);
    }
    Require(c, tkn, T_EOL);
}
/* ParseFor - parse the 'FOR' statement */
parse the 'FOR' statement
parse the ' FOR ' statement
static void ParseFor(ParseContext *c)
{
    ParseTreeNode *node = NewParseTreeNode(c, NodeTypeForStatement);
    int tkn;
    AddNodeToList(c, &c->bptr->pNextStatement, node);
    PushBlock(c, BLOCK_FOR, node);
    c->bptr->pNextStatement = &node->u.forStatement.bodyStatements;
    FRequire(c, T_IDENTIFIER);
    node->u.forStatement.var = GetSymbolRef(c, c->token);
    FRequire(c, '=');
    node->u.forStatement.startExpr = ParseExpr(c);
    FRequire(c, T_TO);
    node->u.forStatement.endExpr = ParseExpr(c);
    if ((tkn = GetToken(c)) == T_STEP) {
        node->u.forStatement.stepExpr = ParseExpr(c);
        tkn = GetToken(c);
    }
    Require(c, tkn, T_EOL);
}
static void ParseFor ( ParseContext * c ) { ParseTreeNode * node = NewParseTreeNode ( c , NodeTypeForStatement ) ; int tkn ; AddNodeToList ( c , & c -> bptr -> pNextStatement , node ) ; PushBlock ( c , BLOCK_FOR , node ) ; c -> bptr -> pNextStatement = & node -> u . forStatement . bodyStatements ; FRequire ( c , T_IDENTIFIER ) ; node -> u . forStatement . var = GetSymbolRef ( c , c -> token ) ; FRequire ( c , ' ' ) ; node -> u . forStatement . startExpr = ParseExpr ( c ) ; FRequire ( c , T_TO ) ; node -> u . forStatement . endExpr = ParseExpr ( c ) ; if ( ( tkn = GetToken ( c ) ) == T_STEP ) { node -> u . forStatement . stepExpr = ParseExpr ( c ) ; tkn = GetToken ( c ) ; } Require ( c , tkn , T_EOL ) ; }
ParseFor - parse the 'FOR' statement
ParseFor - parse the ' FOR ' statement
/* get the control variable */ /* parse the starting value expression */ /* parse the TO expression and generate the loop termination test */ /* get the STEP expression */