As a follow-up to this, I have my code posted at http://blogs.perl.org/users/ovid/2009/12/configini-in-perl-6.html
While my admittedly clumsy grammar matches, transforming it into an AST has failed miserably. Aside from the advent calendar or the online docs at http://perlcabal.org/syn/S05.html, are there any other resources for explaining the generation of an AST from a grammar? Cheers, Ovid-- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog - http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6 ----- Original Message ---- > From: Patrick R. Michaud <pmich...@pobox.com> > To: Ovid <publiustemp-perl6langua...@yahoo.com> > Cc: perl6-langu...@perl..org > Sent: Sun, 27 December, 2009 16:57:44 > Subject: Re: Debugging Grammars > > 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 , line ) > > 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