Re: Buffered input for a lexer?

Ray Dillinger <bear@sonic.net>
10 Apr 2002 00:13:47 -0400

          From comp.compilers

Related articles
[7 earlier articles]
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)
Re: Buffered input for a lexer? cgweav@aol.com (2002-04-17)
Re: Buffered input for a lexer? rhyde@cs.ucr.edu (Randall Hyde) (2002-04-19)
Re: Buffered input for a lexer? monnier+comp.compilers/news/@RUM.cs.yale.edu (Stefan Monnier) (2002-04-19)
[4 later articles]
| List of all articles for this month |

From: Ray Dillinger <bear@sonic.net>
Newsgroups: comp.compilers
Date: 10 Apr 2002 00:13:47 -0400
Organization: Compilers Central
References: 02-03-171 02-03-183
Keywords: lex, practice
Posted-Date: 10 Apr 2002 00:13:47 EDT

Clayton Weaver wrote:
>
> Files not terminated with newlines are rare, right? Just put one
> there.
>
> Ie, if the source file and directory are writable for your process,
> truncate the file out 1 byte and add a newline. If the source files
> are read-only, copy it to a temp directory and add the newline, then
> operate on the copy of the source file.


I object. It is not the place of the compiler to modify the source
file unless the programmer specifically tells it to. And if that were
to happen, it should be clear that there is something profoundly weird
going on.


In the case where the compiler modifies the source file, bizarre
things can happen because the "modification date", on which such basic
utilities as make and RCS rely, can get altered unexpectedly.


Programmers rely on the last-modified dates of our files to tell us
which things we worked on in which session, and unexpected
modifications can mess us up. Many of us also have written utility
scripts that use "diff", relying on the complete absence of output
from unmodified sources.


And just incidentally, I have *LOTS* of text files (including source
code) on my system that don't end with a newline character. It's not
rare at all.


Bear
[I think someone reasonably suggested to map the file in, and if it
doesn't end with \n just make an in-memory copy of the last page and
put a newline at the end of it. -John]





Post a followup to this message

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