Re: Regex query

2002-09-23 Thread Simon Cozens
[EMAIL PROTECTED] (Luke Palmer) writes: > Since we now have an explicit flattening operator (unary *), there's no > need to differentiate between a "real" list and a reference to one. What context does "push" impute on its operands? If push @a, [1,2,3,4]; and push @a, 1,2,3,4; are goi

Re: Regex query

2002-09-23 Thread Andrew Rodland
On Sat, 21 Sep 2002 16:33:31 -0600 (MDT), Luke Palmer said: > You know, the idea that square brackets are the only things that can > make lists is starting to really appeal to me. Similar for squiggles > and hashes. I don't know how many times in my early Perl5 days I did > this: > Since we no

Re: Regex query

2002-09-22 Thread Chip Salzenberg
According to John Williams: > On Sat, 21 Sep 2002, Jonathan Scott Duff wrote: > > (7,) is an abomination. It's one of python's misfeatures that annoys > > me the most. > > Of course, _requiring_ the comma is bad [...] Well, I don't know about Jonathan, but requiring the comma is exactly what Py

Re: Regex query

2002-09-22 Thread John Williams
On Sat, 21 Sep 2002, Jonathan Scott Duff wrote: > > Why can't perl be smart enough to figure out what we mean? Something > along these lines: > > (7) # list context > (3+4) # numeric context (there's a numeric operator in there) > (3+4,5) # list context (comma trumps the n

Re: Regex query

2002-09-22 Thread Simon Cozens
[EMAIL PROTECTED] (Markus Laire) writes: > How do you do C< ($a + $b) * $c > if parentheses are forbidden for > mathematical expressions? I thought that , was actually the list constructor, much as => is the pair constructor. (And hence a => 1, b => 2 would be a list of pairs.) Of co

Re: Regex query

2002-09-22 Thread Markus Laire
And the one best reason I forgot to include: How do you do C< ($a + $b) * $c > if parentheses are forbidden for mathematical expressions? -- Markus Laire 'malaire' <[EMAIL PROTECTED]>

Re: Regex query

2002-09-22 Thread Dan Sugalski
At 10:52 AM -0500 9/21/02, Jonathan Scott Duff wrote: >So, you expect 7.pow(2) to work? I'd expect it to be an error (this >isn't python after all). Sure, why not? I mean, we already use methods on integers all the time--what do you thin 12.5 is anyway, other than calling the 5 method on the c

Re: Regex query

2002-09-22 Thread Pixel
Chip Salzenberg <[EMAIL PROTECTED]> writes: > According to David Whipp: > > (7,8,9) == 3 # true > > (7,8) == 2 # true > > (7) == 1 # false > > () == 0 # true? > > Hell, yes, why didn't I think of that? This is exactly the same > problem that afflicts Python's tuple syntax! v

Re: Regex query

2002-09-22 Thread Simon Cozens
[EMAIL PROTECTED] (Smylers) writes: > Does that matter? This example is fairly contrived, and anybody > actually concerned about this can always use: > > $num = @massive.length; I'd be in favour of forcing people to say this if they want the length of the array. But then, it might be that wh

Re: Regex query

2002-09-22 Thread Simon Cozens
[EMAIL PROTECTED] (Jonathan Scott Duff) writes: > Why can't perl be smart enough to figure out what we mean? We're talking about lists, the second most fundamental data structure in the language. If we have to resort to much magic to get these right, we're pretty much doomed from the outset. --

Re: Regex query

2002-09-21 Thread matt diephouse
Luke Palmer wrote: >On Sun, 22 Sep 2002, Markus Laire wrote: >You know, the idea that square brackets are the only things that can make >lists is starting to really appeal to me. Similar for squiggles and > >So parens really do provide grouping, not list constructing. Thus, this >can stay:

Re: Regex query

2002-09-21 Thread Luke Palmer
On Sun, 22 Sep 2002, Markus Laire wrote: > > On Sat, Sep 21, 2002 at 11:36:49AM -0600, John Williams wrote: > > > On Sat, 21 Sep 2002, Jonathan Scott Duff wrote: > > > > > > Anyway, (7) or (3+4) should yield a number, not a list, because > > > otherwise every math expression will break. > > > >

Re: Regex query

2002-09-21 Thread Markus Laire
> On Sat, Sep 21, 2002 at 11:36:49AM -0600, John Williams wrote: > > On Sat, 21 Sep 2002, Jonathan Scott Duff wrote: > > > > Anyway, (7) or (3+4) should yield a number, not a list, because > > otherwise every math expression will break. > > Why can't perl be smart enough to figure out what we me

Re: hotplug regexes, other misc regex questions

2002-09-21 Thread Steve Fink
On Wed, Sep 18, 2002 at 05:01:35PM +0200, Damian Conway wrote: > Steve Fink wrote: > > >What possible outputs are legal for this: > > > > "aaa" =~ /( a { print 1 } | a { print 2 })* { print "\n" } x/ > > Unless Larry specifies a required semantics, there are potentially very > many acceptable o

Re: Regex query

2002-09-21 Thread Luke Palmer
On 21 Sep 2002, Smylers wrote: > Luke Palmer wrote: > > > my @v = $( &func() ); > > > > Would provide scalar context. But then assign it to a list... > > In the course of reading that I developed a concern about memory usage > when trying to find the size of arrays. As I understand it th

Re: hotplug regexes, other misc regex questions

2002-09-21 Thread Steve Fink
On Mon, Sep 16, 2002 at 10:32:17AM +0300, Markus Laire wrote: > On 15 Sep 2002 at 22:41, Steve Fink wrote: > > Your code seems to backtrack to the beginning at every failure. First > code only backtracks one char at time. > > Huh? What implementation is that? I think my naive implementation > >

Re: Regex query

2002-09-21 Thread Jonathan Scott Duff
On Sat, Sep 21, 2002 at 11:36:49AM -0600, John Williams wrote: > On Sat, 21 Sep 2002, Jonathan Scott Duff wrote: > > > I can't tell whether (7).length is asking for the length > > > of 7 or the length of a list, but I would be badly surprised if > > > (3+4).pow(2) returned 1 instead of 49. > > > >

Re: Regex query

2002-09-21 Thread John Williams
On 21 Sep 2002, Smylers wrote: > > Does that matter? This example is fairly contrived, and anybody > actually concerned about this can always use: > > $num = @massive.length; > > So perhaps this isn't a problem. $num = +@massive; would also set $num to the length, not the ref. ~ John Willi

Re: Regex query

2002-09-21 Thread John Williams
On Sat, 21 Sep 2002, Jonathan Scott Duff wrote: > > I can't tell whether (7).length is asking for the length > > of 7 or the length of a list, but I would be badly surprised if > > (3+4).pow(2) returned 1 instead of 49. > > So, you expect 7.pow(2) to work? I'd expect it to be an error (this > isn

Re: Regex query

2002-09-21 Thread Jonathan Scott Duff
On Fri, Sep 20, 2002 at 09:46:58PM -0600, John Williams wrote: > On Fri, 20 Sep 2002, Jonathan Scott Duff wrote: > > > But I cannot tell whether (7) is list context or numeric context, > > > > Nope, you can't tell without the surrounding context: > > > > (7) + 0;# numeric > > $a =

Re: Regex query

2002-09-21 Thread Smylers
Tanton Gibbs wrote: > (7) == 7 > > why? Otherwise, we couldn't use parens for mathematical expressions But as Luke Palmer pointed about above, this syntax would make square brackets redundant, so we could now use those unambiguously for overriding mathematical precedence ... (Sorry about t

Re: Regex query

2002-09-21 Thread Smylers
Luke Palmer wrote: > my @v = $( &func() ); > > Would provide scalar context. But then assign it to a list... In the course of reading that I developed a concern about memory usage when trying to find the size of arrays. As I understand it the Perl 5 syntax for discovering the number of

Re: Regex query

2002-09-20 Thread John Williams
On Fri, 20 Sep 2002, Jonathan Scott Duff wrote: > > But I cannot tell whether (7) is list context or numeric context, > > Nope, you can't tell without the surrounding context: > > (7) + 0;# numeric > $a = (7); # list > (7) == 1; # boolean (same as (7).length =

Re: Regex query

2002-09-20 Thread Tanton Gibbs
> > This kind of clever magic always makes me nervous: > > it introduces subtle bug potentials. > > > > (7,8,9) == 3 # true > > (7,8) == 2 # true > > (7) == 1 # false > > Why is this one false? I'd expect it to be true just as the others. (7) == 7 why? Otherwise, we couldn't use

Re: Regex query

2002-09-20 Thread Jonathan Scott Duff
On Fri, Sep 20, 2002 at 10:16:38PM -0400, Chip Salzenberg wrote: > According to John Williams: > > I believe the last two cases should be: > > (7,)== 1 > > (,) == 0 > > Gack! It's Python's tuple syntax! Run away! Run away! > > Seriously, having actually programmed Python for m

Re: Regex query

2002-09-20 Thread Jonathan Scott Duff
On Fri, Sep 20, 2002 at 02:17:42PM -0700, David Whipp wrote: > Larry wrote: > > : $shouldbe3 = (1,2,3) + 0; > > > > It's 3, though not for the reason a Perl 5 programmer would think. > > (In Perl 6 it's the length of the anonymous array, not the > > last value.) > > This kind of clever magic

Re: Regex query

2002-09-20 Thread Jonathan Scott Duff
On Fri, Sep 20, 2002 at 09:02:52PM -0600, John Williams wrote: > On Fri, 20 Sep 2002, Tanton Gibbs wrote: > > If this is the case, then can you also have: > > > > (,7) > > > > What is its length? > > Hmm, it's a syntax error in perl5. I'd advocate it continuing to be a syntax error in perl 6.

Re: Regex query

2002-09-20 Thread John Williams
On Fri, 20 Sep 2002, Tanton Gibbs wrote: > > I believe the last two cases should be: > > > > (7,)== 1 > > (,) == 0 > > > > Because its the perl6 comma that creates the list, not the parenthesis. > > > > ~ John Williams > > If this is the case, then can you also have: > > (,7) > >

Re: Regex query

2002-09-20 Thread Chip Salzenberg
According to John Williams: > I believe the last two cases should be: > (7,)== 1 > (,) == 0 Gack! It's Python's tuple syntax! Run away! Run away! Seriously, having actually programmed Python for money (no smiley -- it was NOT fun), I can say that this syntactical hack would be

Re: Regex query

2002-09-20 Thread Tanton Gibbs
> > This kind of clever magic always makes me nervous: > > it introduces subtle bug potentials. > > > > (7,8,9) == 3 # true > > (7,8) == 2 # true > > (7) == 1 # false > > () == 0 # true? > > I believe the last two cases should be: > > (7,)== 1 > (,) == 0 > > B

RE: Regex query

2002-09-20 Thread John Williams
On Fri, 20 Sep 2002, David Whipp wrote: > Larry wrote: > > : $shouldbe3 = (1,2,3) + 0; > > > > It's 3, though not for the reason a Perl 5 programmer would think. > > (In Perl 6 it's the length of the anonymous array, not the > > last value.) > > This kind of clever magic always makes me nervous:

Re: Regex query

2002-09-20 Thread Luke Palmer
On Fri, 20 Sep 2002, Chip Salzenberg wrote: > According to Luke Palmer: > > I think to get Perl5 behavioueaur :), you do this: > > > > my @flatL = ( *("1a", "2a"), *("1b", "2b") ); > > Geez, I hope not, because that would imply that in > > my @v = ( &func() ); > > that &func is called

Re: Regex query

2002-09-20 Thread Chip Salzenberg
According to David Whipp: > (7,8,9) == 3 # true > (7,8) == 2 # true > (7) == 1 # false > () == 0 # true? Hell, yes, why didn't I think of that? This is exactly the same problem that afflicts Python's tuple syntax! Larry, I strongly suggest that making () act in any way like [

RE: Regex query

2002-09-20 Thread David Whipp
Larry wrote: > : $shouldbe3 = (1,2,3) + 0; > > It's 3, though not for the reason a Perl 5 programmer would think. > (In Perl 6 it's the length of the anonymous array, not the > last value.) This kind of clever magic always makes me nervous: it introduces subtle bug potentials. (7,8,9) ==

Re: Regex query

2002-09-20 Thread Chip Salzenberg
According to Luke Palmer: > I think to get Perl5 behavioueaur :), you do this: > > my @flatL = ( *("1a", "2a"), *("1b", "2b") ); Geez, I hope not, because that would imply that in my @v = ( &func() ); that &func is called in a scalar context. -- Chip Salzenberg - a.k.a. -

Re: Regex query

2002-09-20 Thread Luke Palmer
> >I was just thinking that $((1,2,3)) is also the same as [1,2,3], > >and shorter than scalar(1,2,3). > > > I wonder if you can't just use $(1, 2, 3) to the same effect. I think you can. I was under the impression that the C comma was dying, so that would have to make a list or err. > Al

Re: Regex query

2002-09-20 Thread matt diephouse
John Williams wrote: >On Fri, 20 Sep 2002, Larry Wall wrote: > > >>On Fri, 20 Sep 2002, John Williams wrote: >>: On Fri, 20 Sep 2002, Larry Wall wrote: >>: > >>: > Yes, in fact any list forced into scalar context will make a ref in Perl 6: >>: > >>: > $arrayref = (1,2,3); >>: >>: That wou

Re: Regex query

2002-09-20 Thread John Williams
On Fri, 20 Sep 2002, Larry Wall wrote: > On Fri, 20 Sep 2002, John Williams wrote: > : On Fri, 20 Sep 2002, Larry Wall wrote: > : > > : > Yes, in fact any list forced into scalar context will make a ref in Perl 6: > : > > : > $arrayref = (1,2,3); > : > : That would seem to obviate the need for

Re: Regex query

2002-09-20 Thread Larry Wall
On Fri, 20 Sep 2002, John Williams wrote: : On Fri, 20 Sep 2002, Larry Wall wrote: : > : > Yes, in fact any list forced into scalar context will make a ref in Perl 6: : > : > $arrayref = (1,2,3); : : That would seem to obviate the need for brackets to define array : references. Is there any

Re: hotplug regexes, other misc regex questions

2002-09-20 Thread Larry Wall
ters, or we have to : > adjust all known pointers any time the string may be modified. : : With the current Parrot GC, keeping pointers into the string while doing : unrelated allocation will get you a core dump, since the string body might : be copied. So unless the regex engine copies st

Re: Regex query

2002-09-20 Thread John Williams
On Fri, 20 Sep 2002, Larry Wall wrote: > > Yes, in fact any list forced into scalar context will make a ref in Perl 6: > > $arrayref = (1,2,3); That would seem to obviate the need for brackets to define array references. Is there any case where [1,2,3] would be needed instead of (1,2,3)? Al

Re: hotplug regexes, other misc regex questions

2002-09-20 Thread Sean O'Rourke
y time the string may be modified. With the current Parrot GC, keeping pointers into the string while doing unrelated allocation will get you a core dump, since the string body might be copied. So unless the regex engine copies strings off into its own private non-collected storage, we're stuc

Re: Regex query

2002-09-20 Thread Aaron Sherman
On Fri, 2002-09-20 at 10:39, Larry Wall wrote: > On 20 Sep 2002, Aaron Sherman wrote: > : Is that "any list" as oppopsed to "any array"? Or is that arrayref in a > : numeric context the length of the array? In other words does this do > : what I think I think it does? > : > : $shouldbe3 = (1,

Re: Regex query

2002-09-20 Thread Larry Wall
On 20 Sep 2002, Aaron Sherman wrote: : Is that "any list" as oppopsed to "any array"? Or is that arrayref in a : numeric context the length of the array? In other words does this do : what I think I think it does? : : $shouldbe3 = (1,2,3) + 0; It's 3, though not for the reason a Perl 5 pro

Re: Regex query

2002-09-20 Thread Aaron Sherman
On Fri, 2002-09-20 at 04:14, Larry Wall wrote: > On 20 Sep 2002, Simon Cozens wrote: > : > their names. also if you use a scalar to grab something which is in a > : > quantified outer rule what is put in the var? a ref to a list of the > : > grabbed things? > : > : *nod* Something I'd like to kno

Re: hotplug regexes, other misc regex questions

2002-09-20 Thread Larry Wall
On Sun, 15 Sep 2002, Steve Fink wrote: : What should this do: : : my $x = "the letter x"; : print "yes" if $x =~ /the { $x .= "!" } .* !/; Depends. I think it may be necessary for speed and safety reasons to set COW on the string we're matching, so that you're always matching against the or

Re: Regex query

2002-09-20 Thread Larry Wall
On 20 Sep 2002, Simon Cozens wrote: : > their names. also if you use a scalar to grab something which is in a : > quantified outer rule what is put in the var? a ref to a list of the : > grabbed things? : : *nod* Something I'd like to know. Yes, in fact any list forced into scalar context will m

Re: Regex query

2002-09-20 Thread Uri Guttman
> "SC" == Simon Cozens <[EMAIL PROTECTED]> writes: SC> [EMAIL PROTECTED] (Uri Guttman) writes: >> actually i just had another thought. you don't need any of the $foo := >> stuff as the match tree will have it all for you. SC> Yes, but it's nice to be able to access the captured thin

Re: Regex query

2002-09-19 Thread Simon Cozens
[EMAIL PROTECTED] (Uri Guttman) writes: > actually i just had another thought. you don't need any of the $foo := > stuff as the match tree will have it all for you. Yes, but it's nice to be able to access the captured things by name. Or should I be saying things like rule raiddev { *

Re: Regex query

2002-09-19 Thread Uri Guttman
> "SC" == Simon Cozens <[EMAIL PROTECTED]> writes: SC> rule comm_eol { ? \n }; >> >> aren't those 's redundant? the first is overlapping with the one at >> the beginning of comment. SC> But only matches if there *is* a comment, and there may not SC> be, so I want to match opt

Re: Regex query

2002-09-19 Thread Simon Cozens
[EMAIL PROTECTED] (Uri Guttman) writes: > shouldn't that have a inside the blank line? Or *, yes. > SC> rule comm_eol { ? \n }; > > aren't those 's redundant? the first is overlapping with the one at > the beginning of comment. But only matches if there *is* a comment, and there may not

Re: Regex query

2002-09-19 Thread Uri Guttman
> "SC" == Simon Cozens <[EMAIL PROTECTED]> writes: SC> raiddev /dev/md0 SC> raid-level 5 SC> option value SC> option value SC> ... SC> device /dev/sde1 SC> raid-disk 0

Regex query

2002-09-19 Thread Simon Cozens
Well, I've started my Perl 6 programming career already and I've got stuck. :) I'm trying to parse a Linux RAID table (/etc/raidtab), which looks a bit like this: raiddev /dev/md0 raid-level 5 option value option value

Re: hotplug regexes, other misc regex questions

2002-09-19 Thread Josh Jore
On Wed, 18 Sep 2002, Luke Palmer wrote: > On Wed, 18 Sep 2002, Josh Jore wrote: > > On Wed, 18 Sep 2002, Damian Conway wrote: > > > > What possible outputs are legal for this: > > > > > > > > "aaa" =~ /( a { print 1 } | a { print 2 })* { print "\n" } x/ > > > > I take it that what I've learned f

Re: hotplug regexes, other misc regex questions

2002-09-19 Thread Damian Conway
Josh Jore wrote: >>>Would it be correct for this to print 0? Would it be correct for this >>>to print 2? >>> >>> my $n = 0; >>> "aargh" =~ /a* { $n++ } aargh/; >>> print $n; >> >>Yes. ;-) > > Wouldn't that print 2 if $n is lexical Err. It *is* lexical in this example. > and 0 if it's local

Re: hotplug regexes, other misc regex questions

2002-09-18 Thread Luke Palmer
On Wed, 18 Sep 2002, Josh Jore wrote: > On Wed, 18 Sep 2002, Damian Conway wrote: > > > > Would it be correct for this to print 0? Would it be correct for this > > > to print 2? > > > > > > my $n = 0; > > > "aargh" =~ /a* { $n++ } aargh/; > > > print $n; > > > > Yes. ;-) > > Wouldn't that

Re: hotplug regexes, other misc regex questions

2002-09-18 Thread Josh Jore
On Wed, 18 Sep 2002, Damian Conway wrote: > > Would it be correct for this to print 0? Would it be correct for this > > to print 2? > > > > my $n = 0; > > "aargh" =~ /a* { $n++ } aargh/; > > print $n; > > Yes. ;-) Wouldn't that print 2 if $n is lexical and 0 if it's localized? Or are lexic

Re: hotplug regexes, other misc regex questions

2002-09-18 Thread Damian Conway
Steve Fink wrote: > What should this do: > > my $x = "the letter x"; > print "yes" if $x =~ /the { $x .= "!" } .* !/; > > Does this print "yes"? If it's allowed at all, I think the match should succeed. > print "yes" if "helo" =~ /hel { .pos-- } lo/; This definitely has to work. But r

Re: Suggestion for perl 6 regex syntax

2002-09-09 Thread Uri Guttman
> "AS" == Aaron Sherman <[EMAIL PROTECTED]> writes: AS> On Mon, 2002-09-09 at 06:05, David Helgason wrote: >> >> Yeay! Golf... >> If we are allowed to use all of perl6 in this particular (golf-)course, >> I suggest: AS> Clearly I've missed a reference at some point. Presumably

Re: Suggestion for perl 6 regex syntax

2002-09-09 Thread Mark J. Reed
On Mon, Sep 09, 2002 at 05:02:18PM -0400, Aaron Sherman wrote: > On Mon, 2002-09-09 at 06:05, David Helgason wrote: > > > > Yeay! Golf... > > > If we are allowed to use all of perl6 in this particular (golf-)course, > > I suggest: > > Clearly I've missed a reference at some point. Presumably "

Re: Suggestion for perl 6 regex syntax

2002-09-09 Thread Aaron Sherman
On Mon, 2002-09-09 at 06:05, David Helgason wrote: > > Yeay! Golf... > If we are allowed to use all of perl6 in this particular (golf-)course, > I suggest: Clearly I've missed a reference at some point. Presumably "golf" is used here to mean something like "stupid question". > Perl6 will be a

Re: Suggestion for perl 6 regex syntax

2002-09-09 Thread Aaron Sherman
[Moved over from p6i, to more appropriate p6l] On Sat, 2002-09-07 at 12:03, Mr. Nobody wrote: > While Apocolypse 5 raises some good points about problems with the old regex > syntax, its new syntax is actually worse than in perl 5. Most regexes, such > as this one to match

Re: Suggestion for perl 6 regex syntax

2002-09-09 Thread David Helgason
Yeay! Golf... Adam D. Lopresto wrote: [...golf...] > /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/ #50 chars [...more golf...] > Of course, that's because we use perl6's strengths. > > :i/^(+|-)?(\d*[\.\d*]?)<($2=~/./)>[E([+|-]?\d+)]?$/ #51 Clever! But If we are allowed to

Re: Suggestion for perl 6 regex syntax

2002-09-08 Thread Adam D. Lopresto
antissa isn't empty, making the new perl6 code actually shorter than the (correct) perl5 version. Of course, that's because we use perl6's strengths. :i/^(+|-)?(\d*[\.\d*]?)<($2=~/./)>[E([+|-]?\d+)]?$/#51 > While Apocolypse 5 raises some good points about proble

Re: Suggestion for perl 6 regex syntax

2002-09-07 Thread Luke Palmer
On Fri, 6 Sep 2002, Mr. Nobody wrote: > While Apocolypse 5 raises some good points about problems with the old regex > syntax, its new syntax is actually worse than in perl 5. Most regexes, such > as this one to match a C float > > /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+

Re: Suggestion for perl 6 regex syntax

2002-09-07 Thread Ken Fox
should probably compare non-capturing versions of the regex: /^[+-]?(?=\d|\.\d)\d*(?:\.\d*)?(?:[Ee][+-]?\d+)?$/ vs /^<[+-]>?\d*[\.\d*]?[<[Ee]><[+-]>?\d+]?$/ The <[Ee]> isn't the way I'd write it in Perl 6 -- I'd shift into case-insensitive mode temporarily bec

Suggestion for perl 6 regex syntax

2002-09-07 Thread Mr. Nobody
While Apocolypse 5 raises some good points about problems with the old regex syntax, its new syntax is actually worse than in perl 5. Most regexes, such as this one to match a C float /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/ would actually become longer: /^(<[+-]>?)\d*(\.\d*)

Re: regex args and interpolation

2002-09-06 Thread Nicholas Clark
On Fri, Sep 06, 2002 at 02:49:13PM +0100, Piers Cawley wrote: > Nicholas Clark <[EMAIL PROTECTED]> writes: > > This idea of just switching language syntax in a context-sensitive way is > > trying to make my head explode. > > But you mean that in a good way right? Anyway, he did introduce the Ye

Re: regex args and interpolation

2002-09-06 Thread Mark J. Reed
On Fri, Sep 06, 2002 at 02:34:52PM +0100, Nicholas Clark wrote: > On Wed, Sep 04, 2002 at 10:46:24PM -0400, Ken Fox wrote: > > What is really needed is something that converts the date syntax > > to normal Perl code: > > > >rule iso_date { () - > >() - > >

Re: regex args and interpolation

2002-09-06 Thread Piers Cawley
Nicholas Clark <[EMAIL PROTECTED]> writes: > On Fri, Sep 06, 2002 at 02:20:10PM +0100, Piers Cawley wrote: >> Nicholas Clark <[EMAIL PROTECTED]> writes: >> >> > On Wed, Sep 04, 2002 at 10:46:24PM -0400, Ken Fox wrote: >> >> What is really needed is something that converts the date syntax >> >> t

Re: regex args and interpolation

2002-09-06 Thread Nicholas Clark
On Fri, Sep 06, 2002 at 02:20:10PM +0100, Piers Cawley wrote: > Nicholas Clark <[EMAIL PROTECTED]> writes: > > > On Wed, Sep 04, 2002 at 10:46:24PM -0400, Ken Fox wrote: > >> What is really needed is something that converts the date syntax > >> to normal Perl code: > >> > >>rule iso_date { (

Re: regex args and interpolation

2002-09-06 Thread Piers Cawley
Nicholas Clark <[EMAIL PROTECTED]> writes: > On Wed, Sep 04, 2002 at 10:46:24PM -0400, Ken Fox wrote: >> What is really needed is something that converts the date syntax >> to normal Perl code: >> >>rule iso_date { () - >>() - >>() >>

Re: regex args and interpolation

2002-09-06 Thread Nicholas Clark
On Wed, Sep 04, 2002 at 10:46:24PM -0400, Ken Fox wrote: > What is really needed is something that converts the date syntax > to normal Perl code: > >rule iso_date { () - >() - >() >{ use grammar Perl::AbstractSyntax; >

Re: regex args and interpolation

2002-09-05 Thread Aaron Sherman
On Wed, 2002-09-04 at 22:46, Ken Fox wrote: >rule iso_date { $year:=(\d{4}) - >$month:=(\d{2}) - >$day:=(\d{2}) } You mean C<< \d<4> >>, etc. I presume.

Re: regex args and interpolation

2002-09-04 Thread Ken Fox
David Whipp wrote: > But can I use a non-constant date? You didn't show us the iso_date rule. > Obviously we could put the onus on the module writer to write super-flexible > rules/grammars. But will there be an easy way to force interpolative context > onto this type of regex-

regex args and interpolation

2002-09-04 Thread David Whipp
here. I could now write: $foo.set_date 2002-09-04; But can I use a non-constant date? Perl5: $day = "04"; $foo->set_date("2002-09-$day"); Perl6: $day = "04"; $foo.set_date 2002-09-$day; # ERROR -- doesn't match regex Perl6: $day = "04"; eval "\$f

Re: Regex stuff...

2002-08-31 Thread Damian Conway
Piers Cawley wrote: > If I replace C<< ($key, $val) >> with > > @ary = m/<$pattern>/ > > and the match succeeds, how many elements are there in @ary? Zero. No explicit captures in that pattern. > Suppose you want to use a hypothetical variable to bind a name to > a capture

Re: Regex stuff...

2002-08-31 Thread Ken Fox
Piers Cawley wrote: > Unless I'm very much mistaken, the order of execution will > look like: > > $2:=$1; $1:=$2; You're not binding $2:=$1. You're binding $2 to the first capture. By default $1 is also bound to the first capture. Assuming that numbered variables aren't special, the orde

Re: Regex stuff...

2002-08-31 Thread Markus Laire
On 31 Aug 2002 at 10:26, Piers Cawley wrote: > > my $pattern = rx:w / $1:=(\S+) = $2:=(\S+) | > > $2:=(\S+) = $1:=(\S+) /; > > Count the capturing groups. Looks like there's 4 of 'em to me. $1, $2, > $3 and $4 are automatic variables which, according to the Apocalyp

Re: Regex stuff...

2002-08-31 Thread Markus Laire
On 31 Aug 2002 at 0:17, Piers Cawley wrote: > my $pattern = rx:w / $1:=(\S+) = $2:=(\S+) | > $2:=(\S+) = $1:=(\S+) /; > > @ary = m/<$pattern>/ > > how many elements are there in @ary? I can > make a case for 4 quite happily. Certainly that's what A5 seems to

Re: Quick Perl 6 regex question

2002-07-16 Thread Luke Palmer
On Tue, 16 Jul 2002, Brent Dax wrote: > I was reading through the Monastery, and I noticed a node (about the > line between what's considered Perl discussion and what's off-topic) > that had this regex in it: > > m:iw/how [do[es]?|can] [I|one] @tasks in @non_

Quick Perl 6 regex question

2002-07-16 Thread Brent Dax
I was reading through the Monastery, and I noticed a node (about the line between what's considered Perl discussion and what's off-topic) that had this regex in it: m:iw/how [do[es]?|can] [I|one] @tasks in @non_perl_languages/ (Yes, people are already using Perl 6 regex

Re: greedy/non-greedy regex assertions

2002-07-04 Thread Larry Wall
On Thu, 4 Jul 2002, Ashley Winters wrote: : On Thursday 04 July 2002 10:47 am, Larry Wall wrote: : > On Thu, 4 Jul 2002, Ashley Winters wrote: : > So I'd guess that we just don't talk about :-1, but rather say that : > : > <*$min..$max> : > : > is naturally greedy, and as with any quantifier y

Re: greedy/non-greedy regex assertions

2002-07-04 Thread Ashley Winters
On Thursday 04 July 2002 11:07 am, Ashley Winters wrote: > > I would expect /a<*1..2>?/ to mean /[a<*1..2>]?/ just looking at it. How > can ? ever mean non-greedy unless it follows a metachar <[*+?]>? Perhaps I can respond to my own question. In /.+?/ . is an assertion, + is an assertion, and ?

Re: greedy/non-greedy regex assertions

2002-07-04 Thread Ashley Winters
On Thursday 04 July 2002 10:47 am, Larry Wall wrote: > On Thu, 4 Jul 2002, Ashley Winters wrote: > So I'd guess that we just don't talk about :-1, but rather say that > > <*$min..$max> > > is naturally greedy, and as with any quantifier you write > > <*$min..$max>? > > to get minimal match

Re: greedy/non-greedy regex assertions

2002-07-04 Thread Larry Wall
On Thu, 4 Jul 2002, Ashley Winters wrote: : I was pondering how to implement the apocalypse 5 stuff (only pondering) and I : was wondering if could be legal, indicating a greedy match. : : * = : + = : ? = <1,0> : *? = <0,Inf> : +? = <1,Inf> : ?? = <0,1> We could autoreverse, but it'd be a ba

greedy/non-greedy regex assertions

2002-07-04 Thread Ashley Winters
I was pondering how to implement the apocalypse 5 stuff (only pondering) and I was wondering if could be legal, indicating a greedy match. * = + = ? = <1,0> *? = <0,Inf> +? = <1,Inf> ?? = <0,1> Speaking of the range assertion, is there anything other than ? There used to be discussion on th

Re: Some regex syntax foibles

2002-07-02 Thread Allison Randal
On Tue, Jul 02, 2002 at 03:59:57PM -0500, Allison Randal wrote: > > The parens in #3, C<< <( code )> >>, make sense if you think of s/3/2/ Allison

Re: Some regex syntax foibles

2002-07-02 Thread Allison Randal
re what we would expect from a block than just getting a "truth" value). Think of it as analogous to C<< <$pat> >>, only the value of $pat is returned instead of pre-existing within a variable. And, C< $( code ) > fits nicely with the general (non-regex) syntax for interpolating a scalar expression. Allison

Some regex syntax foibles

2002-07-01 Thread Me
Current p6 rx syntax aiui regarding embedded code: / #1 do (may include an explicit fail): { code } #2 do with implicit 'or fail' <( code )> #3 interp lit: $( { code } ) #4 interp as rx: <{ code }> / This feels cryptic. Do we need abbreviated syntax for

Re: regex and xml/html/*ml

2002-06-05 Thread Michel Rodriguez
On Wed, 5 Jun 2002 [EMAIL PROTECTED] wrote: > Just read (skimmed) apocalypse 5, had one concern - it looks like we are on a > serious collision course with parsing the various *mls. > > before: > > m#..etc# > > after > > m#\\\# > > Also, the space being backslashed sort of bugs me. Surely th

RE: regex and xml/html/*ml

2002-06-05 Thread Erik Steven Harrison
after ># ># m#\\\# > >That's intentional. What will that regex do with this? > > > >That's interpreted the same way, but typed a bit differently. It won't >match your regex. > >The moral of the story is that you should not try to parse the *MLs with

RE: regex and xml/html/*ml

2002-06-05 Thread Brent Dax
[EMAIL PROTECTED]: # Just read (skimmed) apocalypse 5, had one concern - it looks # like we are on a serious collision course with parsing the # various *mls. # # before: # # m#..etc# # # after # # m#\\\# That's intentional. What will that regex do with this? That's i

regex and xml/html/*ml

2002-06-05 Thread esp5
hmm. Just read (skimmed) apocalypse 5, had one concern - it looks like we are on a serious collision course with parsing the various *mls. before: m#..etc# after m#\\\# Also, the space being backslashed sort of bugs me. Surely there is going to be a 'non-x' modifier? And perhaps a modifier t

Re: Using closures for regex control

2002-05-20 Thread Larry Wall
_ pat2 _ pat3 and capture pat2 match: : / pat1 { ($foo) = / pat2 / } pat3 / : : work? As long as they're all working off of the same regex state, I don't see why not. Except that you'd better have a () in pat2 to capture something, if we keep the same rules as Perl 5. :

Re: Using closures for regex control

2002-05-20 Thread Me
/ pat1 { ($foo) = / pat2 / } pat3 / work? > I don't think the return of the closure will be interpreted as > [a string to be matched or a boolean success indicator or > indeed anything, at least not something that the regex > pays attention to]. Closures will be used for si

Re: Using closures for regex control

2002-05-19 Thread Larry Wall
Me writes: : [modified repost due to warnock's dilemma] : : Would something like these DWIM? : : # match pat1 _ pat2 and capture pat2 match: : / pat1 { ($foo) = / pat2 / } / Yes, though I think we'll see people doing it more like this: / pat1 ( pat2 ) { $foo = $-1 } / We might al

Using closures for regex control

2002-04-27 Thread Me
[modified repost due to warnock's dilemma] Would something like these DWIM? # match pat1 _ pat2 and capture pat2 match: / pat1 { ($foo) = / pat2 / } / # match pat1 _ 'foo bar': / pat1 { 'foo bar' } / # match pat2 if not pat1 / { ! /pat1/ } pat2 } / # match pat2 if

Re: Regex and Matched Delimiters

2002-04-24 Thread Rafael Garcia-Suarez
Michael G Schwern wrote in perl.perl6.language : > On Tue, Apr 23, 2002 at 11:11:28PM -0500, Me wrote: >> Third, I was thinking that having perl 6 regexen have /s on >> by default would be easy for perl 5 coders to understand; >> not too hard to get used to; and have no negative effects >> for exi

Re: Regex and Matched Delimiters

2002-04-23 Thread Me
> when matching against something like "foo\nwiffle\nbarfoo\n" >/(foo.*)$/ # matches the last line /(foo[^\n]*)$/ # assuming perl 6 meaning of $, end of string >/(foo.*)$/m # matches the first line /(foo[^\n]*)$$/ # assuming perl 6 meaning of $$, end of line or /(foo.*?

<    1   2   3   >