src/visit.c
double visit_print(ast_t* node) {

    msg(2, "Visit %s AST node", NT_TOSTR(node->type));
    if(node != NULL) {
        //node_type_t type = node->type;
        double val;
        if(node->left != NULL)
            val = node->left->visit(node->left);
        else {
            error("invalid print child node");
            return NAN;
        }
        switch(node->value.op->op) {
            case PRINT_OP:
                //printf("%0.3f\n", val);
                return val;
            default:
                error("invalid print node type: %s", OP_TOSTR(node->value.op->op));
                return NAN;
        }
    }
    else {
        error("invalid print node");
        return NAN; // not a number
    }

    return NAN; // unreachable
}
/*
 * Perform a unary operation where the operation is "print". This traverses the
 * tree to obtain the value to print out.
 */
Perform a unary operation where the operation is "print". This traverses the
tree to obtain the value to print out.
Perform a unary operation where the operation is " print " . This traverses the tree to obtain the value to print out .
double visit_print(ast_t* node) {
    msg(2, "Visit %s AST node", NT_TOSTR(node->type));
    if(node != NULL) {
        double val;
        if(node->left != NULL)
            val = node->left->visit(node->left);
        else {
            error("invalid print child node");
            return NAN;
        }
        switch(node->value.op->op) {
            case PRINT_OP:
                return val;
            default:
                error("invalid print node type: %s", OP_TOSTR(node->value.op->op));
                return NAN;
        }
    }
    else {
        error("invalid print node");
        return NAN; 
    }
    return NAN; 
}
double visit_print ( ast_t * node ) { msg ( 2 , " " , NT_TOSTR ( node -> type ) ) ; if ( node != NULL ) { double val ; if ( node -> left != NULL ) val = node -> left -> visit ( node -> left ) ; else { error ( " " ) ; return NAN ; } switch ( node -> value . op -> op ) { case PRINT_OP : return val ; default : error ( " " , OP_TOSTR ( node -> value . op -> op ) ) ; return NAN ; } } else { error ( " " ) ; return NAN ; } return NAN ; }
Perform a unary operation where the operation is "print".
Perform a unary operation where the operation is " print " .
//node_type_t type = node->type; //printf("%0.3f\n", val); // not a number // unreachable