Fwd: [antlr-interest] Lexer not as smart as it should be?

Martin Probst mail at martin-probst.com
Sat Oct 22 01:37:02 PDT 2005


Am Samstag, den 22.10.2005, 12:14 +0530 schrieb Suman Karumuri:
> On 10/22/05, Martin Probst <mail at martin-probst.com> wrote:
> > > This seems to work as well(atleast no non-determinism error). As antlr
> > > generates codes, which itself is means that there is no
> > > non-determinism.
> >
> > That is not correct. ANTLR will generate code even if there are non-
> > determinisms. That's why they are warnings, not errors. The code might
> > still not work as you expect it to.
> >
> I did not see any warnings or errors for that grammar though.
> I tried some examples, but can you give me an example where the above
> grammar fails?

I was just referring to your last sentence:

> > As antlr generates codes, which itself is means that there is no
> > non-determinism.

> So, can i take this as a rule of thumb:
> " If i am using an If in the action to check some property of the a
> label, it can be made a semantic predicate in the rule".

A syntactic predicate is something like this:
foo: ( AB CD EF ) => ruleA
     | ruleB;
And that is slowing down parsing. If you don't use that, it's not slow.

Martin



More information about the antlr-interest mailing list