Re: Debugging Grammars
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
Re: Interactive Perl 6 shell
Jason (), Juan (): Does Perl6/Rakudo have an interactive perl shell like ruby does with irb? http://en.wikipedia.org/wiki/Interactive_Ruby_Shell Would be great for trying out the new syntax quickly. My phone accidentally sent an empty reply to this. What I was supposed to reply with was information regarding the built-in Rakudo REPL. You can see it in action here: http://perl6advent.wordpress.com/2009/12/01/day-1-getting-rakudo/ A mention of today's RE(P)L in Rakudo practically mandates a mention of its known deficiencies: http://use.perl.org/~masak/journal/38279 Last I heard, pmichaud++ was well under way to fixing the annoying variable-forgetting bug, by extending the way eval works. // Carl
Re: Debugging Grammars
Ovid (): 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? Yes: #perl6 -- or more specifically, moritz++ and a number of other people who have built dozens of grammars already. // Carl
Re: Debugging Grammars
Carl (), Ovid (): 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? Yes: #perl6 -- or more specifically, moritz++ and a number of other people who have built dozens of grammars already. As for the current issue you're experiencing, it seems you can't initialize a nested class in the way you're trying to: $ perl6 -e 'class A { class A::B {} }; A::B.new' Null PMC access in find_method('new') $ perl6 -e 'class A { class B {} }; A::B.new; say alive' alive There's already a bug in RT pertaining to a similar issue (http://rt.perl.org/rt3/Ticket/Display.html?id=69316), but I'll submit yours as a separate one. // Carl
Re: Interactive Perl 6 shell
Juan Madrigal wrote: Does Perl6/Rakudo have an interactive perl shell like ruby does with irb? $ perl -ple '$_=eval' (In Windows: perl -ple $_=eval ) Enter the command `exit` to end the session. -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. I like Perl; it's the only language where you can bless your thingy.
Re: Interactive Perl 6 shell
With rakudo, just running perl6 with no arguments drops you into the RE_L. On Tuesday, December 29, 2009, Shawn H Corey shawnhco...@gmail.com wrote: Juan Madrigal wrote: Does Perl6/Rakudo have an interactive perl shell like ruby does with irb? $ perl -ple '$_=eval' (In Windows: perl -ple $_=eval ) Enter the command `exit` to end the session. -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. I like Perl; it's the only language where you can bless your thingy. -- Mark J. Reed markjr...@gmail.com