);
no strict 'refs';
- *{$KW_MODULE.'::parse'} = sub (&) {};
*{$KW_MODULE.'::keyword'} = sub (&) {
no strict 'refs';
$Keyword::__keyword_block = shift;
};
+ *{$KW_MODULE.'::parse'} = sub (&) { };
strict->import;
warnings->import;
$parser->line($l);
#install shadow for keyword routine
- $parser->shadow($keyword);
+ $parser->shadow($parser->package."::".$keyword);
}
# parses the parse keyword
substr($l, $parser->offset+1, 0) = $code;
$parser->line($l);
- #install shadow for keyword routine
- $parser->shadow($name);
+ no strict 'refs';
+ no warnings 'redefine';
+ *{$KW_MODULE.'::parse'} = sub (&) {
+ *{$parser->package."::parse_$name"} = shift;
+ };
}
sub eos {
}
sub shadow {
- my ($self, $name) = @_;
- $name = $self->package()."::$name" if $name;
- my $sub;
+ my ($self, $name, $sub) = @_;
#set name as global for import;
no strict 'refs';
${$self->package."::__block_name"} = $name;
-
- if($name) {
- $sub = sub (&) {
- no strict 'refs';
- *{$name} = shift;
- };
- }
- else {
- $sub = sub (&) { ${$self->package."::__tmp_block"}; };
+
+ unless ($sub) {
+ if($name) {
+ $sub = sub (&) {
+ *{$name} = shift;
+ };
+ }
+ else {
+ $sub = sub (&) { shift; };
+ }
}
- Devel::Declare::shadow_sub("$name", $sub);
+ Devel::Declare::shadow_sub($name, $sub);
}
1;