Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Created July 4, 2015 16:26
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 AlexDaniel/5fde506394d862f23626 to your computer and use it in GitHub Desktop.
Save AlexDaniel/5fde506394d862f23626 to your computer and use it in GitHub Desktop.
<!> does not help
grammar TestGrammar {
regex TOP { ^ $<plain>=.*? [ <special> $<plain>=.*? ]*? $ }
regex special { '**' .*? '**' }
# regex special { '**' .*? [ '**' || 'XX' <!> ] } # in these tests this works identically to the above
}
say TestGrammar.parse('test wooohoo XX oops test'); # correct!
# 「test wooohoo XX oops test」
# plain => 「test wooohoo XX oops test」
say TestGrammar.parse('test **wooohoo XX oops test'); # correct!
# 「test **wooohoo XX oops test」
# plain => 「test **wooohoo XX oops test」
say TestGrammar.parse('test **wooohoo** XX oops test'); # correct!
# 「test **wooohoo** XX oops test」
# plain => 「test 」
# special => 「**wooohoo**」
# plain => 「 XX oops test」
say TestGrammar.parse('test **wooohoo XX oops** test'); # wrong!
# 「test **wooohoo XX oops** test」
# plain => 「test 」
# special => 「**wooohoo XX oops**」
# plain => 「 test」
# I want it to be:
# 「test **wooohoo XX oops** test」
# plain => 「test **wooohoo XX oops** test」
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment