[antlr-interest] Parsing comments
Jim Idle
jimi at temporal-wave.com
Thu Sep 17 11:34:40 PDT 2009
You just don't consume after the '@' then and that token will stop
there.
Jim
On Sep 17, 2009, at 9:59 AM, Soren Holstebroe <holstebroe at gmail.com>
wrote:
> Thank you for your answer,
>
> As i understand it, your suggestion considers the whole template
> line as a single token, but I don't want the template token to eat
> up the rest of the line, since this is where my template wrapping
> grammar would be.
>
> My grammar will have rules like this:
>
> wrap_option
> : WRAP_OPTION_BEGIN
> ( 'WRAP'
> | 'TEMPLATE' '<' type_specifier (',' type_specifier)* '>'
> )
> ;
>
> so I need something to match '//' WS* '@' as my WRAP_OPTION_BEGIN.
>
> Soren
>
> 2009/9/17 Indhu Bharathi <indhu.b at s7software.com>
> Try using semantic predicates to look-ahead and decide whether to
> emit SLCOMMENT or TEMPLATE
>
>
>
> Something like:
>
>
>
> fragment SLCOMMENT
>
> : ;
>
>
>
> fragment TEMPLATE
>
> : ;
>
>
>
> SLCOMMENT_OR_TEMPLATE
>
> : '//' (
>
> { input.LA(1)=='@' }?
> => ( options {greedy=false;} : . )* EOL { $type=TEMPLATE; }
>
> | ( options
> {greedy=false;} : . )* EOL { $type=SLCOMMENT; }
>
> )
>
> ;
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090917/858b2a9f/attachment.html
More information about the antlr-interest
mailing list