Mercurial > hg > Papers > 2019 > anatofuz-thesis
changeset 80:cbd990446e05
fix
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 18 Feb 2019 20:38:01 +0900 |
parents | 0d4418a76093 |
children | ff884fd7a990 |
files | paper/codes/grammer.p6 paper/main.pdf |
diffstat | 2 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/paper/codes/grammer.p6 Mon Feb 18 20:32:53 2019 +0900 +++ b/paper/codes/grammer.p6 Mon Feb 18 20:38:01 2019 +0900 @@ -1,11 +1,11 @@ -grammar Parser { - rule TOP { I <love> <lang> } - token love { '♥' | love } - token lang { < Perl Rust Go Python Ruby > } +grammar REST { + token TOP { '/' <subject> '/' <command> [ '/' <data> ]? } + token subject { \w+ } + token command { \w+ } + token data { .* } } -say Parser.parse: 'I ♥ Perl'; -# OUTPUT: 「I ♥ Perl」 love => 「♥」 lang => 「Perl」 +my $m = REST.parse('/product/create'); +say $m<subject>, $m<command>; -say Parser.parse: 'I love Rust'; -# OUTPUT: 「I love Rust」 love => 「love」 lang => 「Rust」 +# OUTPUT: [product][create]