[antlr-interest] "Comments" token from source to the target language
Andreas Bartho
andreas.bartho at inf.tu-dresden.de
Tue Nov 13 08:18:10 PST 2007
Hi,
I had a similar problem (getting a C#-AST with comments and Preprocessor
directives). I settled with defining 3 parsers (C#, Preprocessor,
Comments) and merging the resulting asts.
There are some ambiguities to be solved (e.g. does a comment above the
first statement in a method belong to the method body node, the
StatementList node or the first statement node?), but it saves you much
hassle in your grammar definition (as already discussed).
Andreas
Mateus Baur da Silva wrote:
> Hi Guys,
>
> As I mentioned in some my other email, I doing a translator from a
> Pascal subset to java. Currently, I'm ignoring the "comments" by using
> skip() on the lexer rule that defines the "comments".
>
> However, I would like to translate the comments from Pascal to Java code
> as well. I was wondering if I could do that by using the HIDDEN_CHANNEL
> or some other feature to properly translate the comments. Does someone
> have any clue on how to do that?
>
> Thanks in advance,
> Mateus
>
>
More information about the antlr-interest
mailing list