home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / compiler / 1264 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  2.3 KB

  1. Path: sparky!uunet!olivea!decwrl!decwrl!world!iecc!compilers-sender
  2. From: vern@horse.ee.lbl.gov (Vern Paxson)
  3. Newsgroups: comp.compilers
  4. Subject: Re: Using FLEX to do macro processing - enhancement to include ...
  5. Summary: use unput()
  6. Keywords: flex, macros
  7. Message-ID: <92-07-085@comp.compilers>
  8. Date: 24 Jul 92 05:35:51 GMT
  9. References: <92-07-077@comp.compilers>
  10. Sender: compilers-sender@iecc.cambridge.ma.us
  11. Reply-To: vern@horse.ee.lbl.gov (Vern Paxson)
  12. Organization: Lawrence Berkeley Laboratory, Berkeley
  13. Lines: 38
  14. Approved: compilers@iecc.cambridge.ma.us
  15.  
  16. cdh@world.std.com (Charles D Havener) writes:
  17. > Has there been any discussion about using FLEX to handle macro expansion
  18. > as opposed to just #include type processing as descriobed in the Flex
  19. > manual?
  20. > For example, can I use yy_create_buffer(FILE *file,int size) with a NIL
  21. > FILE * and merely unput() the macro text into this buffer?
  22.  
  23. This should work as long as you redefine YY_INPUT, too, to not try to read
  24. from yyin.  You could instead just use unput() directly with the current
  25. buffer (this is how flex itself expands {name} definitions).
  26.  
  27. > [Plain unput() might work, though I imagine it'd be more robust to
  28. > redefine YY_INPUT to copy in expanded text when it's reading from a
  29. > buffer corresponding to expanded text. -John]
  30.  
  31. I'm not sure what's meant here by "more robust".  The amount of text that
  32. can be pushed back will be limited to the amount of free space in the
  33. buffer.  Except for pathological cases, this will be at least 8KB, as the
  34. buffer is by default 16KB and is filled 8KB at a time.
  35.  
  36. In general it's hard solving this problem with YY_INPUT instead of
  37. unput(), because the scanner will have already loaded its internal buffer
  38. with quite a bit of data and will have to work its way through it before
  39. it gets around to calling YY_INPUT again.  If there are difficulties I'm
  40. missing with just using unput() I'd like to hear about them ...
  41.  
  42.         Vern
  43.  
  44.     Vern Paxson                vern@ee.lbl.gov
  45.     Computer Systems Engineering        ucbvax!ee.lbl.gov!vern
  46.     Lawrence Berkeley Laboratory        (510) 486-7504
  47. [Some PC versions of flex have a much smaller input buffer, on the order
  48. of 256 bytes, which won't always be enough unput space.  Agreed, with the
  49. standard 8K buffers unput is perfectly adequate. -John]
  50. -- 
  51. Send compilers articles to compilers@iecc.cambridge.ma.us or
  52. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  53.