EXAMPLES
SQL.pm - execute select statements in perl
-Methods.pm -
+Methods.pm - usual method signature
PLAN
* add support for multiple keywords per module
-* let modules optionally write there own import subs
-* find usescases from: http://cpants.perl.org/dist/used_by/Devel-Declare
-* and go through perl's -existing- keywords print $fh "sddfsd". $f, $c etc
-* look at ... metalua ... and common lisp reader macros.
-
* remove globals
* write pod for Keyword::Declare
-
* cleanup parser construction (check if code exists etc)
* write default action to return whatever the parse routine matched
-
-* add pre and post block hooks with shadow { setup_shit() ;exec_block(); do_shit; return $ret}
-
-* alter sig syntax to:
+* add pre and post block hooks with shadow { setup_stuff() ;exec_block(); do_stuff; return $ret}
+* alter sig syntax to (see MXD code)
keyword method (Maybe[Ident] $ident, Maybe[Proto] $proto, Block $block) {
+RESEARCH
+* find usescases from: http://cpants.perl.org/dist/used_by/Devel-Declare
+* and go through perl's -existing- keywords print $fh "sddfsd". $f, $c etc
+* look at ... metalua ... and common lisp reader macros.
* long term goal, a hints file describing syntax to be shared with ppi / vim etc
+
CURRENT SYNTAX
-#parse an action routines called for each entry in proto
+# parse an action routines called for each entry in proto
keyword method (ident?, proto?, custom, block) {
$block->name($ident); # name the block
$block->inject_begin($proto); # inject at begin of block
$block->terminate; # add semi colon
}
-#passed a Keyword::Declare object
+# passed a Keyword::Declare object
parse custom ($parser) {
if (my $len = $parser->scan_word(1)) {
my $l = $parser->line;
}
}
-#passed whatever the parse routine matches
+# passed whatever the parse routine matches
action proto ($match) {
my $match;
return $code;
#parses keyword signature
sub keyword_parser {
- warn Dumper @_; #need to pass @_ to KD
- my $kd = Keyword::Declare->new;
+ my $kd = Keyword::Declare->new(@_);
$kd->next_token;
$kd->skip_ws;
# parses the parse keyword
sub parse_parser {
- my $kd = Keyword::Declare->new;
+ my $kd = Keyword::Declare->new(@_);
$kd->next_token;
$kd->skip_ws;
# parses the action keyword
sub action_parser {
- my $kd = Keyword::Declare->new;
+ my $kd = Keyword::Declare->new(@_);
$kd->next_token;
$kd->skip_ws;
use warnings;
use Carp;
use Devel::Declare;
+use Data::Dumper;
=head1 NAME
sub new {
- my ($class, $self) = @_;
- $self = {} unless $self;
- no strict 'refs';
- $self->{offset} = 0;
- bless($self,__PACKAGE__);
+ my ($class) = @_;
+ my $self->{offset} = $_[2] || 0;
+ $self->{declarator} = $_[1];
+ bless($self,$class);
}
=head1 METHODS
return $self->{offset};
}
+sub declarator {
+ my $self = shift;
+ return $self->{declarator}
+}
+
=head2 inc_offset
increments the current offset