r31918 -[S05] be explicit about which attributes/modifiers are allowed where

2010-08-06 Thread pugs-commits
Author: moritz
Date: 2010-08-06 19:52:06 +0200 (Fri, 06 Aug 2010)
New Revision: 31918

Modified:
   docs/Perl6/Spec/S05-regex.pod
Log:
[S05] be explicit about which attributes/modifiers are allowed where

Also removes rx:g// from existing examples.
Added myself boldly to AUTHORS list

Modified: docs/Perl6/Spec/S05-regex.pod
===
--- docs/Perl6/Spec/S05-regex.pod   2010-08-06 17:52:01 UTC (rev 31917)
+++ docs/Perl6/Spec/S05-regex.pod   2010-08-06 17:52:06 UTC (rev 31918)
@@ -11,13 +11,14 @@
 Allison Randal 
 Patrick Michaud 
 Larry Wall 
+Moritz Lenz 
 
 =head1 VERSION
 
 Created: 24 Jun 2002
 
-Last Modified: 11 Jul 2010
-Version: 128
+Last Modified: 6 Aug 2010
+Version: 129
 
 This document summarizes Apocalypse 5, which is about the new regex
 syntax.  We now try to call them I rather than "regular
@@ -604,6 +605,56 @@
 
 =back
 
+=head2 Allowed modifiers
+
+Some modifiers are allowed in all possible places where modifiers can occur,
+but not all of them.
+
+In general, a modifier that affects the compilation of a regex (like C<:i>)
+must be known at compile time. A modifier that affects only the calling
+behaviour, and not the regex itself (eg. C<:pos>, C<:overlap>, C<:x(4)>) may
+only appear on constructs that involve a call (like C and C), and
+not on C. Finally overlapping is disallowed on substitutions, while
+adverbs that affect modifications (eg. C<:samecase>) are only allowed on
+substitutions.
+
+These principle result in the following rules:
+
+=over
+
+=item *
+
+The C<:ignorecase>, C<:ignoremark> C<:sigspace>, C<:ratchet> and C<:Perl5>
+modifiers and their short forms are allowed everywhere: inside a regex,
+and on C, C and C constructs. An implementation may require
+that their value is known at compile time, and give a compile-time error
+message if that is not the case.
+
+rx:i/ hello /   # OK
+rx:i(1) /hello/ # OK
+my $i = 1;
+rx:i($i) /hello/# may error out at compile time
+
+=item *
+
+The C<:samecase>, C<:samespace> and C<:samemark> modifiers (and their short
+forms) modifiers are only allowed on substitutions (C and C).
+
+=item *
+
+The C<:overlap> and C<:exhaustive> modifiers (and their short forms) are only
+allowed on matches (ie C), not on substitutions or regex quotes.
+
+=item * 
+
+The C<:pos>, C<:continue>, C<:x> and C<:nth> modifiers and their aliases are
+only allowed on constructs that involve immediate calls, eg. C and C
+(but not on C).
+
+=item *
+
+The C<:dba> adverb is only allowed inside a regex.
+
 =head1 Changed metacharacters
 
 =over
@@ -1967,8 +2018,8 @@
 
 If either form needs modifiers, they go before the opening delimiter:
 
- $regex = regex :g:s:i { my name is (.*) };
- $regex = rx:g:s:i / my name is (.*) /;# same thing
+ $regex = regex :s:i { my name is (.*) };
+ $regex = rx:s:i / my name is (.*) /;# same thing
 
 Space is necessary after the final modifier if you use any
 bracketing character for the delimiter.  (Otherwise it would be taken as
@@ -1979,7 +2030,7 @@
 You may not use colons for the delimiter.  Space is allowed between
 modifiers:
 
- $regex = rx :g :s :i / my name is (.*) /;
+ $regex = rx :s :i / my name is (.*) /;
 
 =item *
 



r31919 -[S03] smart-match entry for Match on RHS

2010-08-06 Thread pugs-commits
Author: moritz
Date: 2010-08-06 19:52:10 +0200 (Fri, 06 Aug 2010)
New Revision: 31919

Modified:
   docs/Perl6/Spec/S03-operators.pod
Log:
[S03] smart-match entry for Match on RHS

After some discussion with @Larry on YAPC::EU, we figured that's the best way
to solve the dilemma that C<'string' ~~ m/regex/> immediately matches on the
right-hand side, thus ends up calling $/.ACCEPTS('string').

Modified: docs/Perl6/Spec/S03-operators.pod
===
--- docs/Perl6/Spec/S03-operators.pod   2010-08-06 17:52:06 UTC (rev 31918)
+++ docs/Perl6/Spec/S03-operators.pod   2010-08-06 17:52:10 UTC (rev 31919)
@@ -3536,6 +3536,8 @@
 Array Regex array "boolean grep".any.match(X)
 Any   Regex pattern match   .match(X)
 
+Any   Match identity$_
+
 Num   Range in numeric rangeX.min <= $_ <= X.max (mod ^'s)
 Str   Range in string range X.min le $_ le X.max (mod ^'s)
 Any   Range in generic range[!after] X.min,$_,X.max (etc.)



Re: pattern alternation (was Re: How are ...)

2010-08-06 Thread Moritz Lenz


Darren Duncan wrote:
> David Green wrote:
>> On 2010-08-05, at 8:27 am, Aaron Sherman wrote:
>>> On Thu, Aug 5, 2010 at 7:55 AM, Carl Mäsak  wrote:
 I see this particular thinko a lot, though. Maybe some Perl 6 lint tool
 or another will detect when you have a regex containing ^ at its start, $
 at the end, | somewhere in the middle, and no [] to disambiguate.
>> 
>> I think conceptually the beginning and the end of a string feels like a
>> bracketing construct (only without symmetrical symbols).  At least that seems
>> to be my instinct.  Well, it doesn't in / ^foo | ^bar | ^qux /, but in
>> something like /^ foo|bar $/, the context immediately implies a higher
>> precedence for ^ and $.  Maybe something like // foo|bar // could work as a
>> bracketing version?
> 
> Personally, I had always considered the ^ and $ to be the lowest precedence 
> things in a pattern. 

Meta characters don't have a precedence on their on - concatenation has.

Cheers,
Moritz