Re: r31755 -[S05] specifiy that .parse can invoke other subrules than TOP by name

2010-07-19 Thread Stéphane Payrard
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',
:rulehi) eq 'hi',  Grammar.parse: :rulesomerule

On Sun, Jul 18, 2010 at 10:40 PM,  pugs-comm...@feather.perl6.nl 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 CCursor, 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 CTOP method (regex, token,
 -or rule) of CMyGrammar.  Grammar objects are considered immutable, so
 +or rule) of CMyGrammar. The default rule name to call can be overridden 
 with
 +the C:rule named argument of the Cparse 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


Re: r31755 -[S05] specifiy that .parse can invoke other subrules than TOP by name

2010-07-19 Thread Moritz Lenz

Hi,

Am 19.07.2010 04:20, schrieb Stéphane Payrard:

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


Either somebody applied it, or it was superfluous - :rulerulename 
works in Rakudo (though I don't know if it works in nqp-rx).

Anyway, thanks for your patch.


use Test;  grammar A { token hi { hi } };  ok   A.parse( 'hi',
:rulehi) eq 'hi',  Grammar.parse: :rulesomerule


Test passes.

BTW it's preferrable to use is($got, $expected, $message) instead of 
is($got eq $expected, $message), because the former gives better 
diagnostics if the test fails.


Cheers,
Moritz