Last active
October 4, 2018 11:30
-
-
Save tbrowder/476d7e61fb091a812a9e0e1d73308731 to your computer and use it in GitHub Desktop.
grammar assertions
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
# code fragment in rakudo's src/Perl6/Grammar.nqp | |
token numbered-alias { '#' } | |
my $*USE-HASH-MARK := 1; # default, means we're free to extract the first '#' in a pod block's data | |
# inside a pod block, e.g., abbreviated, paragraph, or delimited | |
# following the configuration, if any | |
{ | |
if nqp::defined($<configuration>) { | |
:my $c := $<configuration>; | |
if $c ~~ / 'V<#>' / { | |
$*USE-HASH-MARK := 0: | |
} | |
# other tests following... | |
} | |
} | |
[ | |
<?{ $*USE-HASH-MARK }> # if true, the rest of the token is evaluated for a match | |
# if false, the token will not match at all | |
\s* <numbered-alias> \s+ <?before \w> | |
]? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment