Re: Problem using a module containing a grammar
On Mon, Mar 25, 2013 at 11:01 AM, wrote: > grammar SalesExportGram is export { (...) > my $parsed = SalesReportGram.parsefile('sales_report.txt'); > Might help if you used the same name in both places? -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Re: Problem using a module containing a grammar
On Mon, Mar 25, 2013 at 11:01 AM, wrote: > I have created a file called SalesReport.mp6, which contains a grammar > > module SalesReport; > grammar SalesExportGram is export { Aiui you can now use this module to introduce SalesReport as a module name and SalesExportGram as a grammar name. > which I would like to use in the following PERL 6 script: > > use SalesReport; > my $parsed = SalesReportGram.parsefile('sales_report.txt'); As Brandon noted, SalesReportGram is misspelled in this case. Aiui SalesExportGram ought to work. > If I give the module (SalesReport.pm6) and the grammar > declared in it (grammar SalesReport) the same name, I get > "no such method 'parsefile' for invocant of type 'SalesReport'": > > my $parsed = SalesReport.parsefile('sales_report.txt'); Is SalesReport resolving to the module (which does not have a method 'parsefile')? To see if this is so, try: say SalesReport.HOW # how is SalesReport handled? What version of Perl 6 are you using? If I correctly understand what I just checked, SalesReport.parsefile() should work. > Any suggestions? The best place to get answers to these sorts of questions is the freenode IRC channel #perl6. Feel free to email me if you would like help getting going with IRC. If you really want/need to use a mailing list, consider posting to the perl6-users list. This perl6-language list is intended for posts related to language design. (Which is why just about the only traffic is the slow trickle of updates to the language specification, which is relatively stable, and a very occasional burst of discussion about some topic. It may get noisier in the second half of this year when concurrency starts to get a work through, but I think most of that will be on #perl6 too.) Hth, -- raiph
Re: Problem using a module containing a grammar
If I give the module (SalesReport.pm6) and the grammar declared in it (grammar SalesReport) the same name, I get a "no such method 'parsefile' for invocant of type 'SalesReport'" error, when the following lines are run: use lib '.'; use SalesReport; my $parsed = SalesReport.parsefile('sales_report.txt'); - Mail original - De: "Brandon Allbery" À: phi...@free.fr Cc: perl6-language@perl.org Envoyé: Lundi 25 Mars 2013 16:08:14 Objet: Re: Problem using a module containing a grammar On Mon, Mar 25, 2013 at 11:01 AM, < phi...@free.fr > wrote: grammar SalesExportGram is export { (...) my $parsed = SalesReportGram.parsefile('sales_report.txt'); Might help if you used the same name in both places? -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
Problem using a module containing a grammar
Hello, I have created a file called SalesReport.mp6, which contains a grammar - module SalesReport; grammar SalesExportGram is export { token TOP { ^ + $ } token country { \n + } token destination { \t \s+ ':' \s+ ',' \s+ ':'\s+ \n } token name { \w+ [ \s \w+ ]* } token num { '-'? \d+ [\. \d+]? } token integer { '-'? \d+ } } which I would like to use in the following PERL 6 script: use v6; use lib '.'; use SalesReport; my $parsed = SalesReportGram.parsefile('sales_report.txt'); if $parsed { my @countries = @($parsed); ... Unfortunately, when I run the script, I get an "undeclared name: SalesReportGram" error. I have tried my $parsed = SalesReport::SalesReportGram.parsefile('sales_report.txt'); and my $parsed = SalesReport.SalesReportGram.parsefile('sales_report.txt'); but to no avail. Any suggestions? Many thanks. Philippe