Skip to content

Instantly share code, notes, and snippets.

@samebchase
Created November 28, 2020 12:25
Show Gist options
  • Save samebchase/0820b9ecfdb011a9b73aedfb4ba349d1 to your computer and use it in GitHub Desktop.
Save samebchase/0820b9ecfdb011a9b73aedfb4ba349d1 to your computer and use it in GitHub Desktop.
simple-ns.raku
#!/usr/bin/env raku
use v6.d;
use Grammar::Tracer;
grammar SimpleNs {
token TOP { <simple-ns> }
token simple-ns { <lparen> <ns-keyword> <.ws> <ns-name> <rparen> }
token ns-keyword { 'ns' }
token ns-name { <.ns-name-component>+ % '.' }
token ns-name-component { ( <.alnum> | '-' )+ }
token lparen { '(' }
token rparen { ')' }
}
sub MAIN() {
say SimpleNs.parse("(ns foo.bar.baz-quux)");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment