Created
October 29, 2017 01:29
-
-
Save wmoxam/a3d93a1bcde7cfbdbc64d9584fd1929b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar Parser { | |
rule TOP { I <love> <lang> } | |
token love { '♥' | love } | |
token lang { < Perl Rust Go Python Ruby > } | |
} | |
say Parser.parse: 'I ♥ Perl'; | |
# OUTPUT: 「I ♥ Perl」 love => 「♥」 lang => 「Perl」 | |
say Parser.parse: 'I love Rust'; | |
# OUTPUT: 「I love Rust」 love => 「love」 lang => 「Rust」 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment