Thomas Woelfle wrote:
Hi,

I've been running in an almost similar problem again.

The subject language that has to be parsed defines some keywords which 
begin with a '.'. Besides that there are specific names allowed and '.' 
is allowed to be a token too.

The reduced lexer grammar that produces the problem is:

DOT: '.';

ARG: ('.ARG')=> '.ARG';

ATT: ('.ATT')=> '.ATT';

NAME
  :
  ('A'..'Z')*;


  
This token allows a match of an empty string and is going to cause all sorts of problems. You want:

NAME : ('A'..'Z')+;

Then if you still have problems, either do:

DOT : '.';
ARG: 'ARG';
ATT : 'ATT';

ident : ID
        | DOT (ARG|ATT)
        ;

Or:

fragment ARG : ;  // Define token number and document
fragment ATT : ; // Define token number and document
DOT : '.'
           (  ('ARG')=>'ARG'  { $type = ARG; }
             | ('ATT')=>'ATT'    { $type = ATT; }
           )
    

Jim

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