[antlr-interest] Lexer Question

Jeff Barnes Jeff.Barnes at codesic.com
Thu Mar 23 16:34:51 PST 2006


I think I may be confusing a couple of issues... Consider the following partial rule:
 
SF
{
    int length = 0;
}
:       
    '\u005A'!
    byte1:'\0'..'\u007F'
    byte2:. {length = (byte1<<8)+(byte2&0XFF);}
    '\u00D3'
    (
        '\u00A0'
        (
            '\u0088' {$setType(MFC_SF);}  '\0' '\0' '\0' MFC_SF[length-12]
        |   '\u0090' {$setType(TLE_SF);}  '\0' '\0' '\0' TLE_SF[length-8]
        )
    |   '\u00A2' '\u0088' {$setType(MCC_SF);}  '\0' '\0' '\0' MCC_SF[length-8]
...
    )
...
 
With this kind of lexing, each byte specifies the one and only path (state) the lexer can follow (be in).
 
It's not a DFA, but it sorta acts like one. The subrules are called and no recursion back to SF occurs from the subrules.
 
If I were looking to describe this strategy in a few words, what would I call it? Left-factoring?

Regards,
Jeff


More information about the antlr-interest mailing list