[antlr-interest] Is it safe to overwrite the Lexer's text?

Gavin Lambert antlr at mirality.co.nz
Tue Aug 28 05:20:47 PDT 2007


At 00:11 29/08/2007, Bjoern Doebel wrote:
 >I have a language consisting of source code and comments. I have 
a
 >lexer and parser that create an AST of it. I would like to use 
the
 >created syntax tree as a starting point for several tools. Some 
of
 >them will need access to the comments, some of them won't. I
 >cannot just ignore the comments, but I also don't want to store
 >all of them inside the AST. Instead, inside the lexer I 
recognize
 >comments, copy them (current value of self.text) into a separate 

 >table and replace the comment's text by overwriting self.text 
with
 >an index referencing the comment's table entry.

Isn't that what channels are for?



More information about the antlr-interest mailing list