Re: regex interpolation of array

2020-06-13 Thread William Michels via perl6-users
Thank you so much for explaining what's going on here, Brad. You gave a good example--just one that I misinterpreted. I think I understand now: inside a regex Richard has to enclose his code within "<{ ... }>" for it to be properly interpreted as a 'match objective' (I hope I said that correctly).

Re: regex interpolation of array

2020-06-13 Thread Brad Gilbert
On Sat, Jun 13, 2020 at 1:27 PM Sean McAfee wrote: > On Sat, Jun 13, 2020 at 10:21 AM Brad Gilbert wrote: > >> That was just a dumb example. >> An incredibly dumb example. >> >> So what happens is that `Bool.pick` chooses The Bool values of either >> `True` or `False`. >> It does this at every p

Re: regex interpolation of array

2020-06-13 Thread Sean McAfee
On Sat, Jun 13, 2020 at 10:21 AM Brad Gilbert wrote: > That was just a dumb example. > An incredibly dumb example. > > So what happens is that `Bool.pick` chooses The Bool values of either > `True` or `False`. > It does this at every position in the string. > > 'TrueFalse' ~~ / <{ Bool.pick }

Re: regex interpolation of array

2020-06-13 Thread Brad Gilbert
That was just a dumb example. An incredibly dumb example. So what happens is that `Bool.pick` chooses The Bool values of either `True` or `False`. It does this at every position in the string. 'TrueFalse' ~~ / <{ Bool.pick }> Let's say that initially `Bool.pick` chooses `False`. That value t

Re: regex interpolation of array

2020-06-13 Thread William Michels via perl6-users
Hi, I seem to be having some problems with Brad's code. The 'boolean pick' code seems far too clever for me to have intuited it on my own, so (to expand my Raku/Perl6 vocabulary), I played around with matching extra 'True' or 'False' values--as well as played around with seeing if similar 'boolean

Re: regex interpolation of array

2020-06-13 Thread Richard Hainsworth
Understood. Thankyou. The " quotes is what I missed. So $ = "@W[3]" worked as I would expect. The other two variations, eg. $ =<{ @W[3] }>, gave Nil responses, indicating match failure. On 13/06/2020 14:41, Brad Gilbert wrote: Inside of a regex `{…}` will just run some regular Raku code. Cod

Re: regex interpolation of array

2020-06-13 Thread Brad Gilbert
Inside of a regex `{…}` will just run some regular Raku code. Code inside of it will most likely have no effect on what the regex matches. What you should have written was: $ = "@W[3]" The thing you were thinking of was: $ = <{ @W[3] }> Which could have been written as: --- To

regex interpolation of array

2020-06-13 Thread Richard Hainsworth
I was playing with a regex and array interpolation. From the documentation I thought the following comparisons would be the same, but they are not. What am I missing? my @W = ; my $S = 'perlchallengeextrathingswithweeklysome' ; #randomly concatenate the words without spaces say 'yes' if $S ~

Re: generating grammars, capturing in regex interpolation, etc.

2015-04-20 Thread Nathan Gray
> Am 17.04.2015 um 04:34 schrieb Nathan Gray: > > # Call it if it is a routine. This will capture if requested. > > return (var)(self) if nqp::istype(var,Callable); > > > > This seems to indicate that captures in the embedded regexes > > should capture. On Fri, Apr 17, 2015 at 09:47:22AM +0200

Re: generating grammars, capturing in regex interpolation, etc.

2015-04-17 Thread Tobias Leich
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The comment in INTERPOLATE is about "subcaptures"... but if you do not capture the interpolated regex itself, you break that chain. Am 17.04.2015 um 04:34 schrieb Nathan Gray: > On Wed, Apr 15, 2015 at 09:45:39PM -0400, Nathan Gray wrote: >> I had g

Re: generating grammars, capturing in regex interpolation, etc.

2015-04-16 Thread Nathan Gray
On Wed, Apr 15, 2015 at 09:45:39PM -0400, Nathan Gray wrote: > I had given up on using regexes embedded within regexes, because > I could not get capturing to work. I did a backtrace on one of the test cases that fails, which led me to src/core/Cursor.pm in method INTERPOLATE(\var, $i = 0,

Re: generating grammars, capturing in regex interpolation, etc.

2015-04-15 Thread Nathan Gray
On Tue, Apr 14, 2015 at 08:58:29PM -0500, Patrick R. Michaud wrote: > Just an idea: instead of building strings to be interpolated into > a regex, could you just build regexes directly? > > my $pattern = rx/$=[hello]/; > my $match = "hello" ~~ / /; > > The resulting string is captured i

Re: generating grammars, capturing in regex interpolation, etc.

2015-04-14 Thread Patrick R. Michaud
second statement can also be written as: # captures into $match my $match = "hello" ~~ / $=$pattern /; # captures into $match[0] my $match = "hello" ~~ / $<0>=$pattern /; Hope this is useful, or at least illustrative. > Of course, there may b

generating grammars, capturing in regex interpolation, etc.

2015-04-14 Thread Nathan Gray
"/"; Of course, there may be a better way, since regex interpolation seems frowned upon in Perl 6. One idea I have is to generate a grammar, but the only way I've been able to get that to work is to create a string that looks like a grammar, and EVAL it. Is that a Perl 6 be

Re: Regex interpolation

2010-03-29 Thread mark . a . biggar
Biggar -- m...@biggar.org mark.a.big...@comcast.net mbig...@paypal.com - Original Message - From: Mark J. Reed To: perl6-langu...@perl.org Sent: Mon, 29 Mar 2010 14:27:00 +0000 (UTC) Subject: Regex interpolation Is there not a way to run arbitrary code and interpolate the result as a literal string

Regex interpolation

2010-03-29 Thread Mark J. Reed
Is there not a way to run arbitrary code and interpolate the result as a literal string (instead of a Regex)? I assume that {...} is intended to be where you hook in semantics/actions mid-parse, but it seems a bit counter-intuitive that the same syntax interpolates in double-quote context but not