G_PARSE(2) Demeter Software G_PARSE(2) NAME g_parse - send the generic parse message to an object. SYNOPSIS Universal* Universal:: _g__p_a_r_s_e ( char* filename ) DESCRIPTION _g__p_a_r_s_e parses in the text contained in file _f_i_l_e_n_a_m_e and produces an object of the class of the object to which the message was sent. Or, if the text in _f_i_l_e_n_a_m_e does not describe a legal object, then an error output is produced and the program is aborted. _g__p_a_r_s_e is a generic method implemented at class Universal and inherited by any user class. RETURN VALUES _g__p_a_r_s_e returns an object of the class of the object to which the message was sent. However, the type returned by _g__p_a_r_s_e is _U_n_i_v_e_r_s_a_l*, since _g__p_a_r_s_e does not know in advance to what class the message is going to be sent. Therefore, the value returned must be cast to the appropri- ate type before it can be assigned or used in any way. For example: Compound* iCompound = new Compound(); iCompound = (Compound*)iCompound->g_parse("demeter-input"); If _g__p_a_r_s_e finds an error, i.e., the input text in _f_i_l_e_n_a_m_e does not represent a legal object of the class of the object to which the message was sent, _g__p_a_r_s_e returns the NULL con- stant. Thus, it is recommendable to check for the return value before using it. ERROR MESSAGES If the input text in _f_i_l_e_n_a_m_e does not represent a legal object of the class of the object to which the message was sent, _g__p_a_r_s_e produces as output three error messages: Error An explanation of the error, along with the line in _f_i_l_e_n_a_m_e where it occurred. Current token The token in _f_i_l_e_n_a_m_e that caused the error is printed along with up to the following 10 tokens. Production stack dump A listing, in reverse order, of the productions in the grammar that led to the point where the error Demeter Last change: 8 April 1991 1 G_PARSE(2) Demeter Software G_PARSE(2) occurred. MODIFYING THE CONCRETE SYNTAX The file _c_d-_p_a_r_s_e, created by Demeter from the class dic- tionary at generation time, contains the grammar the generic parser uses in parsing the text in the input file. In this file the user can modify the concrete syntax (constant strings appearing in the specifications of productions) to change the appearance of input sentences. After modifying _c_d-_p_a_r_s_e, the user needs to rerun _g_e_n-_s_c_a_n_n_e_r and to recom- pile the program to make the modification effective. FILES demeter-input cd-parse SEE ALSO gen-scanner(1), universal(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: 8 April 1991 2