[antlr-interest] ANTLR equivalent of JavaCC Lexer behaviour?

Richard.Kennard at mail.thomson.com Richard.Kennard at mail.thomson.com
Mon Mar 27 15:37:40 PST 2006


Jeff,

Thank you so much for your reply.

I'm afraid I don't think it addresses my issue, principally because the contention is not between the different forms of the same token, but between different tokens. For example...

	EQUALS: "is" | "are";
	NOT_EQUALS: "is not";
	LESS_THAN: "is less than";

...these 3 tokens all begin with "is", and that is what is throwing ANTLR (but not JavaCC) off. I can't make "is" some kind of fixed keyword either, because at least one form of EQUALS ("are") does not require it.

Is there some other way to obtain JavaCC behaviour?

Regards,

Richard.

-----Original Message-----
From: Jeff Barnes [mailto:Jeff.Barnes at codesic.com]
Sent: Tuesday, 28 March 2006 10:26 AM
To: Kennard, Richard; antlr-interest at antlr.org
Subject: RE: [antlr-interest] ANTLR equivalent of JavaCC Lexer
behaviour?


The short answer is:
 
        class BusinessLexer extends Lexer;

        options
        {
        }

        EQUALS: IS_THE_SAME_AS | IS | ARE_THE_SAME_AS | ARE | OF;
       protected IS: "is";
       protected IS_THE_SAME_AS: "is the same as";
       protected ARE: "are";
       protected ARE_THE_SAME_AS: "are the same as";
       protected OF: "of";

Do the same for the other conflicting rules. Check the manual under alts for more info.
 
Your solution may or may not be this simple.
Jeff



More information about the antlr-interest mailing list