Re: RPN calculator in Perl 6

2009-06-06 Thread Minimiscience
[I just realized I sent this directly to Daniel rather than to the list, so for the benefit of onlookers...] On Jun 6, 2009, at 1:51 PM, Daniel Carrera wrote: Daniel Ruoso wrote: Yes... that's what wasn't implemented... But now it is ;) http://sial.org/pbot/37085 Close, but... % perl6 rpn.

Re: How to speed up a grammar

2009-06-06 Thread Minimiscience
On Jun 6, 2009, at 10:32 AM, Richard Hainsworth wrote: rule element { '<' * [ | '/>' | '>' * ' '>' ] } This is just a wild, uneducated, possibly delusional guess, but I don't think that vertical bar before the '/>' should be there. I think it might be causing the grammar engine to check w

Re: RPN calculator in Perl 6

2009-06-06 Thread Daniel Carrera
Daniel Ruoso wrote: Are you planning to write a post explaining how your program works? Maybe, but if you want to beat me to it, feel free ;) I figure that the explanation is as useful as the example. I sure spent a lot of time writing the blog post. I'm not sure I'll have the time to write

Re: RPN calculator in Perl 6

2009-06-06 Thread Daniel Carrera
Daniel Ruoso wrote: Yes... that's what wasn't implemented... But now it is ;) http://sial.org/pbot/37085 Close, but... % perl6 rpn.pl "5 4 + 3 / 5 3 - *" -6 That should be a positive 6. Are you planning to write a post explaining how your program works? I figure that the explanation is as

Re: RPN calculator in Perl 6

2009-06-06 Thread Daniel Carrera
Daniel Ruoso wrote: You can probably fix that with a different split() line. I tried using instead of \s+ but the program just hangs forever. Hmm.. it certainly is in the split, I'm not sure how to get the barrier between the 2 and the + Does Perl 6 still have the word barrier \b regex?

Re: RPN calculator in Perl 6

2009-06-06 Thread Daniel Carrera
Daniel Carrera wrote Ok, try again: % perl6 rpn.pl "2 2+" 2 2 You can probably fix that with a different split() line. I tried using instead of \s+ but the program just hangs forever. I also tried a more complex expression, and the calculator didn't like it: % perl6 rpn.pl "5 4 + 3 / 5 3

Re: RPN calculator in Perl 6

2009-06-06 Thread Daniel Carrera
Daniel Carrera wrote: http://sial.org/pbot/37075 % perl rpn.pl "2 2 +" Tee hee... that should have been "perl6". :-) Ok, try again: % perl6 rpn.pl "2 2+" 2 2

Re: RPN calculator in Perl 6

2009-06-06 Thread Daniel Carrera
Daniel Ruoso wrote: TIMTOWTDI ;) The objective of the blog was more about the learning + teaching experience than anything else. http://sial.org/pbot/37075 % perl rpn.pl "2 2 +" Semicolon seems to be missing at rpn.pl line 2. String found where operator expected at rpn.pl line 13, near

How to speed up a grammar

2009-06-06 Thread Richard Hainsworth
Leon Timmermans wrote: If you want to write a fast parser for XML, preventing backtracking is going to be quite essential. I suspect the problem is your grammar, not the grammar engine itself. You could post it to perl6-users and ask for advice on it. Leon Below is the grammar. I am only inte

RPN calculator in Perl 6

2009-06-06 Thread Daniel Carrera
Hi all, I just wrote a blog post showing how to make a reverse polish notation calculator in Perl 6. In the process I show some of Perl 6's grammar features. Someone in IRC thought it was good, so I decided to post here in the off chance that someone else finds it interesting or useful. ht

Re: the file slurping is not working

2009-06-06 Thread Tom Christiansen
Larry wrote: » Indeed, that preference is why Perl 6 can (we hope) get away with » autochomping, where Perl 5 can't (as easily). Or more accurately, » we choose not to special-case "while (<>)" as Perl 5 does (because » even Perl 5 has difficulties with files that are accidentally » "autochomped"