[cfe-dev] Patch to allow comment translators implementation

Chris Lattner clattner at apple.com
Tue Dec 29 12:08:35 PST 2009

On Dec 26, 2009, at 7:58 AM, Abramo Bagnara wrote:

> This small patch change comments handler in a simple way to permit to
> implement quite easily comment translators.
> Once applied this patch, a CommentHandler is allowed to build a first
> token to be returned to Lexer and to push a TokenStream for the others,
> then allowing generic comment -> tokens transformer.
> This can be useful to transform comment shaped program annotation that
> should be translated to source code and also other interesting applications.

This is an interesting approach.  The only major concern I have is that this only allows you to translate comments into exactly one token.  In the case of openmp pragmas (for example) this doesn't seem rich enough.  A different approach would be to allow the handler to push an arbitrary number of tokens into the parser's lookahead buffer.  Would this work for what you're trying to do?


More information about the cfe-dev mailing list