Author: lwall
Date: 2010-06-11 19:00:19 +0200 (Fri, 11 Jun 2010)
New Revision: 31195

Modified:
   docs/Perl6/Spec/S05-regex.pod
Log:
[S05] mention TOP, and explain how parsing is initiated and how it actually 
works


Modified: docs/Perl6/Spec/S05-regex.pod
===================================================================
--- docs/Perl6/Spec/S05-regex.pod       2010-06-11 15:22:00 UTC (rev 31194)
+++ docs/Perl6/Spec/S05-regex.pod       2010-06-11 17:00:19 UTC (rev 31195)
@@ -16,8 +16,8 @@
 
     Created: 24 Jun 2002
 
-    Last Modified: 4 Jun 2010
-    Version: 124
+    Last Modified: 11 Jun 2010
+    Version: 125
 
 This document summarizes Apocalypse 5, which is about the new regex
 syntax.  We now try to call them I<regex> rather than "regular
@@ -1953,6 +1953,10 @@
 
 (This is true for all quotelike constructs in PerlĀ 6.)
 
+The C<rx> form may be used directly as a pattern anywhere a normal C<//> match 
can.
+The C<regex> form is really a method definition, and must be used in such a 
way that
+the grammar class it is to be used in is apparent.
+
 =item *
 
 If either form needs modifiers, they go before the opening delimiter:
@@ -3921,11 +3925,28 @@
 
 =item *
 
-A string can be matched against a grammar by calling C<.parse> on the grammar,
-and optionally pass an I<actions> object to that grammar:
+A string can be matched against a grammar by calling C<.parse>
+or C<.parsefile> on the grammar, and optionally pass an I<actions>
+object to that grammar:
 
-    MyGrammar.parse($str, :actions($action-object))
+    MyGrammar.parse($string, :actions($action-object))
+    MyGrammar.parse($filename, :actions($action-object))
 
+This creates a C<Grammar> object, whose type denotes the current language being
+parsed, and from which other grammars may be derived as extended languages.
+All grammar objects are derived from C<Cursor>, so every grammar object's
+value embodies the current state of the current match.  This new grammar
+object is then passed as the invocant to the C<TOP> method (regex, token,
+or rule) of C<MyGrammar>.  Grammar objects are considered immutable, so
+every match returns a different match state, and multiple match states may
+exist simultaneously.  Each such match state is considered a hypothesis on
+how the pattern will eventually match.  A backtrackable choice in pattern
+matching may be easily represented in Perl 6 as a lazy list of match state
+cursors; backtracking consists of merely throwing away the front value of
+the list and continuing to match with the next value.  Hence, the management
+of these match cursors controls how backtracking works, and falls naturally
+out of the lazy list paradigm.
+
 =back
 
 =head1 Syntactic categories

Reply via email to