[antlr-interest] Javadoc -style extensions

henry whittaker whittaker55 at yahoo.com
Wed May 25 08:21:57 PDT 2005


Hi,

I'd like to extend the grammar I'm working up to use
Javadoc-style language annotations so that optional
metadata can be embedded as Javadoc comments.

I've looked at the examples of this in the
documentation and there are two mechanisms
highlighted, the primary one using multiplexed lexers
and hidden tokens. 

I don't want to parse all javadoc-style comments
though, only those preceding certain language
structures so I am reluctant to extend the lexer.
Instead I was considering the following:
  Have the lexer emit javadoc comments as a single
token
  Add a filter that strips and stores the Javadoc
comments in a WeakHashMap mapped to the next visible
token.
  Create a method on the filter that returns the
parsed Javadoc structure on-request (using a
javadoc-specifc lexer initialised with line/col of
javadoc comment).
  Invoke the new filter method from my grammar at all
locations where optional javadoc is required, called
with the first token of the rule I want to annotate.

Is there any problems with this approach or is there a
better way to do this?

Also, are there any grammars already available for
parsing javadoc comments? If not, I'd be happy to post
mine (once it's written :)!)

Cheers,

Henry

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the antlr-interest mailing list