On 10/10/2010 06:31 PM, A Z wrote:
> Hello,
> 
> I have a lexer with the following rules:
> 
> 
> LBMINUSGT                  : '[->';
> LBASRB                     : '[*]';
> LBAST                      : '[*';
> LBEQUALS                   : '[=';
> LBPLUSRB                   : '[+]';
> LBRACE                     : '{';
> LBRACKET                   : '[';
> MINUS                      : '-';
> 
> The lexer fails(with an error message) when any string of '[-' or '[*' is
> detected. I'm confused why ANTLR cannot tokenize '[-' correctly as LBRACKET
> MINUS. It also discards two characters after the failed token. I do not have
> a static k defined and ANTLR generates no warnings when compiling. I'm still
> debugging but it's slow figuring out how the antlr3dfapredict() function
> works. Any help is appreciated.

Does the following help you out?

fragment
LBMINUSGT: // "[->"
        ;

fragment
LBASRB: // "[*]"
        ;

fragment
LBAST:  // "[*"
        ;

fragment
LBEQUALS: // "[="
        ;

fragment
LBPLUSRB: // "[+]"
        ;

LBRACKET: '[' ( ('-' '>')=> '-' '>' { $token = LBMINUSGT; }
              | ('*' ( ']' { $token = LBASRB; }
                     | { $token = LBAST; } )
              | ('+' ']')=> '+' ']' { $token = LBPLUSRB; }
              | '=' { token = LBEQUALS; }
              | )
        ;

-- 
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to