Skip to content

Instantly share code, notes, and snippets.

@ShimmerFairy
Created August 26, 2011 04:19
Show Gist options
  • Save ShimmerFairy/1172689 to your computer and use it in GitHub Desktop.
Save ShimmerFairy/1172689 to your computer and use it in GitHub Desktop.
Grammar idea
#`««This is my idea for matching a series of lines that could
be a mix of <doorA> and <doorB>, where keeping the order of
lines (more generally, matched rules) is important. I think
I've got the grammar side down, but what should go in TOP's
method in the actions is what I'm stuck on now.
Any ideas?
»»
grammar Doc::Grammar {
regex TOP {
(<doorA>||<doorB>)+
}
regex doorA {
^^ <alpha>+ $$
}
regex doorB {
^^ <digit>+ $$
}
}
class Doc::Actions {
method doorA {
make ~$/;
}
method doorB {
make ~$/;
}
method TOP {
# not sure what should be here.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment