From: William F. D. <wil...@th...> - 2005-02-15 15:48:29
|
On Tue, 2005-02-15 at 02:26, Martin Quinson wrote: > On Mon, Jan 24, 2005 at 05:06:27PM -0500, Dowling, William (Will) (TS USA) wrote: > > One limitation of the flexml-generated parser is that its prototype is > > fixed within flexml: > > int yylex() > > In order to pass in a parameter to the generated parser, I had to resort > > to a flex command line that contained this (I am generating C++ code, > > hence the class declaration) > > > > -PLinksXML \ > > -DYY_DECL='"class LinksAPIStart; static LinksAPIStart * > > private_Start_ptr; int LinksXMLlex(LinksAPIStart *LinksAPIStart_ptr)"' \ > > -DYY_USER_INIT='"private_Start_ptr=LinksAPIStart_ptr;"' > > > > This trick allows me to refer to the parameter passed into the parser > > (LinksAPIStart_ptr) using the name private_Start_ptr in my .act file. > > [...] > > [...] we also want to embeed several parsers in the same > code, and that I was thinking about implementing the -P flag to flexml. > > It does not look really related to your issue [...] I think it is somewhat related; -P allows you to change the name of the generated parser, as does modifying YY_DECL. (-P also privatizes other identifiers, which YY_DECL does not.) YY_DECL also allows you to change the signature (params and return type), which -P does not. This part of the design of flex is not as orthogonal as it could be. Maybe a YY_DECL (and other user-settable #defines) should be passed through from flexml into the generated flex input file? Will -- William F. Dowling Thomson/ISI (www.thomsonisi.com) 215-386-0100 x-1156 ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |