[antlr-interest] v2->v3 Skip chars in Lexer. DELIMITED IDENT [SOLVED v3] :-)

Ruslan Zasukhin ruslan_zasukhin at valentina-db.com
Sun Apr 17 11:52:09 PDT 2011


On 4/17/11 6:32 PM, "Jim Idle" <jimi at temporal-wave.com> wrote:

Hi Jim,

Thanks to your point on
    http://markmail.org/message/izyhuzbooerfw4tu


I was able resolve DELIMITED IDENT rule with (as I am sure now) maximal
effectiveness. Great.

30 min for me have take to correctly find C analogs of macros, and make them
compile. Then next 90 minutes I have search how to force IDENT type of token
instead of DELIMITED.

Now rule works correctly.  All on LEXER level.  All looks effective.

Again, if you like this code, maybe add it to FAQ page for future
developers.


//----------------------------------------------------------------------
Next task is LITERAL :-)
So I will yet send letters here. Please be patience.


//----------------------------------------------------------------------
IDENT
    :    ( LETTER | '_' ) ( LETTER | '_' | DIGIT )*
    ;

DELIMITED        // delimited_identifier
@init
{
    $type = IDENT;
    int theStart = $start;
}
    :
    (    DQUOTE    { theStart = GETCHARINDEX(); }
            ( ~(DQUOTE) | DQUOTE DQUOTE )+
                { $start = theStart; EMIT(); }
        DQUOTE
    
    |    BQUOTE    { theStart = GETCHARINDEX(); }
            ( ~(BQUOTE) | BQUOTE BQUOTE )+
                { $start = theStart; EMIT(); }
        BQUOTE
    
        // valentina/oracle extension: [asasas '' " sd "]
    |    LBRACK    { theStart = GETCHARINDEX(); }
            ( ~(']') )+
                { $start = theStart; EMIT(); }
        RBRACK
    )            
    ;


-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the antlr-interest mailing list