Created
August 29, 2010 18:36
-
-
Save ShimmerFairy/556545 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
use v6; | |
grammar Markov { | |
token TOP { | |
[<comment>|<command>]+ | |
} | |
token comment { | |
^^ '#' \N* \n | |
} | |
token command { | |
^^ $<item>=[\S+] <ws> '->' <ws> $<stop>=['.'?] $<replacement>=[\N+] \n | |
} | |
} | |
my $test = Q {# This rules file is extracted from Wikipedia: | |
# http://en.wikipedia.org/wiki/Markov_Algorithm | |
A -> apple | |
B -> bag | |
S -> shop | |
T -> the | |
the shop -> my brother | |
a never used -> .terminating rule | |
}; | |
my $match = Markov.parse($test); | |
say $match.perl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment