On Sat, Nov 29, 2008 at 05:57:07PM +1000, Илья wrote: > Hi there, > I have tried to fix our HTML::Template in November which is blocked by > Rakudo segaful. > I was trying to create simple example, but can`t reproduce it. By the > way now I have short > example(much shorter then when I start), and I have questions about it: > > grammar G { > token TOP { ^ <foo>+ $ }; > token foo { ':' <bar>? }; > token bar { \w }; > }; > > ":a:b" ~~ G::TOP; > > say ~$/<foo><bar>; #:a > > # why ':a'? why not just 'a'?
$/<foo> is an array of Match objects, and Parrot currently doesn't distinguish between array indexes and hash indexes -- it treats them both the same. Thus $/<foo><bar> is ending up acting the same as $/<foo>['bar'], and since 'bar' stringifies to zero that's the same as $/<foo>[0], which includes the colon. The correct way to get just the <bar> component would be $/<foo>[0]<bar>[0] since both <foo> and <bar> are quantified subrules in the grammar. Pm