From: Robin Edwards Date: Mon, 14 Dec 2009 16:34:22 +0000 (+0000) Subject: renamed Keyword::Parser to Keyword::Declare X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=be13af0ed9fdba334d8c7ff2bc10d4af3fb13206;p=p5sagit%2FDevel-Declare-Keyword.git renamed Keyword::Parser to Keyword::Declare --- diff --git a/README b/README index ba43c43..6ced004 100644 --- a/README +++ b/README @@ -14,14 +14,14 @@ I really don't know what I am doing, so all feedback / abuse is welcome. robin dot ge at gmail dot com TODO -* remove stupid globals +* remove globals * add support for blockless keywords * add eos inject see MXD * cleanup parser construction (check if code exists etc) * write default action to return whatever the parse routine matched PLAN -* rename Keyword::Parser to Keyword::Declare alter to sub class of DD:C:S with aliases +* alter Keyword::Declare to sub class of DD:C:S? * create new Keyword::Parser class for storing parse routines SYNTAX @@ -33,7 +33,7 @@ keyword method (ident?, proto?, custom, block) { $block->terminate; # add semi colon } -#passed a Keyword::Parser object +#passed a Keyword::Declare object parse custom ($parser) { if (my $len = $parser->scan_word(1)) { my $l = $parser->line; diff --git a/lib/Keyword.pm b/lib/Keyword.pm index 9e3360e..1ecbca5 100644 --- a/lib/Keyword.pm +++ b/lib/Keyword.pm @@ -4,7 +4,7 @@ use warnings; use Devel::Declare; use B::Hooks::EndOfScope; use Data::Dumper; -use Keyword::Parser; +use Keyword::Declare; use Keyword::Parse::Block; use Keyword::Parse::Proto; use Keyword::Parse::Ident; @@ -38,7 +38,7 @@ sub import { #parses keyword signature sub keyword_parser { - my $parser = Keyword::Parser->new; + my $parser = Keyword::Declare->new; $parser->next_token; $parser->skip_ws; @@ -73,7 +73,7 @@ sub keyword_parser { # parses the parse keyword sub parse_parser { - my $parser = Keyword::Parser->new; + my $parser = Keyword::Declare->new; $parser->next_token; $parser->skip_ws; @@ -100,7 +100,7 @@ sub parse_parser { # parses the action keyword sub action_parser { - my $parser = Keyword::Parser->new; + my $parser = Keyword::Declare->new; $parser->next_token; $parser->skip_ws; @@ -127,7 +127,7 @@ sub action_parser { sub eos { on_scope_end { - my $parser = new Keyword::Parser; + my $parser = new Keyword::Declare; my $l = $parser->line; my $loffset = $parser->line_offset; substr($l, $loffset, 0) = ';'; @@ -195,7 +195,7 @@ sub proto_to_parselist { sub mk_parser { my ($plist,$keyword) = @_; return sub { - my $parser = Keyword::Parser->new; + my $parser = Keyword::Declare->new; $parser->next_token; $parser->skip_ws; @@ -221,7 +221,6 @@ sub mk_import { return sub { my $module_user = caller(); - # module_user is the user of your Keyword based module Devel::Declare->setup_for( $module_user, @@ -301,7 +300,7 @@ There are three built-in parse routines: Its possible to write your own with the following syntax: - parse something($parser) { + parse identifier($parser) { if (my $len = $parser->scan_word(1)) { my $l = $parser->line; my $ident = substr($l, $parser->offset, $len); diff --git a/lib/Keyword/Parser.pm b/lib/Keyword/Declare.pm similarity index 95% rename from lib/Keyword/Parser.pm rename to lib/Keyword/Declare.pm index 5b45c66..7dc1593 100644 --- a/lib/Keyword/Parser.pm +++ b/lib/Keyword/Declare.pm @@ -1,8 +1,10 @@ -package Keyword::Parser; +package Keyword::Declare; use strict; use warnings; use Devel::Declare; +# maybe subclass Devel::Declare::Context::Simple? + sub new { my ($class, $self) = @_; $self = {} unless $self;