Skip to content

Instantly share code, notes, and snippets.

@Kaiepi

Kaiepi/p6.p6 Secret

Forked from zoffixznet/p6.p6
Last active June 18, 2018 01:34
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 Kaiepi/420265032e13e6cb7089574326a6d38a to your computer and use it in GitHub Desktop.
Save Kaiepi/420265032e13e6cb7089574326a6d38a to your computer and use it in GitHub Desktop.
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