Created
August 26, 2011 04:19
-
-
Save ShimmerFairy/1172689 to your computer and use it in GitHub Desktop.
Grammar idea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#`««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