Skip to content

Instantly share code, notes, and snippets.

@grondilu
Created December 6, 2012 10:16
Show Gist options
  • Save grondilu/4223474 to your computer and use it in GitHub Desktop.
Save grondilu/4223474 to your computer and use it in GitHub Desktop.
Newick Perl 6 grammar test
use v6;
my $sample = q :to 'STOP';
(cat)dog;
dog cat
(dog,cat);
dog cat
STOP
grammar Newick {
rule TOP { <node> ';' }
token node {
| <name>
| '(' ~ ')' <node>+ % ',' <name>
}
token name { <alpha>* }
}
for $sample.split: "\n" {
.say if Newick.parse: $_;
}
# vim: ft=perl6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment