Re: Buffered input for a lexer?

Joachim Durchholz <joachim_d@gmx.de>
31 Mar 2002 23:21:19 -0500

          From comp.compilers

Related articles
[4 earlier articles]
Re: Buffered input for a lexer? sabre@nondot.org (Chris Lattner) (2002-03-24)
Re: Buffered input for a lexer? rhyde@cs.ucr.edu (Randall Hyde) (2002-03-25)
Re: Buffered input for a lexer? cfc@world.std.com (Chris F Clark) (2002-03-25)
Re: Buffered input for a lexer? clint@0lsen.net (2002-03-31)
Re: Buffered input for a lexer? sabre@nondot.org (Chris Lattner) (2002-03-31)
Re: Buffered input for a lexer? sabre@nondot.org (Chris Lattner) (2002-03-31)
Re: Buffered input for a lexer? joachim_d@gmx.de (Joachim Durchholz) (2002-03-31)
Re: Buffered input for a lexer? cgweav@aol.com (2002-03-31)
Re: Buffered input for a lexer? bear@sonic.net (Ray Dillinger) (2002-04-10)
Re: Buffered input for a lexer? bear@sonic.net (Ray Dillinger) (2002-04-10)
Re: Buffered input for a lexer? cgweav@aol.com (2002-04-13)
Re: Buffered input for a lexer? ralph@inputplus.co.uk (2002-04-16)
Re: Buffered input for a lexer? joachim_d@gmx.de (Joachim Durchholz) (2002-04-16)
[7 later articles]
| List of all articles for this month |

From: Joachim Durchholz <joachim_d@gmx.de>
Newsgroups: comp.compilers
Date: 31 Mar 2002 23:21:19 -0500
Organization: Compilers Central
References: 02-03-162 02-03-171
Keywords: lex, practice
Posted-Date: 31 Mar 2002 23:21:19 EST

Randall Hyde wrote:
> Like GCC and a few other compilers, I require that the source file end
> with a newline (actually, any whitespace or single character lexeme
> would be fine, but I explicitly check for a newline after mapping the
> file and warn the user if one isn't present (*). If a newline is
> present, then I don't have to check for the end of the buffer except
> when scanning whitespace.


Is there a deep reason for doing it this way? I mean, it wouldn't be
too difficult to check for end-of-file. Just let the routine that gets
the next character check whether it's past EOF, in which case it
returns a line feed. (Or a special EOF character that's handled mostly
like a line feed, except that it also ends the scanning process.) If
you're doing memory-mapped IO, the EOF check is just a pointer
comparison.


So: what did I overlook?


Regards,
Joachim


Post a followup to this message

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