[antlr-interest] handling /// comments
ajk .
anders43 at gmail.com
Fri Sep 19 02:02:02 PDT 2008
Hi
I was wondering if somebody has an idea how to solve the following problem.
Lets see if I can describe the issue in a proper way.
We have a translator that translates a scripting language to C#.
We now need to support ///<summary>.. in C#
By adding the /// in the scripting language we were hoping just to move this
over to C#:
example
/// <summary>
/// some function
/// </summary>
myfunction returns int
begin
bla();
end
->
C#
/// <summary>
/// some function
/// </summary>
int myfunction()
{
bla();
}
So far so good, I would associate the comments to the following function
which is a node in the AST, simple to do a parser rule for this.
But in C# (as well as the scripting language) you can write comments
anywhere in the code in whatever form you want e.g.
/// hello
or
///////////////////////////////////////////
//// this freestanding comment
////////////////////////////////////////////
How do you filter away these things? How do I write a parser rule that
allows comments anywhere in the original code but only move the relevant
ones? i.e. the ones associated with certain elements like functions,
variable declarations etc.
TIA
Anders.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080919/9a90c2fe/attachment.html
More information about the antlr-interest
mailing list