Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Created October 26, 2019 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexDaniel/a77b2555bfd0fb11e843712a8412883b to your computer and use it in GitHub Desktop.
Save AlexDaniel/a77b2555bfd0fb11e843712a8412883b 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