Skip to content

Instantly share code, notes, and snippets.

@tbrowder
Last active October 4, 2018 11:30
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 tbrowder/476d7e61fb091a812a9e0e1d73308731 to your computer and use it in GitHub Desktop.
Save tbrowder/476d7e61fb091a812a9e0e1d73308731 to your computer and use it in GitHub Desktop.
grammar assertions
# 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