[antlr-interest] Not generating parts of AST (argh!)

Monty Zukowski monty at codetransform.com
Sun Oct 24 21:23:19 PDT 2004


On Oct 24, 2004, at 8:56 PM, Paul J. Lucas wrote:

> 	Ideally, yes.  However, ANTLR complains about having ^ on
> 	non-terminals:
>
> 		ANTLR Parser Generator   Version 2.7.2   1989-2003 jGuru.com
> 		XQueryParser.g:2015:33: rule classDef trapped:
> 		XQueryParser.g:2015:33: unexpected token: ^
> 		error: aborting grammar 'XQueryParser' due to errors
> 		Exiting due to errors.
>

Yes, of course, I knew I was missing something.

There are language specific ways to manually ^ a node, but your code 
actually looks cleaner.

On second thought, how about this:

		comparisonExpr
		    : rangeExpr
		      (co:comparisonOp! rangeExpr { ##=#(co,##); })?
		    ;

Although I'm trying to remember if the above sets the nextSibling 
pointer to null such that you would see #(comparisonOp r1) instead of 
the full tree.  Experimentation would show you instantly.

The following would work for sure:

		comparisonExpr
		    : re1:rangeExpr
		      (co:comparisonOp! re2:rangeExpr! { #comparisonExpr = #(co, re1, 
re2); })?
		    ;

Monty



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list