[antlr-interest] Equivalent of TOKEN{x,y}

Sam Harwell sharwell at pixelminegames.com
Wed Nov 11 12:26:29 PST 2009


Jim doesn't "emphasize" the benefits of doing things this way because by
now we understand that this is "just how things are done."

If you relax checks like this in the grammar and place them in a
post-parse analysis (tree walker for example), some of your benefits
include:

* Faster parsing (sometimes **much** faster)
* Smaller generated code (sometimes **much** smaller)
* Better error messages (**always much** better)
* Everything is more maintainable

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: Wednesday, November 11, 2009 1:41 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Equivalent of TOKEN{x,y}

<snip>

You really don't want to do things like this at the grammar level - the
messages you will issue will be confusing to users "Error at 'y',
expecting '}'" leaves you to guess the meaning. It is generally better
to produce a CommonTree, verify it and output whatever you need.

<snip> 

Jim



More information about the antlr-interest mailing list