[antlr-interest] Re: TreeParsing with various roots

lgcraymer lgc at mail1.jpl.nasa.gov
Wed Nov 3 14:42:43 PST 2004



Paul--

Unfortunately, the answer to your question is "not yet".  Alternatives
for roots should be supported--I started to do that for 2.8, but did
not finish--but 2.x currently does not support them.

3.0 will:  Ter, Monty, and I discussed this at last summer's cabal.

--Loring


--- In antlr-interest at yahoogroups.com, "Paul J. Lucas"
<pauljlucas at m...> wrote:
> 	Suppose I have in a parser:
> 
> 		compExpr
> 		    : re1rangeExpr
> 		      (co:compOp! re:rangeExpr!
> 		      	{
> 			    ## = #(co, re1, re2)
> 			}
> 		      )?
> 		    ;
> 
> 		compOp
> 		    : EQ | NE | LT | LE | GT | GE
> 		    ;
> 
> 	How to I write the corresponding Treeparser?
> 
> 		compExpr
> 		    : #( xxx re1=rangeExpr re2=RangeExpr )
> 		    ;
> 
> 	What goes in the place of the "xxx"?  Ideally, I'd like to
> 	share the code for all compOps.
> 
> 	I *could* do:
> 
> 		compOp
> 		    : (EQ | NE | LT | LE | GT | GE)
> 		    	{
> 			    ##.setType( COMP_OP );
> 			}
> 		    ;
> 
> 	then:
> 
> 		compExpr
> 		    : #( co:COMP_OP re1=rangeExpr re2=RangeExpr )
> 		    	{
> 			    // do something with co.getText()
> 			}
> 		    ;
> 
> 	But having to use the text of the original token seems a bit
> 	hokey to me.  Is there a better way?
> 
> 	- Paul





 
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