From: Robin Edwards Date: Fri, 11 Dec 2009 13:17:13 +0000 (+0000) Subject: added eos for keyword X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3b041686df418f3883b16d34b8c9035f75ac5b9b;p=p5sagit%2FDevel-Declare-Keyword.git added eos for keyword --- diff --git a/examples/Methods.pm b/examples/Methods.pm index 4ce0817..8297d0f 100644 --- a/examples/Methods.pm +++ b/examples/Methods.pm @@ -4,9 +4,10 @@ use Keyword; use Data::Dumper; keyword method (ident?, proto?, block) { - $block->begin("warn 'hello from Methods';"); $block->name($ident); -}; + $block->code("warn 'hello from Methods';"); + $block->terminate; +} sub action_ident { return @_; diff --git a/lib/Keyword.pm b/lib/Keyword.pm index 3b44b32..35eee57 100644 --- a/lib/Keyword.pm +++ b/lib/Keyword.pm @@ -59,13 +59,24 @@ sub sig_parser { $parser->skip_ws; my $l = $parser->line; - substr($l, $parser->offset+1, 0) = proto_to_code($proto); + my $code = "BEGIN { Keyword::eos()}; ".proto_to_code($proto); + substr($l, $parser->offset+1, 0) = $code; $parser->line($l); #install shadow for keyword routine $parser->shadow($keyword); } +sub eos { + on_scope_end { + my $parser = new Keyword::Parser; + my $l = $parser->line; + my $loffset = $parser->line_offset; + substr($l, $loffset, 0) = ';'; + $parser->line($l); + }; +} + sub proto_to_code { my ($proto) = @_; my $inject = " my ("; diff --git a/t/02-syntax.t b/t/02-syntax.t index 596215c..d8413cd 100644 --- a/t/02-syntax.t +++ b/t/02-syntax.t @@ -4,11 +4,8 @@ use Data::Dumper; ok 1; keyword method (ident?, proto?, thing, block) { - warn Dumper $ident; - warn Dumper $proto; - warn Dumper $thing; - warn Dumper $block; -}; + ok 1; +} ok 1; diff --git a/t/03-methods.t b/t/03-methods.t index 9ff07ad..3bc78d7 100644 --- a/t/03-methods.t +++ b/t/03-methods.t @@ -6,7 +6,7 @@ use Methods; method something ($a, $b, $c) { return 1; -}; +} 1;