// Print Object Function for CS 51 Introduction to C // // File: print_object.cc // Author: () // Assignment: c // This file contains the print object function for // programming the CS 51 LISP assignments in C++. #include "intro51.h" // Pseudo-code: // // if ob == NULL then print "NULL" // else if ob->type is SYMBOL then print ob->name; // else if ob->type is INTEGER then print ob->value; // else if ob->type is CONS then // { // print "(" // print_object ob->car // while ( ob->cdr is a CONS ) // { // print " " // set ob = ob->cdr // print_object ob->car // } // if ( ob->cdr is not NIL ) // { // print " " // print "." // print " " // print_object ob->cdr // } // print ")" // else print "BAD OBJECT" // } ostream & operator << ( ostream & s, object * ob ) { if ( ob == NULL ) s << "NULL"; else if ( ob->type == SYMBOL ) s << ob->name; else if ( ob->type == INTEGER ) s << ob->value; else if ( ob->type == CONS ) { // Replace this line with your code. } else s << "BAD OBJECT"; return s; }