rir has asked for the wisdom of the Perl Monks concerning the following question:
Be well,#!/home/rir/rakudo/parrot_install/bin/perl6 use v6; grammar Calc { rule TOP { <term> <op> <term> } # rule TOP { <term>\s?<op>\s?<term> } # a fix token term { \d+(\.\d*)? } token op { '*' | 'x' } } my @t = ( [ 44, " 8.8 * 5.0 " ], [ 44, " 8.8 x 5.0 " ], [ 44, " 8.8*5.0 " ], [ 44, " 8.8x5.0 " ], # no match ); for @t -> $i { my $m = Calc.parse( $i[1]); print $m ?? " " !! "no"; say " match: $i[1]" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: P6: parsing whitespace
by moritz (Cardinal) on Jun 09, 2010 at 18:01 UTC |