comparison paper/codes/grammer.p6 @ 78:a456a90f9f35

add perl6 sample code
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 18 Feb 2019 20:29:10 +0900
parents
children cbd990446e05
comparison
equal deleted inserted replaced
77:2327c951dfb9 78:a456a90f9f35
1 grammar Parser {
2 rule TOP { I <love> <lang> }
3 token love { '♥' | love }
4 token lang { < Perl Rust Go Python Ruby > }
5 }
6
7 say Parser.parse: 'I ♥ Perl';
8 # OUTPUT: 「I ♥ Perl」 love => 「♥」 lang => 「Perl」
9
10 say Parser.parse: 'I love Rust';
11 # OUTPUT: 「I love Rust」 love => 「love」 lang => 「Rust」