Re: Input buffer overflow in lex...

vern@daffy.ee.lbl.gov (Vern Paxson)
Tue, 5 Jan 1993 18:30:07 GMT

          From comp.compilers

Related articles
Input buffer overflow in lex przemek@viewlogic.com (1993-01-04)
Re: Input buffer overflow in lex... johnl@iecc.cambridge.ma.us (John R. Levine) (1993-01-05)
Re: Input buffer overflow in lex... vern@daffy.ee.lbl.gov (1993-01-05)
Re: Input buffer overflow in lex... richw@sol.camb.inmet.com (1993-01-06)
Re: Input buffer overflow in lex... finger@convex.com (1993-01-08)
| List of all articles for this month |
Newsgroups: comp.compilers
From: vern@daffy.ee.lbl.gov (Vern Paxson)
Organization: Lawrence Berkeley Laboratory, Berkeley CA
Date: Tue, 5 Jan 1993 18:30:07 GMT
Keywords: lex
References: 93-01-009 93-01-010

John R. Levine <johnl@iecc.cambridge.ma.us> writes:
> Well, the short answer is that you lose. No version of lex checks for
> token buffer overflow, although it is less destructive in flex than it is
> in lex. This can be called a lex design error, though it's hard to
> check for overflow without making the lexer a lot slower.


Let me clarify a bit. flex does detect token buffer overflow and
generates a fatal run-time error when it occurs. It can do so cheaply
because such overflow can only occur when new characters are being read
into the input buffer. That's a rare operation in a flex scanner because
input is block-oriented.


> The other possibility is to use start states to build the string
> yourself:


Hear hear! This is in general a much better approach, as it also provides
a natural way to deal with escape sequences and continued strings.


Vern


Vern Paxson vern@ee.lbl.gov
Systems Engineering ucbvax!ee.lbl.gov!vern
Lawrence Berkeley Laboratory (510) 486-7504
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.