Author: lwall
Date: 2009-01-27 01:08:23 +0100 (Tue, 27 Jan 2009)
New Revision: 25048

Modified:
   docs/Perl6/Spec/S05-regex.pod
   src/perl6/STD.pm
Log:
[STD, S05] converge spec and parse of character classes


Modified: docs/Perl6/Spec/S05-regex.pod
===================================================================
--- docs/Perl6/Spec/S05-regex.pod       2009-01-26 22:33:20 UTC (rev 25047)
+++ docs/Perl6/Spec/S05-regex.pod       2009-01-27 00:08:23 UTC (rev 25048)
@@ -14,9 +14,9 @@
    Maintainer: Patrick Michaud <pmich...@pobox.com> and
                Larry Wall <la...@wall.org>
    Date: 24 Jun 2002
-   Last Modified: 17 Nov 2008
+   Last Modified: 26 Jan 2009
    Number: 5
-   Version: 86
+   Version: 87
 
 This document summarizes Apocalypse 5, which is about the new regex
 syntax.  We now try to call them I<regex> rather than "regular
@@ -1399,7 +1399,8 @@
     <alpha>
 
 However, in order to combine classes you must prefix a named
-character class with C<+> or C<->.
+character class with C<+> or C<->.  Whitespace is required before
+any C<-> that would be misparsed as an identifier extender.
 
 =item *
 

Modified: src/perl6/STD.pm
===================================================================
--- src/perl6/STD.pm    2009-01-26 22:33:20 UTC (rev 25047)
+++ src/perl6/STD.pm    2009-01-27 00:08:23 UTC (rev 25048)
@@ -3758,7 +3758,7 @@
         || [ <?before \s | '#'> <nextsame> ]?   # still get all the pod 
goodness, hopefully
     }
 
-    token sigspace {
+    token normspace {
         <?before \s | '#'> [ :lang($¢.cursor_fresh($+LANG)) <.ws> ]
     }
 
@@ -3832,7 +3832,7 @@
     # "normal" metachars
 
     token metachar:sigwhite {
-        <sigspace>
+        <normspace>
     }
 
     token metachar:sym<{ }> {
@@ -3988,23 +3988,25 @@
                                     ]?
     }
 
-    token assertion:sym<[> { <before '[' > <cclass_elem> ** < + - > }
-    token assertion:sym<+> { <sym> <cclass_elem> ** < + - > }
-    token assertion:sym<-> { <sym> <cclass_elem> ** < + - > }
+    token assertion:sym<[> { <?before '['> <cclass_elem>+ }
+    token assertion:sym<+> { <?before '+'> <cclass_elem>+ }
+    token assertion:sym<-> { <?before '-'> <cclass_elem>+ }
     token assertion:sym<.> { <sym> }
     token assertion:sym<,> { <sym> }
     token assertion:sym<~~> { <sym> [ <?before '>'> | \d+ | <desigilname> ] }
 
     token assertion:bogus { <.panic: "Unrecognized regex assertion"> }
 
+    token sign { '+' | '-' | <?> }
     token cclass_elem {
-        <.ws>
         :dba('character class element')
+        <sign>
+        <.normspace>?
         [
         | <name>
         | <before '['> <quibble($¢.cursor_fresh( ::STD::Q ).tweak(:q))> # XXX 
parse as q[] for now
         ]
-        <.ws>
+        <.normspace>?
     }
 
     token mod_arg { :dba('modifier argument') '(' ~ ')' <semilist> }
@@ -4044,7 +4046,7 @@
     token quantifier:sym<*>  { <sym> <quantmod> }
     token quantifier:sym<+>  { <sym> <quantmod> }
     token quantifier:sym<?>  { <sym> <quantmod> }
-    token quantifier:sym<**> { <sym> :: <sigspace>? <quantmod> <sigspace>?
+    token quantifier:sym<**> { <sym> :: <normspace>? <quantmod> <normspace>?
         [
         | \d+ [ '..' [ \d+ | '*' ] ]?
         | <codeblock>
@@ -4057,7 +4059,7 @@
         | '!' <sym>
         | <sym>
         ]
-        <sigspace> <quantified_atom> }
+        <normspace> <quantified_atom> }
 
     token quantmod { ':'? [ '?' | '!' | '+' ]? }
 

Reply via email to