Thank you!

This one worked fine:

> bracketedBlock : '{' statement* '}' -> ^(Block statement*) ;

Strangely it works for two statements but not for 3 - my input like this

  { echo 'foo';  echo 'bar';  echo 'tree'; }

Now produces this AST

64: Block
  34: echo
    92: 'foo'
  34: echo
    92: 'bar'

(No 'echo tree' in the AST).

This might be a higher level problem in my grammar though ... but if
something comes to mind I'd love to know any ideas why that might be.

Thanks again!

Cheers,

Simon

On Wed, Mar 30, 2011 at 1:27 PM, John B. Brodie <[email protected]> wrote:
> Greetings!
>
> On Wed, 2011-03-30 at 12:43 +1100, Simon wrote:
>> Hello all,
>>
>> I have a grammar that does a rewrite like so:
>>
>>   bracketedBlock
>>       : '{' stmts=statement* '}' -> ^(Block $stmts)
>>       ;
>>
> you are not properly handling the cardinality of the * meta-operator.
>
> try:
>
> bracketedBlock : '{' statement* '}' -> ^(Block statement*) ;
>
> or:
>
> bracketedBlock : '{' stmts+=statement* '}' -> ^(Block $stmts} :
>
>
>
> Hope this helps...
>   -jbb
>
>
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to