I have a regex that parses a string that should be a fully qualified module name for Raku (see below). Since only the auth, ver, and api versions seem to be used in the Precomp modules, I only test for those.
I need to separate out the name of the module from the identifiers.
My regex is:
my $rx := /
^
$<name> = ( [ \w | '::' ] + )
[ ':' $<part> = ( [ 'ver' | 'auth' | 'api' ] )
\< ~ \> $<val> = ( .*? ) ]*
$
/;
Question is whether there is a standard way to match to a Raku module, or a sub so that this regex does not become an error in the future.
Looking at the grammar of Raku, it looks like it is just first eating all adverbs in a package definition, and then checks each one of them if it's either ver
, auth
or api
, to die
if it is not one of these.
So, I would say: No, currently there is no standard way to match a Raku module name.
It's probably the best if you use Zef::Identity
use Zef::Identity;
say Zef::Identity.new( "WithApi:ver<0.0.2>:api<1>" ).hash;
# {api => 1, auth => , from => Perl6, name => WithApi, ver => 0.0.2}
It's probably already installed in your system, since it's part of
zef
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With