Created
April 7, 2011 21:53
-
-
Save masak/908829 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
#!/usr/local/bin/perl6 | |
use v6; | |
use GGE; | |
my $pattern = '<[hm]> <[ea]> [nk|n|nn] [ing|ell|all]'; | |
# Add :debug to the below call to see AST and generated code | |
my $ast = GGE::Perl6Regex.new($pattern).exp; | |
.say for generate($ast); | |
multi generate(GGE::Exp::Concat $_) { [X~] map { [generate($_)] }, .list } | |
multi generate(GGE::Exp::EnumCharList $_) { .ast.comb } | |
multi generate(GGE::Exp::Alt $_) { generate($_) for .[0], .[1] } | |
multi generate(GGE::Exp::Literal $_) { .ast } | |
multi generate(GGE::Exp $_) { die "Unhandled expression type {.WHAT.perl}" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment