Skip to content

Instantly share code, notes, and snippets.

@ocharles
Created August 3, 2010 21:20
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 ocharles/507173 to your computer and use it in GitHub Desktop.
Save ocharles/507173 to your computer and use it in GitHub Desktop.
grammar OrgMode::Grammar {
token TOP {
<node>+
}
token node {
^^ '*'+ \s+ $<text>=[\N*] \n
}
}
my $text = q{
* Hello
** Hi world!
* How are you
* Test
* Another test
* Pattern?
* Here?
** Or here
*** Maybe here
* Here
* And
* Here
};
my $match = OrgMode::Grammar.parse($text);
for $match<node> -> $node {
say "A node: $node<text>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment