Skip to content

Instantly share code, notes, and snippets.

@wmoxam
Created October 29, 2017 01:29
Show Gist options
  • Save wmoxam/a3d93a1bcde7cfbdbc64d9584fd1929b to your computer and use it in GitHub Desktop.
Save wmoxam/a3d93a1bcde7cfbdbc64d9584fd1929b to your computer and use it in GitHub Desktop.
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