[antlr-interest] Problems with StringTemplate within TreeGrammar

Terence Parr parrt at cs.usfca.edu
Mon Oct 29 11:21:01 PDT 2007


On Oct 29, 2007, at 5:58 AM, G R wrote:

Use ANTLRWorks to step thru your grammar.  You'll find that your  
grammar for tree doesn't match the tree.  Also note that you should  
probably not use Root? style trees in your grammar.

Ter
> select    :    ^(Select condition relation)
>                 ->select(condition={$condition.st}, relation= 
> {$relation.st});
> condition
>     :    ^(Or? lt+=logicalTerm+)
>                 ->condition(logicalTerms={$lt});
> logicalTerm
>     :    ^(And? lf+=logicalFactor+)
>                 ->logicalTerm(logicalFactors={$lf});
> logicalFactor
>     :    ^(Not ^(CompareOperator leftOp=operand rightOp=operand))
>                 ->notLogicalFactor(leftOperand={$leftOp.text},  
> rightOperand={$rightOp.text}, operator={$CompareOperator.text})
>     |    ^(CompareOperator operand operand)
>                 ->logicalFactor(leftOperand={$leftOp.text},  
> rightOperand={$rightOp.text}, operator={$CompareOperator.text})
>     |    condition
>                 ->innerCondition(condition={$condition.st});
> operand    :    AttributeName
>     |    Numeric;


More information about the antlr-interest mailing list