Skip to content

Commit

Permalink
allow Token::Whitespace to throw useful error on unexpected input
Browse files Browse the repository at this point in the history
fixes #10
  • Loading branch information
wchristian committed May 13, 2017
1 parent 7b0e448 commit a7a1390
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/PPI/Token/Whitespace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ sub __TOKENIZER__on_line_start {

sub __TOKENIZER__on_char {
my $t = $_[1];
my $char = ord substr $t->{line}, $t->{line_cursor}, 1;
my $c = substr $t->{line}, $t->{line_cursor}, 1;
my $char = ord $c;

# Do we definitely know what something is?
return $COMMITMAP[$char]->__TOKENIZER__commit($t) if $COMMITMAP[$char];
Expand Down Expand Up @@ -415,9 +416,9 @@ sub __TOKENIZER__on_char {
}

} elsif ( $char >= 128 ) { # Outside ASCII
return 'PPI::Token::Word'->__TOKENIZER__commit($t) if $t =~ /\w/;
return 'Whitespace' if $t =~ /\s/;
}
return 'PPI::Token::Word'->__TOKENIZER__commit($t) if $c =~ /\w/;
return 'Whitespace' if $c =~ /\s/;
}


# All the whitespaces are covered, so what to do
Expand Down

0 comments on commit a7a1390

Please sign in to comment.