Skip to content

Instantly share code, notes, and snippets.

@Xliff

Xliff/gisty.md Secret

Last active February 18, 2019 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Xliff/d139f0e12f69678d3ccc2e056eb401af to your computer and use it in GitHub Desktop.
Save Xliff/d139f0e12f69678d3ccc2e056eb401af to your computer and use it in GitHub Desktop.
use v6.c;

grammar T {
  token TOP { \w+ }
  token a   { 'a'+ }
  token b   { 'b'+ }
}

my $text = "aaaaab
ab
aaaaabbbbbab
aabb
ababab
abacab";

my @rules = T.^methods(:local).map( *.name ).sort;
my $r = T.parse($text);

say $text ~~ /\w+/;

say "Rules: { @rules.join(',') }";
say $r.gist;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment