Last active
March 7, 2020 18:00
-
-
Save littlebenlittle/4c6891f084de260dcc4d2b1258f8cb46 to your computer and use it in GitHub Desktop.
How can the proto token match the B sym rather than the A sym?
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
use v6; | |
grammar Test { | |
token TOP { <x>+ % \h+ $<rest>=(.*) } | |
proto token x {*} | |
token x:sym<A> { \S+ [\h \S+]* } | |
token x:sym<B> { | |
"[" <special-token> "]" <.ws> <important-message> | |
} | |
token special-token { "SPECIAL TOKEN" } | |
token important-message { \S+ } | |
} | |
my $dat = q (59.5 Some Term [SPECIAL TOKEN] Important!! Yet another term); | |
say Test.parse($dat); | |
# 「59.5 Some Term [SPECIAL TOKEN] Important!! Yet another term」 | |
# x => 「59.5」 | |
# x => 「Some Term」 | |
# x => 「[SPECIAL TOKEN] Important!!」 | |
# x => 「Yet another term」 | |
# rest => 「」 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment