From: Florian Ragwitz Date: Wed, 6 May 2009 00:23:24 +0000 (+0000) Subject: Implement skip_declarator in terms of scan_word in Context::Simple. X-Git-Tag: 0.005001~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=616311aed0f7a03f2c69876fef0e0cea346c2f19;p=p5sagit%2FDevel-Declare.git Implement skip_declarator in terms of scan_word in Context::Simple. --- diff --git a/lib/Devel/Declare/Context/Simple.pm b/lib/Devel/Declare/Context/Simple.pm index 1a47a7f..5fe25df 100644 --- a/lib/Devel/Declare/Context/Simple.pm +++ b/lib/Devel/Declare/Context/Simple.pm @@ -1,9 +1,10 @@ package Devel::Declare::Context::Simple; -use Devel::Declare (); -use B::Hooks::EndOfScope; use strict; use warnings; +use Devel::Declare (); +use B::Hooks::EndOfScope; +use Carp qw/confess/; sub new { my $class = shift; @@ -33,7 +34,17 @@ sub declarator { sub skip_declarator { my $self = shift; - $self->inc_offset(Devel::Declare::toke_move_past_token($self->offset)); + my $decl = $self->declarator; + my $len = Devel::Declare::toke_scan_word($self->offset, 0); + confess "Couldn't find declarator '$decl'" + unless $len; + + my $linestr = $self->get_linestr; + my $name = substr($linestr, $self->offset, $len); + confess "Expected declarator '$decl', got '${name}'" + unless $name eq $decl; + + $self->inc_offset($len); } sub skipspace {