[antlr-interest] Lexer modes

Loring Craymer lgcraymer at yahoo.com
Tue Sep 5 11:23:45 PDT 2006


Ter--

Lexer modes may be very easy to implement.  Have multiple mToken (single token returned) rules underneath mTokens selected by sempreds.  Syntax might be

mode FOO {
    TEXT, NUMBER, 'hello'
}

to list the rules recognized in a mode.  Multiple mTokens_ might be faster, and could be done easily if empty rules with sempreds work:

TOMBSTONE
    :
    { mode != lastMode }? { lastMode = mode }?
    ;

Then you could follow the mTokens_ loops with TOMBSTONE as a termination condition and have a master mTokens rule.

Much of the simplicity comes from the artificially generated mTokens approach that you already have in place--that's a very clever way of letting ANTLR do the analysis.

--Loring

Terence Parr <parrt at cs.usfca.edu> wrote: 
On Sep 1, 2006, at 12:32 PM, FranklinChen at cmu.edu wrote:

> Is there an estimate on when an ANTLR with lexer modes will be
> available?  I have been holding off on implementing part of a program
> until this feature exists.

   I am not sure about timing, but I want these for sure.

Ter



 		
---------------------------------
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060905/aaed744c/attachment.html 


More information about the antlr-interest mailing list