[antlr-interest] using newline for a statement terminator

Randall R Schulz rschulz at sonic.net
Sun Dec 9 19:56:54 PST 2007


On Sunday 09 December 2007 19:50, Mark Volkmann wrote:
> I've come to the conclusion that it's difficult to implement a
> language with ANTLR where statements are terminated by a newline
> character. Hopefully I'm wrong about this and there is a simple
> pattern of usage that I'm missing. If you've done this, any hints
> would be appreciated.

There is no reason that newline character or sequence is any harder to 
use as a statement terminator or separator than any other character.

The problem comes because of the ambiguity that results from not making 
a newline a _mandatory_ terminator, as, say, a semicolon would be. That 
practice is compounded by the typical practice of making semicolon 
allowable but optional.

Personally, as someone currently using Groovy, I don't think it's worth 
it. Semicolons are neither evil nor particularly onerous. But ambiguity 
is the bane of language designers.


Randall Schulz


More information about the antlr-interest mailing list