.TH G_PARSE 2 "8 April 1991" "Demeter" "Demeter Software" .SH NAME g_parse \- send the generic parse message to an object. .SH SYNOPSIS Universal* Universal:: .I g_parse ( char* filename ) .SH DESCRIPTION .I g_parse parses in the text contained in file .I filename and produces an object of the class of the object to which the message was sent. Or, if the text in .I filename does not describe a legal object, then an error output is produced and the program is aborted. .I g_parse is a generic method implemented at class Universal and inherited by any user class. .SH RETURN VALUES .I g_parse returns an object of the class of the object to which the message was sent. However, the type returned by .I g_parse is .I Universal*, since .I g_parse does not know in advance to what class the message is going to be sent. Therefore, the value returned must be cast to the appropriate type before it can be assigned or used in any way. For example: Compound* iCompound = new Compound(); .br iCompound = (Compound*)iCompound->g_parse("demeter-input"); If .I g_parse finds an error, i.e., the input text in .I filename does not represent a legal object of the class of the object to which the message was sent, .I g_parse returns the NULL constant. Thus, it is recommendable to check for the return value before using it. .SH ERROR MESSAGES If the input text in .I filename does not represent a legal object of the class of the object to which the message was sent, .I g_parse produces as output three error messages: .TP 10 Error An explanation of the error, along with the line in .I filename where it occurred. .TP Current token The token in .I filename that caused the error is printed along with up to the following 10 tokens. .TP Production stack dump A listing, in reverse order, of the productions in the grammar that led to the point where the error occurred. .LP .SH MODIFYING THE CONCRETE SYNTAX The file .I cd-parse, created by Demeter from the class dictionary 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 .I cd-parse, the user needs to rerun .I gen-scanner and to recompile the program to make the modification effective. .SH FILES demeter-input .br cd-parse .SH SEE ALSO gen-scanner(1), universal(2) .SH REFERENCES .I User Manual for The C++ Demeter System .br Walter L. Hursch .br Northeastern University, 1993 .I The Annotated C++ Reference Manual .br Margaret A. Ellis and Bjarne Stroustrup .br Addison-Wesley, 1990 .I C++ Primer .br Stanley B. Lippman .br Addison-Wesley, 1989