-
-
Save Kaiepi/420265032e13e6cb7089574326a6d38a to your computer and use it in GitHub Desktop.
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
grammar GrammarAdvice { | |
rule TOP { | |
:my $*USE-WS = 0; | |
"use" <type> "for" <significance> "whitespace" | |
} | |
token type { | |
| "tokens" { $*USE-WS = 0 } | |
| "regex" { $*USE-WS = 0 } | |
| "rules" { $*USE-WS = 1 } | |
} | |
token significance { | |
| <{ "insignificant" unless $*USE-WS }> | |
| <{ "significant" if $*USE-WS }> | |
} | |
} | |
say GrammarAdvice.parse("use rules for insignificant whitespace"); | |
say GrammarAdvice.parse("use tokens for insignificant whitespace"); | |
say GrammarAdvice.parse("use regex for insignificant whitespace"); | |
say GrammarAdvice.parse("use rules for significant whitespace"); | |
say GrammarAdvice.parse("use tokens for significant whitespace"); | |
say GrammarAdvice.parse("use regex for significant whitespace"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment