[antlr-interest] Antlr Book Chapter 3 troubles

Tim Halloran hallorant at gmail.com
Fri Sep 5 13:40:04 PDT 2008


Thanks Jim,

Yes, I typo-ed the example it was
  | ^('=' ID expr)
not
  | ^('=' ID.expr)
on page 65 of the book.

A bit tricky to diagnose, hopefully this will improve in future releases.
In particular, your heuristic approach could be used inside the tool
implementation to at least report which rule has some sort of problems.

Thanks,
Tim


On Fri, Sep 5, 2008 at 4:26 PM, Jim Idle <jimi at temporal-wave.com> wrote:

>  On Fri, 2008-09-05 at 13:17 -0700, Terence Parr wrote:
>
> On Sep 5, 2008, at 12:44 PM, Tim Halloran wrote:
> > [15:36:28] error(10):  internal error: /Users/tim/Source/antlr-Work/
> > Ch3 Expr AST/src/Eval.g : java.lang.NullPointerException
> > org.antlr.codegen.CodeGenTreeWalker.atom(CodeGenTreeWalker.java:1959)
>
> I don't see rule atom.
>
>
> That's the ANTLR stack trace not the grammar trace. This is happening
> because something in the input source for the tree grammar is wrong, but the
> v3 grammar doesn't catch it and produces a tree that causes NPE.
>
> At the moment, the only way to work out what it is, is to remove your
> actions one at a time and try, then remove any parameters or returns and so
> on, and suddenly it will compile - then you will know which bit is in error.
>
> However I can save you a little trouble by pointing out that the problem is
> this:
>
> | ^('=' ID.expr)
>
> You have put ID.expr in the grammar spec and it needs to be just ID.
>
> Jim
>
> Ter
> >
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080905/b54bd7ed/attachment.html 


More information about the antlr-interest mailing list