Note that I sent a patch to that effect to p6c Jun 2 in a mail titled "support of parsing from a non TOP rule" that has not been applied. It still works. Attached below. Testable by :
use Test; grammar A { token hi { hi } }; ok A.parse( 'hi',
:rule<hi>) eq 'hi', "Grammar.parse: :rule<somerule>"
On Sun, Jul 18, 2010 at 10:40 PM, <[email protected]> wrote:
> Author: moritz
> Date: 2010-07-18 22:40:18 +0200 (Sun, 18 Jul 2010)
> New Revision: 31755
>
> Modified:
> docs/Perl6/Spec/S05-regex.pod
> Log:
> [S05] specifiy that .parse can invoke other subrules than TOP by name
>
> Modified: docs/Perl6/Spec/S05-regex.pod
> ===================================================================
> --- docs/Perl6/Spec/S05-regex.pod 2010-07-18 15:13:40 UTC (rev 31754)
> +++ docs/Perl6/Spec/S05-regex.pod 2010-07-18 20:40:18 UTC (rev 31755)
> @@ -3943,7 +3943,10 @@
> 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
> +or rule) of C<MyGrammar>. The default rule name to call can be overridden
> with
> +the C<:rule> named argument of the C<parse> method.
> +
> +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
>
>
--
cognominal stef
parrot-parse_with_rule.2010-06-02.patch
Description: Binary data
