# New Ticket Created by Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯
# Please include the string: [perl #132003]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=132003 >
› perl6 -v
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.
› cat calc.pl
use v6;
grammar Calculator {
token TOP { [ <add> | <sub> ] }
rule add { <num> '+' <num> }
rule sub { <num> '-' <num> }
token num { \d+ }
}
say Calculator.parse('2 + 3');
say Calculator.parse(Blob.new([50,32,43,32,51])); # '2 + 3'
› perl6 calc.pl
「2 + 3」
add => 「2 + 3」
num => 「2」
num => 「3」
Cannot use a Buf as a string, but you called the Str method on it
in block <unit> at calc.pl line 9
It appears grammars only accept strings, but I also want to parse
non-text input, e.g. binary file formats.