Created
February 26, 2015 18:00
-
-
Save patrickbkr/5fd2380e8bbe140b22f3 to your computer and use it in GitHub Desktop.
State and backtracking
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
#!/usr/bin/env perl6 | |
grammar Tracker { | |
regex TOP { | |
:my %*QUOTE_TRACKER; | |
Beginning | |
[ <quote> || .*! ] | |
End { say "failure" if %*QUOTE_TRACKER<inQuote> == True } | |
} | |
regex quote { | |
\" { say "enter quote"; %*QUOTE_TRACKER<inQuote> = True } | |
.*? | |
\" { say "exit quote"; %*QUOTE_TRACKER<inQuote> = False } | |
} | |
} | |
Tracker.parse("Beginning\"stuff\@End"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment