[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Analysing comments using visitors




Hi all,


I'm trying to write a documentation helper tool for my Java project.
The goal is to automatically generate some documentation according to
the source code. I've managed to create a parser for me and can also
use my own analyser (extending DepthFirstAdapter). The problem
is that because of the part of the information I need for my final docs
is also written in the javadocs of the source, I need to have
the comments also in my AST tree so that my analyser could analyse them.

At the moment (using Java language grammar from the Sablecc's homepages)
the comments are appearently completely removed from the AST. I've tried
to comment out this part of the grammar

Ignored Tokens

  white_space,
  traditional_comment,
  documentation_comment,
  end_of_line_comment;

to get also the contents of the comments to the AST, but resulted parser
is somehow broken (throws ParserException with message "[13,1]
expecting: EOF"). So, the question is:

Is there any way I could access the contents of the comments using
some child class of DepthFirstAdapter and visitor pattern? Do I need
to modify the grammar somehow? If yes, how?


Sincerely,


Jouni Hartikainen