[antlr-interest] how to let parser control lexer state.

Jim Idle jimi at temporal-wave.com
Sun Apr 29 09:11:09 PDT 2007


Because human languages developed in a hap-hazard fashion and this seems
intuitively the wrong way to write languages that are used to express a
formal thing like a good program? High-level languages are not designed
[well for some languages we could stop there ;-)] for humans, they are
designed for humans to write programs with.

If it is difficult for the parser to report errors as accurately as
possible, or for the human eye to scan a program and make sense of it,
then the language is going to be harder to develop and debug in. It
isn't anything to do with how hard it is for the guy the wrote the
parser - parsing C and C++ is inherently complicated, but I can see the
difference between
{
And
{
	{

A lot easier than I can
	
and
		

And again, that isn't really a compiler aid - it is quite difficult to
correctly identify the position of a missing } in C. If the position of
something in the 'line' is thought to be a significant aid to
programming, then let's just use virtual 80 column cards and write in
COBOL. I just don't accept the tenet that making whitespace significant
in some places and not in others is somehow an aid for humans to program
in - we don't use space grammatically, when writing human language, we
use things like - () ; {} [] : - 

In point of fact though, it is, and should be, a matter of personal
choice. However, what tends to happen is that programs knocked up to do
a simple task, in a language that is good for that task, tend to
demonstrate the "I've got a hammer" theory and be used everywhere for
everything. I don't despise languages like this, I am a big fan of tools
like awk and sed, but I think they should not be used for any task you
have going on, any more than you should write an application in C. 

Jim

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Benjamin Niemann
Sent: Sunday, April 29, 2007 3:49 AM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] how to let parser control lexer state.

Jim Idle wrote:

> Indeed. Perhaps, someday, the world can require that any 'new' [insert
> post-modernistic interpolation of 'reality' here ;-)] languages have
to
> have a sane ANTLR parser as proof of their ability not to drive anyone
> with any sense mad and generally propagate the idea that languages
> should be 'useful' on their own terms - 'useful' being really "I can't
> be bothered to learn how to do this properly, so pass me the magic
> bullet". I will be the first to program the windows Vista gun gadget
> control to shoot anyone deciding that indenting should be
> lexically/grammatically significant on the vague justification that it
> makes people format code - something that a good programmer should do
> naturally anyway.

(High level) Languages are primarily designed for humans. That's why I
consider 'blocking by indention' more important than {..}, BEGIN..END or
whatever. Why should millions of language users be bothered with
maintaining two ways to define blocks - one for humans and one for the
compiler, if one is sufficient? Just to make those few poor souls
happier,
who want to build parsers for these languages? IMHO: no.

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/



More information about the antlr-interest mailing list