At 21:14 1/09/2008, [EMAIL PROTECTED] wrote:
>In our small language we have a notion that if a line begins with 
>a '*' character on Column 0 we treat it is a line comment.
>However the '*' happens to be the multiplication operator in the 
>language at the same time.
[...]
>LINE_COMMENT
>     : '*' ~('\n'|'\r')* '\r'? ('\n')
>     {
>       if(getCharPositionInLine() == 0){
>             System.out.println("Found Line Comment :" + 
> getLine());
>             $channel=HIDDEN;
>         }
>     }
>     ;

This will match the '*' as a LINE_COMMENT always, but only hide it 
part of the time.  You need to change your recognition around, and 
also provide named tokens for the other variations on the asterisk 
(instead of using parser literals):

fragment STAR: '*';
fragment DBLSTAR: '**';

LINE_COMMENT
   : '*'
     ( { getCharPositionInLine() == 0 }? ~('\n'|'\r')* '\r'? '\n' 
{ $channel=HIDDEN; }
     | '*' { $type = DBLSTAR; }
     | { $type = STAR; }
     )
   ;


List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/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