Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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