Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created September 4, 2012 21:39
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 gfldex/3626896 to your computer and use it in GitHub Desktop.
Save gfldex/3626896 to your computer and use it in GitHub Desktop.
use v6;
my $s1 = 'AA foo; BB baz; AA bar;';
my $s2 = 'AA buzz;';
grammar G {
rule TOP { [ [ <ta> | <tb> ] <.ws> ]+ }
rule ta { 'AA' <name>';' { say $/<name>.Str; } }
rule tb { 'BB' <name>';' { G.parse($s2); say $/<name>.Str; } }
rule name { \w+ }
}
say ?G.parse($s1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment