parse.c
static void ParsePrint(ParseContext *c)
{
    ParseTreeNode *devExpr, *expr;
    int needNewline = VMTRUE;
    int tkn;

    /* check for file output */
    if ((tkn = GetToken(c)) == '#') {
        devExpr = ParseExpr(c);
        FRequire(c, ',');
    }
    
    /* handle terminal output */
    else {
        SaveToken(c, tkn);
        devExpr = NewParseTreeNode(c, NodeTypeIntegerLit);
        devExpr->u.integerLit.value = 0;
    }
    
    while ((tkn = GetToken(c)) != T_EOL) {
        switch (tkn) {
        case ',':
            needNewline = VMFALSE;
            AddNodeToList(c, &c->bptr->pNextStatement, BuildHandlerCall(c, "printTab", devExpr, NULL));
            break;
        case ';':
            needNewline = VMFALSE;
            break;
        case T_STRING:
            needNewline = VMTRUE;
            expr = NewParseTreeNode(c, NodeTypeStringLit);
            expr->u.stringLit.string = AddString(c, c->token);
            AddNodeToList(c, &c->bptr->pNextStatement, BuildHandlerCall(c, "printStr", devExpr, expr));
            break;
        default:
            needNewline = VMTRUE;
            SaveToken(c, tkn);
            expr = ParseExpr(c);
            AddNodeToList(c, &c->bptr->pNextStatement, BuildHandlerCall(c, "printInt", devExpr, expr));
            break;
        }
    }

    if (needNewline)
        AddNodeToList(c, &c->bptr->pNextStatement, BuildHandlerCall(c, "printNL", devExpr, NULL));
}
/* ParsePrint - handle the 'PRINT' statement */
handle the 'PRINT' statement
handle the ' PRINT ' statement
static void ParsePrint(ParseContext *c)
{
    ParseTreeNode *devExpr, *expr;
    int needNewline = VMTRUE;
    int tkn;
    if ((tkn = GetToken(c)) == '#') {
        devExpr = ParseExpr(c);
        FRequire(c, ',');
    }
    else {
        SaveToken(c, tkn);
        devExpr = NewParseTreeNode(c, NodeTypeIntegerLit);
        devExpr->u.integerLit.value = 0;
    }
    while ((tkn = GetToken(c)) != T_EOL) {
        switch (tkn) {
        case ',':
            needNewline = VMFALSE;
            AddNodeToList(c, &c->bptr->pNextStatement, BuildHandlerCall(c, "printTab", devExpr, NULL));
            break;
        case ';':
            needNewline = VMFALSE;
            break;
        case T_STRING:
            needNewline = VMTRUE;
            expr = NewParseTreeNode(c, NodeTypeStringLit);
            expr->u.stringLit.string = AddString(c, c->token);
            AddNodeToList(c, &c->bptr->pNextStatement, BuildHandlerCall(c, "printStr", devExpr, expr));
            break;
        default:
            needNewline = VMTRUE;
            SaveToken(c, tkn);
            expr = ParseExpr(c);
            AddNodeToList(c, &c->bptr->pNextStatement, BuildHandlerCall(c, "printInt", devExpr, expr));
            break;
        }
    }
    if (needNewline)
        AddNodeToList(c, &c->bptr->pNextStatement, BuildHandlerCall(c, "printNL", devExpr, NULL));
}
static void ParsePrint ( ParseContext * c ) { ParseTreeNode * devExpr , * expr ; int needNewline = VMTRUE ; int tkn ; if ( ( tkn = GetToken ( c ) ) == ' ' ) { devExpr = ParseExpr ( c ) ; FRequire ( c , ' ' ) ; } else { SaveToken ( c , tkn ) ; devExpr = NewParseTreeNode ( c , NodeTypeIntegerLit ) ; devExpr -> u . integerLit . value = 0 ; } while ( ( tkn = GetToken ( c ) ) != T_EOL ) { switch ( tkn ) { case ' ' : needNewline = VMFALSE ; AddNodeToList ( c , & c -> bptr -> pNextStatement , BuildHandlerCall ( c , " " , devExpr , NULL ) ) ; break ; case ' ' : needNewline = VMFALSE ; break ; case T_STRING : needNewline = VMTRUE ; expr = NewParseTreeNode ( c , NodeTypeStringLit ) ; expr -> u . stringLit . string = AddString ( c , c -> token ) ; AddNodeToList ( c , & c -> bptr -> pNextStatement , BuildHandlerCall ( c , " " , devExpr , expr ) ) ; break ; default : needNewline = VMTRUE ; SaveToken ( c , tkn ) ; expr = ParseExpr ( c ) ; AddNodeToList ( c , & c -> bptr -> pNextStatement , BuildHandlerCall ( c , " " , devExpr , expr ) ) ; break ; } } if ( needNewline ) AddNodeToList ( c , & c -> bptr -> pNextStatement , BuildHandlerCall ( c , " " , devExpr , NULL ) ) ; }
ParsePrint - handle the 'PRINT' statement
ParsePrint - handle the ' PRINT ' statement
/* check for file output */ /* handle terminal output */