I am working on a lexer where I need to know the context of the input to
determine the proper tokens to generate.

While attempting to solve the problem, my lexer triggered what appears to be
a never ending recursive call - eventually exiting with an Out of Memory
exception.

I ripped out the problem parts and have included it below.  This lexer does
the same thing.  I am running this using antlr 3.1.1

Thanks for any help.

-Dave

--- Example Test Case ---

    public static void main(String [] args) {
        CharStream stream = new ANTLRStringStream("|small");
        error e = new error(stream);

        Token t;
        while((t=e.nextToken()) != Token.EOF_TOKEN) {
            System.out.println(t);
        }
    }

--- output from test case ---

line 1:0 rule CHECK failed predicate: {check}?
line 1:0 rule CHECK failed predicate: {check}?
line 1:0 rule CHECK failed predicate: {check}?
line 1:0 rule CHECK failed predicate: {check}?
line 1:0 rule CHECK failed predicate: {check}?
line 1:0 rule CHECK failed predicate: {check}?
line 1:0 rule CHECK failed predicate: {check}?
.... (forever)

--- error.g ---

lexer grammar error;

@members {
    boolean check = false;
}

fragment Letter
    :    'A'..'Z'|'a'..'z';

fragment Number
    :    '1'..'9'|'0';

fragment Id
    :    Letter(Letter|Number|'_'|'-')+;

fragment Eq
    :    '=';

fragment Pipe
    :    '|';

NOT_CHECK:
    {!check}?=> Pipe Id Eq {
    }
    {!check}?=> Pipe Id {
    }
    {!check}?=> p=Pipe {
    } ;

CHECK:
    {check}?=> ~(' ' | ']')+ ;

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

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

Reply via email to