Re: Buffered input for a lexer?

cgweav@aol.com (Clayton Weaver)
13 Apr 2002 23:08:20 -0400

          From comp.compilers

Related articles
[8 earlier articles]
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)
Re: Buffered input for a lexer? rhyde@cs.ucr.edu (Randall Hyde) (2002-04-20)
[3 later articles]
| List of all articles for this month |
From: cgweav@aol.com (Clayton Weaver)
Newsgroups: comp.compilers
Date: 13 Apr 2002 23:08:20 -0400
Organization: AOL http://www.aol.com
References: 02-04-061
Keywords: lex, practice
Posted-Date: 13 Apr 2002 23:08:20 EDT

>I object. It is not the place of the compiler to modify the source
>file unless the programmer specifically tells it to.


Fair enough. Like others have pointed out, it is only the question of
whether the in-core image of the source that the lexer is working on
is newline-terminated that matters to Hyde's lexer.


>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.


I noticed patch (2.5 IIRC) complaining about something like this when
I hand-modified a big glibc patch to only get the parts that I
needed. I clipped one patch just before instead of just after the last
newline in it, and patch howled about a partial line at the end of the
patch. (This was a context line, and maybe it was just complaining
about an "incomplete line in the context" rather than a missing
newline at the end of the diff.)


I've recently seen something else complain about a source file of some
kind that wasn't terminated by a newline, but I don't immediately
remember what it was (perl?). I try to make it a point to add them
just for neatness and consistency and to keep a lexer that looks for
newlines first before checking to see whether it's source image has
run out of bytes running on what is likely its most common code path
until it actually does run out of bytes.


I actually think it would make sense if an editor's language mode just
did it automatically (terminate all saved source files with a single
end-of-line in the native syntax of the host system when you save the
file). It's absurd to leave something so simple up to the programmer
when you consider how small a job this is compared to all of the other
specialized editor code that goes into a programming-language-specific
editing mode.


Regards,


Clayton Weaver
<mailto: cgweav@aol.com>


Post a followup to this message

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