-package Keyword;
+package Devel::Declare::Keyword;
use 5.008000;
use strict;
use warnings;
use Devel::Declare;
use B::Hooks::EndOfScope;
use Data::Dumper;
-use Keyword::Declare;
-use Keyword::Parser;
-use Keyword::Parse::Block;
-use Keyword::Parse::Proto 'parse_proto';
-use Keyword::Parse::Ident 'parse_ident';
+use Devel::Declare::Keyword::Declare;
+use Devel::Declare::Keyword::Parser;
+use Devel::Declare::Keyword::Parse::Block;
+use Devel::Declare::Keyword::Parse::Proto 'parse_proto';
+use Devel::Declare::Keyword::Parse::Ident 'parse_ident';
our $VERSION = '0.03';
our $KW_MODULE = caller;
no strict 'refs';
*{$KW_MODULE.'::keyword'} = sub (&) {
- $Keyword::__keyword_block = shift;
+ $Devel::Declare::Keyword::__keyword_block = shift;
};
*{$KW_MODULE.'::parse'} = sub (&) { };
*{$KW_MODULE.'::action'} = sub (&) { };
#parses keyword signature
sub keyword_parser {
- my $kd = Keyword::Declare->new(@_);
+ my $kd = Devel::Declare::Keyword::Declare->new(@_);
$kd->next_token;
$kd->skip_ws;
confess "expecting prototype for keyword at:\n".$kd->line;
my $b = 1 if $proto =~ /block/i;
- my $parser = Keyword::Parser->new({proto=>$proto,
+ my $parser = Devel::Declare::Keyword::Parser->new({proto=>$proto,
module=>$KW_MODULE, block=>$b, keyword=>$keyword});
no strict 'refs';
$kd->skip_ws;
my $l = $kd->line;
- my $code = "BEGIN { Keyword::eos()}; ".kw_proto_to_code($proto);
+ my $code = "BEGIN { Devel::Declare::Keyword::eos()}; ".kw_proto_to_code($proto);
substr($l, $kd->offset+1, 0) = $code;
$kd->line($l);
# parses the parse keyword
sub parse_parser {
- my $kd = Keyword::Declare->new(@_);
+ my $kd = Devel::Declare::Keyword::Declare->new(@_);
$kd->next_token;
$kd->skip_ws;
$kd->skip_ws;
my $l = $kd->line;
- my $code = "BEGIN { Keyword::eos()}; my ($proto) = \@_;";
+ my $code = "BEGIN { Devel::Declare::Keyword::eos()}; my ($proto) = \@_;";
substr($l, $kd->offset+1, 0) = $code;
$kd->line($l);
# parses the action keyword
sub action_parser {
- my $kd = Keyword::Declare->new(@_);
+ my $kd = Devel::Declare::Keyword::Declare->new(@_);
$kd->next_token;
$kd->skip_ws;
$kd->skip_ws;
my $l = $kd->line;
- my $code = "BEGIN { Keyword::eos()}; my ($proto) = \@_;";
+ my $code = "BEGIN { Devel::Declare::Keyword::eos()}; my ($proto) = \@_;";
substr($l, $kd->offset+1, 0) = $code;
$kd->line($l);
sub eos {
on_scope_end {
- my $kd = new Keyword::Declare;
+ my $kd = Devel::Declare::Keyword::Declare->new;
my $l = $kd->line;
my $loffset = $kd->line_offset;
substr($l, $loffset, 0) = ';';
else {
no strict 'refs';
*{$module_user."::$keyword"} = sub {
- &$Keyword::__keyword_block(@Keyword::__keyword_block_arg);
+ &$Devel::Declare::Keyword::__keyword_block(@Devel::Declare::Keyword::__keyword_block_arg);
};
}
};
=head1 NAME
-Keyword - an easy way to declare keyword with custom parsers
+Devel::Declare::Keyword - an easy way to declare keyword with custom parsers
=cut
=head1 SYNOPSIS
package Method;
- use Keyword 'debug';
+ use Devel::Declare::Keyword;
keyword method (ident?, proto?, block) {
$block->name($ident); # assign the block to subroutine
=head1 CODE
-http://github.com/robinedwards/Keyword
-
-git@github.com:robinedwards/Keyword.git
+git push p5sagit@git.shadowcat.co.uk:Devel-Declare-Keyword.git
=head1 AUTHOR
-package Keyword::Parser;
+package Devel::Declare::Keyword::Parser;
use strict;
use warnings;
use Carp;
-use Keyword::Declare;
+use Devel::Declare::Keyword::Declare;
use Data::Dumper;
our %BUILTIN = (
- proto => 'Keyword::Parse::Proto::parse_proto',
- ident => 'Keyword::Parse::Ident::parse_ident',
- block => 'Keyword::Parse::Block::new',
+ proto => 'Devel::Declare::Keyword::Parse::Proto::parse_proto',
+ ident => 'Devel::Declare::Keyword::Parse::Ident::parse_ident',
+ block => 'Devel::Declare::Keyword::Parse::Block::new',
);
sub new {
$self->_lookup_routines;
return sub {
- my $kd = Keyword::Declare->new(@_);
+ my $kd = Devel::Declare::Keyword::Declare->new(@_);
$kd->skip_token($kd->declarator);
$kd->skip_ws;
# if it has a block execute keyword block at compile
if($self->{block}) {
- &{$Keyword::__keyword_block}(@arg);
+ &{$Devel::Declare::Keyword::__keyword_block}(@arg);
}
else { # no block execute at runtime, save arg
- @Keyword::__keyword_block_arg = @arg;
+ @Devel::Declare::Keyword::__keyword_block_arg = @arg;
}
};
}