Skip to content

Instantly share code, notes, and snippets.

@araraloren
Forked from Xliff/gisty.md
Last active January 10, 2019 02:56
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 araraloren/0d567e37442338720b7c3878b5c2b921 to your computer and use it in GitHub Desktop.
Save araraloren/0d567e37442338720b7c3878b5c2b921 to your computer and use it in GitHub Desktop.

use v6.c;

grammar T { token TOP { ^ [||' ']+ $ } 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