flex.patch 2.8 KB

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