[antlr-interest] Tree parser action only gets text for first token in rule

Darien A Hager darien at technofovea.com
Thu Oct 8 21:12:57 PDT 2009


I haven't solved the core problem, but there is a workaround: In my case I was able to alter my lexer rules so that the rule text matched a single token. But in trying to do so, I ran into a different problem.


This is what didn't work: I tried to use a rule in the AST-emitting parser to combine all the text into one imaginary token:

______________________
text
	:	QSTRING|(CHAR+)
	->	TEXTVAL[$text.text]
	;
______________________

This created a valid-looking stream of tree nodes going to the tree parser, however... the tree parser would always error out, claiming it found "test text here" instead of TEXTVAL. The TEXTVAL token would have the correct token number, but it's token *name* would somehow match the text payload...?

Anyway, my gut feeling is that there should still be *some* way to specify "all text within this subtree" in an tree-parser, and I'm still interested if someone knows what it is.

--Darien A. Hager



More information about the antlr-interest mailing list