G_DISPLAYASTREE(2) Demeter Software G_DISPLAYASTREE(2) NAME g_displayAsTree - displays a tree object in object graph notation. SYNOPSIS void _g__d_i_s_p_l_a_y_A_s_T_r_e_e ( ostream& strm = cout ) DESCRIPTION _g__d_i_s_p_l_a_y_A_s_T_r_e_e displays a detailed description of an object using the object graph notation. If the _s_t_r_m argument is provided, then the output is sent to the ostream in the given .I strm, otherwise the output is sent to the standard output. The object must be a tree object. That is, it cannot have any cycles or shared subobjects. The class of the object is displayed preceded by a colon, and followed by an open delimiter, the description of the compo- sition of the object, and a close delimiter. If the class of the object is a construction class the open and close delim- iters are "(" and ")", respectively, and the composition of the object is a number of part objects. If the class of the object is a repetition class the open and close delimiters are "{" and "}", respectively, and the composition of the object is a sequence of repeated element objects. Each part object or repeated element object is in turn displayed in object graph format in a similar fashion. Each part object is preceded by a label indicating the name of the part in the class dictionary that defines the object that contains the part. If the class of the object is a terminal class (i.e., Ident, Number, Real, String, or Text), then no delim- iters are displayed and the composition of the object is simply a quoted value. EXAMPLE Here is an example of how to use _g__d_i_s_p_l_a_y_A_s_T_r_e_e. Assume the following class dictionary. Example = List(Prefix). Prefix : Simple | Compound. Simple = Number. Compound = "(" Op List(Prefix) ")". Op : AddSym | MulSym. AddSym = "+". MulSym = "*". List(S) ~ S { S }. The following program parses in a Compound object and displays it as a tree object. Demeter Last change: 27 February 1992 1 G_DISPLAYASTREE(2) Demeter Software G_DISPLAYASTREE(2) Compound* iCompound = new Compound(); iCompound = (Compound*)iCompound->g_parse("demeter-input"); ostream outFile( "compound-object-graph" ); iCompound->g_displayAsTree( outFile ); If the contents of demeter-input is (* (+ 3 4) 3), then the following text is written to the file compound-object-graph. An example of an object graph is as follows: : Compound ( < op > : MulSym ( ) < args > : Prefix_List { : Compound ( < op > : AddSym ( ) < args > : Prefix_List { : Simple ( < val > : Number "3" ) , : Simple ( < val > : Number "4" ) } ) , : Simple ( < val > : Number "3" ) } ) If no argument had been given, then the description is sent to the standard output. SEE ALSO g_parse(2) REFERENCES _U_s_e_r _M_a_n_u_a_l _f_o_r _T_h_e _C++ _D_e_m_e_t_e_r Walter L. Hursch Northeastern University, 1993 _T_h_e _A_n_n_o_t_a_t_e_d _C++ _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l Margaret A. Ellis and Bjarne Stroustrup Addison-Wesley, 1990 _C++ _P_r_i_m_e_r Stanley B. Lippman Addison-Wesley, 1989 Demeter Last change: 27 February 1992 2