[antlr-interest] Comment Problem

Thomas Dill thomas.dill at foery.ch
Thu Apr 30 07:41:58 PDT 2009


Hi there.

 

I got the following Problem:

 

In the syntax, I want to parse, a comment line starts with "-*" and ends at
the end of the line. It's possible that an asterisk can appear in a "text".

 

I can't find a solution. Below there's what I tried (and many other things).
Can somebody help me?

 

Example:

 

TABLE FILE CAR

PRINT * -* prtints all fields

BY MODEL

END

 

ANTLR Code:

grammar FexParser;

options {k=3; backtrack=true; memoize=true;}

 

report    :    (comment | text | NEWLINE)+ ;

 

comment   :    (COMMENT_START ~(NEWLINE))* ;

text      :    (~(COMMENT_START | NEWLINE))+;

 

fragment COMMENT_START

          :    '-*';

 

WS        :    ('\t' | '\v' | '\f' | ' ' | '\u00A0')     {$channel =
HIDDEN;};

NEWLINE   :    '\n' | '\r' | '\u2028'| '\u2029'    ;

 

Best regards,

Tom

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090430/ec63f835/attachment.html 


More information about the antlr-interest mailing list