fragment WRAPPER : ;
COMMENT : '//' SPACE*
( ('@')=> '@' (~WSCHARS)* { $type = WRAPPER; }
| ' (~WSCHARS)*
)
;
Always left factor and change the token type dynamically.
Jim
On Sep 17, 2009, at 7:55 AM, Soren Holstebroe <[email protected]>
wrote:
> Hi,
>
> I have this project where C++ templates are being unfolded and
> wrapped in .NET. This wrapping is performed by some perl-scripts
> which over time have become quite messy, so I wanted to rewrite the
> wrapper using ANTLR.
>
> The way the current template wrapper works is by parsing simple
> template expressions defined in the comments preceding a function
> definition. This is similar to documentation frameworks like
> doxygen, where the documentation is embedded in the comments above
> functions, classes, etc.
> The simple syntax contains elements like this:
> // @TEMPLATE <int, float>
> which tells the wrapper to unfold the template using an int for the
> first template type and a float for the second.
>
> My problem is that I am already stuck in defining the lexer.
> Since all wrapper expressions start with '@' I tried to define a
> token like:
> WRAPPERSTART : SLASHSLASH SPACE* '@'
> and some grammar rules based on that token.
> However that doesn't work since the lexer will always choose the
> longest matching rule, which would always be the normal single line
> comment rule.
>
> I can imagine that there are many approaches to tackle this problem
> and some hints would be greatly appreciated.
>
> Soren
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/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
-~----------~----~----~----~------~----~------~--~---