Keyword-Declare
view release on metacpan or search on metacpan
lib/Keyword/Declare.pm view on Meta::CPAN
# Install replacement __DATA__ handler...
# [REMOVE IF UPSTREAM MODULE (Keyword::Simple) FIXED]
_install_data_handler();
# Install the 'keytype' (meta-)keyword...
Keyword::Simple::define 'keytype', sub {
# Unpack trailing code...
my ($src_ref) = @_;
# Where was this keyword declared???
my ($file, $line) = (caller)[1,2];
# These track error messages and help decompose the parameter list...
# (they have to be package vars, so they're visible to in-regex code blocks in older Perls)
our ($expected, $failed_at, $block_start, @params) = ('new type name', 0, 0);
# Match and extract the keyword definition...
use re 'eval';
$$src_ref =~ s{
\A
(?<syntax>
lib/Keyword/Declare.pm view on Meta::CPAN
. $sigil_decl
. $$src_ref;
};
# Install the 'keyword' (meta-)keyword...
Keyword::Simple::define 'keyword', sub {
# Unpack trailing code...
my ($src_ref) = @_;
# Where was this keyword declared???
my ($file, $line) = (caller)[1,2];
# Which keywords are allowed in nested code at this point...
my @active_IDs = @^H{ grep { m{^ Keyword::Declare \s+ active:}xms } keys %^H };
my $lexical_keywords
= @active_IDs ? join '|', reverse sort map { $keyword_impls[$_]{skip_matcher} } @active_IDs
: '(?!)';
# These track error messages and help decompose the parameter list...
# (they have to be package vars, so they're visible to in-regex code blocks in older Perls)
our ($expected, $failed_at, $block_start, @params) = ('keyword name', 0, 0);
lib/Keyword/Declare.pm view on Meta::CPAN
# [REMOVE IF UPSTREAM MODULE (Keyword::Simple) IS FIXED]
$$src_ref =~ s{\n\z}{};
};
# Install the 'unkeyword' (anti-meta-)keyword...
Keyword::Simple::define 'unkeyword', sub {
# Unpack trailing code...
my ($src_ref) = @_;
# Where was this keyword declared???
my ($file, $line) = (caller)[1,2];
# Match and extract the keyword definition...
use re 'eval';
$$src_ref =~ s{
\A
(?<leadingspace> (?&PerlNWS) )
(?:
(?<keyword> (?&PerlIdentifier) )
|
(?<unexpected> \S+ )
( run in 0.897 second using v1.01-cache-2.11-cpan-a3c8064c92c )