Edward Peschko writes:
> > I've been working at updating the various synopses on dev.perl.org.
> > In particular, you folks might like to know that the regex synopsis at:
> >
> > http://dev.perl.org/perl6/synopsis/S05.html
> >
> > is no longer two years out of date :-)
> >
> > Larry
>
> ok, cool, I'm beginning to understand perl6 patterns a bit better.
> Just a tiny request though (and I seem to remember this being
> discussed)
You were the one who initiated the thread :-)
> - I wish that there was an easy syntax to turn regexes inside out as
> it were, to be able to generate text strings given a certain rule,
> especially at border cases - something like:
>
> rule nonquote { <[^\n"]>+ }
> rule slashchar { \\ <[^\n]> }
>
> m:gen('1000')/(" ( <nonquote> | <slashchar> )* ")/
>
> generating
>
> ""
> "x"
> "\x"
> "\\x"
> ....
>
> ie - 1000 matching strings for the particular rule.
>
> If this isn't possible in the core itself, I'd be interested in seeing how it would
> be possible to program outside it as a user defined modifier.
http://www.nntp.perl.org/group/perl.perl6.language/14458
If you replace the first line:
method Rule::Group::generate(Int $n) {
With
multi generate (Rule::Group $group: Int $n) {
Everything ought still to work.
I think the best you can do is to implement it as a routine. You can't
really make it a modifier, because it's pretty separate from actually
matching anything.
> Ed
>
> (
> ps - is there a 'metaphor translation guide' between perl5 and
> perl6 regex? ex - what does ?: translate to? is '?>' subsumed
> by backtracking control and if so, how?
> )
Are you asking, or asking whether there's some official guide somewhere?
To answer the latter question: no.
Luke