To understand grammars better, I figured I would convert Config::Tiny to Perl 6. I've started with the following:
grammar Config::Tiny::Grammar { token TOP { <root_section>? <section>+ } token root_section { <property>+ } token section { ^^ '[' \s* $<name>=<-[\n\]]>* \s* ']' \n <property>* } token property { ^^ \s* $<name>=<-[=]>* \s* '=' \s* $<value>=[\N*] \n } } my $text = Q{ [foo] }; 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. 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>) And adding any "property" lines like "bar=baz" causes the grammar to fail to match, or switching "<section>+" to "<section>*" in the TOP token causes the grammar to fail to match. In short, just about anything I touch seems to break the grammar :) Any suggestions welcome. 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