[antlr-interest] ANTLRworks vs. Stand-Alone Parser

Randall R Schulz rschulz at sonic.net
Tue Jun 26 06:47:23 PDT 2007


On Tuesday 26 June 2007 06:38, Thomas Brandon wrote:
> On 6/26/07, Randall R Schulz <rschulz at sonic.net> wrote:
> > Hi,
> >
> > I have a grammar, that's working (though far from complete). It's
> > does not appear to be parsing the inputs the way I intend, so I
> > wanted to look at the parse tree in the ANTLRworks Interpreter
> > pane. The problem is that input that is parsed successfully when I
> > run the parser on its own (outside ANTLRworks) just gives a one or
> > two derivations (depending on which non-terminal I choose as the
> > start symbol) and then NoViableAltException. ...
> >
> > Am I doing something wrong? Why the discrepancy between the parser
> > when executed on its own and when executed within ANTLRworks? ...
> >
> >
> > Randall Schulz
>
> The ANTLRWorks interpreter does not execute actions, including
> predicates.

Why not?


> So if your grammar uses predicates or actions which alter 
> the lexing\parsing behaviour it will not work in the ANTLRWorks
> interpreter.

At the moment, I have no syntactic predicates and no actions other than 
some simple println() calls. However, I seem to recall from looking at 
the generated code recently that when you use the backtracking option, 
which I am, ANTLR itself can generate syntactic predicates, right?

So might that explain the discrepancy?


> The ANTLRWorks debugger does do actions properly and should be
> identical to running externally (apart from classpath issues which
> may necessitate external debugging).

OK. I guess I'll try to make that work. I've never had success in the 
past, and have been deterred by the complications from trying hard 
enough to make it work.

E.g., at the moment there's a diagnostic in the console telling me about 
class file version incompatibility (found 50.0, wants 49.0)...


> Tom.


Randall Schulz


More information about the antlr-interest mailing list