-
-
Save yeahnoob/355da51f635e28699584 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 WordPairs { | |
rule word-pair { <key=word> <value=word> } | |
token word { \S+ } | |
rule TOP { <word-pair>* } | |
} | |
my %dict; | |
class WordPairsActions { | |
method word-pair($/) { %dict{~$<key>}.push(~$<value>) } | |
} | |
my $match = WordPairs.parse(slurp, :actions(WordPairsActions)); | |
say ?$match; | |
say "The pairs count of the key word \"her\" in wordpairs.txt is {%dict{"her"}.elems}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment