[antlr-interest] ^(TOKEN) vs. TOKEN

Gary R. Van Sickle g.r.vansickle at att.net
Sat Feb 28 22:56:55 PST 2009


Hi guys,

Can somebody explain to me why this is ok in a parser grammar:

pointer
	: '*' -> ^(POINTER)
	;

But this is an error in a tree grammar?:

pointer
	: ^(POINTER)
	;

?  The following appears to be the correct way to do this, and does in fact
appear to work:

pointer
	: POINTER
	;

But it's not clear to me why this should be so.  Shouldn't both these cases
share the same syntax, either both ^(POINTER) or both POINTER?

Thanks,

-- 
Gary R. Van Sickle



More information about the antlr-interest mailing list