> > 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 :-)
> 

Ah yes, I forgot about that. Damn brain cells.. ;-)

> > - 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.

Ok, fair enough.. although I'm not sure that I'm all that sure I'm completely
happy-with/understand the syntax described in that article. It works for the trivial 
cases, but what about complex grammars? 

The reason for the modifier (or even a new operator (g/" for example) is that 
you can easily test your regular expressions. The interface is trivial - all you have
to do is switch your m/ out for g/, and sit back and see how your patterns translate
into strings.  

Eyeballing and fixing the regular expression then becomes trivial (or relatively 
trivial).

If you need to match the regex engine in reverse, in a totally unattached way 
via subroutine, then I would think the chance for subtle mistakes and errors 
would be exceedingly great.

Or, I could be missing something. How would you generalize 

        multi generate Rule::Group $group: Int $n) ..

to work with 

        (( <nonquote> | <slashchar> )* ")

as input?

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.

well, official or unofficial, either works for me. Perhaps it would be good to be
part of the synopsis.

Ed

Reply via email to