in reply to Re^3: Perl6: Dynamic Grammars
in thread Perl6: Dynamic Grammars
But how would I rewrite my tests, then — which actually want to operate on the captured value?This is Perl, so there's more than one way to do it, eg
will generate a sequence of pairs with the key being the name of the sigil and the value the enclosed text.my %sigils = bang => '!', at => '@', hash => '#', dollar => '$', percent => '%', caret => '^', and => '&', star => '*', zero => '0'; my regex line { ^^ :my $s; (\w+) <?{ $s = %sigils{$0} }> \h+ $s (\N*) $s $$ { make ~$0 => ~$1 } } sub parse($_) { map *.<line>.made, m:g/<line>/ } say parse "star *foo*\nat @bar\nat @baz@";
|
|---|