Antlr v3 & Trees (was: [antlr-interest] if-then-else - Grammar generates faulty parser code)

Terence Parr parrt at cs.usfca.edu
Thu Apr 22 21:26:47 PDT 2004


On Apr 22, 2004, at 1:48 PM, Monty Zukowski wrote:

> On Apr 22, 2004, at 1:23 PM, John D. Mitchell wrote:
>
>> I'm perplexed.  Do you have some example where the addition of an
>> imaginary
>> node is some kind of problem?  The only examples that I can think of
>> would
>> all be issues of a very poorly designed tree to begin with.
>
> Consider the following tree grammar fragment:
>
> Example A:
>
> selectStatement
> 	:
> 	queryExpression
> 	(computeClause)?
> 	(forClause)?
> 	(optionClause)?
> 	;
>
> computeClause
> 	:
> 	#(COMPUTE
> 		(identifier expression)+
> 		(BY (expression)+)?
>           )
> 	;

Hi Monty,

My typical example of where you want a "placeholder" is when you have 
multiple optional things in a row.  For example, the expressions in a 
FOR statement.  Do you want

forRule : #(FOR (expr)? (expr)? (expr)?) ;

??  Probably not as the grammar is inherently ambiguous.  Position has 
"meaning" in this case.

Is that a good example?

Ter





 
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