[stringtemplate-interest] Re: [antlr-interest] StringTemplate + preserving comments

Sohail Somani sohail at taggedtype.net
Tue Nov 8 22:52:27 PST 2005


On Tue, 2005-08-11 at 22:40 -0800, Terence Parr wrote:
> > Nope, newlines are being sent to the parser as well (although EOL+
> > becomes EOL). Where are the fields for this linked list in the  
> > Token? I
> > can't see it in the code API on the web nor in the source  
> > (*Token.java).
> 
> Must be hanging out in the CommonHiddenStreamToken object.  Yep,
> 
> public class CommonHiddenStreamToken extends CommonToken {
>      protected CommonHiddenStreamToken hiddenBefore;
>      protected CommonHiddenStreamToken hiddenAfter;
> ...
> }

But again, this is only hidden stuff right?

So a stream like:

HIDDEN_COMMENT EOL_FOR_PARSER SOME_THING

getText() 
{
	// When called for SOME_THING this is always null as EOL_FOR_PARSER is
not hidden...
	while((curr=getHiddenBefore())!=null)
	{
		ret = curr.getText() + ret; // i know i know, slow.
	}
}




More information about the antlr-interest mailing list