On Sun, Dec 27, 2009 at 01:30:18AM -0800, Ovid wrote:
> 
>     my $config = Config::Tiny::Grammar.parse($text);
>     #say $config ?? 'yes' || 'no';
>     say $config.perl;
> 

> Currently this matches, but if I add a \s* before the final \n 
> in the section token, it fails to match.  I don't know why 
> this is and I'm unsure of how to debug Perl 6 regexes.

Any \s* will end up matching the final \n, and since quantifiers
in tokens default to "non backtracking", \s* \n in a token will 
always fail.  (In P5, it'd be like "(?>\s*)\n".)  Perhaps 
\h* \n would do what you want here?

Alternatively, you can force backtracking by using \s*! instead.

The new version of Rakudo (the "ng" branch) provides a debugging
mode that provides some tracing of the grammar as its matching.
I don't know that it would've found the above yet -- it still needs
some work.

>     my $config = Config::Tiny::Grammar.parse($text);
>     #say $config ?? 'yes' || 'no';
>     say $config.perl;
>
> Also, if I uncomment that 'say $config ??' line, I get the 
> following strange error:
> 
>   ResizablePMCArray: Can't pop from an empty array!
>   in Main (file <unknown>, line <unknown>) 

It's a parsing error in Rakudo at the moment -- it *should* be 
telling you that it found a '??' but no '!!'.  Again, the new
version (arriving in a week or so) should be better about such
messages.

Pm

Reply via email to