$self->{offset} += Devel::Declare::toke_move_past_token($self->offset);
}
+
=head2 skip_to
skips along until it finds a token matching
=cut
sub skip_to {
- my ($self, $name) = @_;
- my $toke = "";
- while ($toke ne $name) {
- my $len = $self->scan_word(1);
- my $l = $self->line;
- $toke = substr($l, $self->offset, $len);
- $self->offset($len + $self->offset);
- $self->inc_offset;
- confess "couldn't find '$name' on this line" if $toke and $toke =~ /\n/;
- }
- return $toke;
+ my ($self, $token) = @_;;
+ $token ||= $self->declarator;
+ my $len = $self->scan_word(0);
+ confess "Couldn't find token '$token'"
+ unless $len;
+
+ my $l = $self->line;
+ my $name = substr($l, $self->offset, $len);
+ confess "Expected declarator '$token', got '${name}'"
+ unless $name eq $token;
+ $self->inc_offset($len);
}
=head2 strip_to_char
sub line_offset {
my ($self, $os) = @_;
- Devel::Declare::set_linestr_offset($os) if $os;
+ Devel::Declare::set_linestr_offset($os) if $os;
return Devel::Declare::get_linestr_offset;
}
no strict 'refs';
${$self->package."::__block_name"} = $name;
-
+
unless ($sub) {
if($name) {
$sub = sub (&) {
return sub {
$self->declare(Keyword::Declare->new(@_));
my @arg;
- $self->declare->skip_to($self->{keyword});
+ $self->declare->skip_to;
+ $self->declare->skip_ws;
#call each parse routine and action
for my $pa (@{$self->{plist}}) {