[antlr-interest] Possible Antlr defect?

Randall R Schulz rschulz at sonic.net
Sat Jun 9 20:41:27 PDT 2007


On Saturday 09 June 2007 20:16, Gavin Lambert wrote:
> At 13:08 10/06/2007, Terence Parr wrote:
>  >Yep.  It is vulnerable to typos, but only comes up when you're
>  >building separate parser and lexer (or a tree parser I guess).
>
> As with any compiled language, I think it's far better to require
> declaration before use to prevent this sort of problem.  It's
> trivial to declare any fake tokens required in a "tokens" block,
> so the cost of requiring predeclaration is (in my opinion) vastly
> less than the cost of *not* requiring predeclaration, where you
> spend hours of pain and torment trying to figure out why something
> isn't working, finally noticing a simple misspelling or
> transposition error.  (And yes, I've had that happen to me before
> with other [usually interpreted] languages that didn't enforce
> predeclaration, so I know whereof I speak.)

For the most part, I agree. I have several parsers for first-order logic 
dialects that implicitly declare each distinct new symbol found, though 
they must be used consistently (in terms of their type, whether 
predicate, function or constant, and the arity of predicate and 
function symbols).

Because of the implicit declaration, I had to write a tool that culls 
all distinct symbols and lists them in alphabetic order as an aid when 
debugging large inputs. It has proved sadly useful.


> ...


Randall Schulz


More information about the antlr-interest mailing list