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