From rse@en1.engelschall.com Wed Jul 3 10:25:57 2002 Date: Wed, 3 Jul 2002 10:25:57 +0200 From: "Ralf S. Engelschall" To: help-flex@gnu.org Cc: john43@astro.temple.edu Subject: [PATCH] YYLTYPE, yy[gs]et_lloc, -P Message-ID: <20020703082557.GA68291@engelschall.com> Reply-To: rse@engelschall.com References: <20011106161709.A67206@engelschall.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20011106161709.A67206@engelschall.com> User-Agent: Mutt/1.4i Organization: Engelschall, Germany. X-Web-Homepage: http://www.engelschall.com/ X-PGP-Public-Key: http://www.engelschall.com/ho/rse/pgprse.asc X-PGP-Fingerprint: 00 C9 21 8E D1 AB 70 37 DD 67 A2 3A 0A 6F 8D A5 Status: RO Content-Length: 2064 Lines: 52 [the following was already reported in November 2001 for Flex 2.5.6-developer-2001-11-01, but the bug is still present in Flex 2.5.8] Just a little thing I've recognized while hacking on a scanner which is generated by flex-2.5.8: Although I used "flex ... -Pl2_spec_ ..." the generated object file still has two "yy"-prefixed symbols: | :> nm -g l2_spec_scan.o | grep yy | 00000c04 T yyget_lloc | 00000c10 T yyset_lloc This is because at the top of the generated l2_spec_scan.c there is: | #ifdef YYLTYPE | #define yyget_lloc l2_spec_get_lloc | #define yyset_lloc l2_spec_set_lloc | #endif Unfortunately the YYLTYPE will _never_ be defined at this point, because it is defined by the parser and the parsers' include file can be included only in %{ ..%} sections, which in turn are inserted in the generated code always _after_ the above sequence. It certainly is not correct to change the position of inserting the %{...%} sections, of course. But we can just leave out the #ifdef..#endif, because even if YYLTYPE is not used (no location tracking is used) or not defined, the extra namespace-preserving definitions of yy[gs]et_lloc will not hurt. So, I recommend to apply the following patch to Flex 2.5.8 and hope it is finally considered for inclusion into forthcoming versions: ================================================================= --- main.c.orig Wed Jun 19 15:26:44 2002 +++ main.c Wed Jul 3 10:12:43 2002 @@ -384,10 +384,8 @@ outn( "#ifdef YY_REENTRANT_BISON_PURE" ); GEN_PREFIX( "get_lval" ); GEN_PREFIX( "set_lval" ); - outn( "#ifdef YYLTYPE" ); GEN_PREFIX( "get_lloc" ); GEN_PREFIX( "set_lloc" ); - outn( "#endif" ); outn( "#endif" ); if ( do_yylineno && reentrant) ================================================================= Yours, Ralf S. Engelschall rse@engelschall.com www.engelschall.com