"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Perl/Tidy/Tokenizer.pm" between
Perl-Tidy-20191203.tar.gz and Perl-Tidy-20200110.tar.gz

About: Perltidy is a Perl script indenter and reformatter (beautifier).

Tokenizer.pm  (Perl-Tidy-20191203):Tokenizer.pm  (Perl-Tidy-20200110)
skipping to change at line 24 skipping to change at line 24
# The Tokenizer returns a reference to a data structure 'line_of_tokens' # The Tokenizer returns a reference to a data structure 'line_of_tokens'
# containing one tokenized line for each call to its get_line() method. # containing one tokenized line for each call to its get_line() method.
# #
# WARNING: This is not a real class yet. Only one tokenizer my be used. # WARNING: This is not a real class yet. Only one tokenizer my be used.
# #
######################################################################## ########################################################################
package Perl::Tidy::Tokenizer; package Perl::Tidy::Tokenizer;
use strict; use strict;
use warnings; use warnings;
our $VERSION = '20191203'; our $VERSION = '20200110';
use Perl::Tidy::LineBuffer; use Perl::Tidy::LineBuffer;
BEGIN { BEGIN {
# Caution: these debug flags produce a lot of output # Caution: these debug flags produce a lot of output
# They should all be 0 except when debugging small scripts # They should all be 0 except when debugging small scripts
use constant TOKENIZER_DEBUG_FLAG_EXPECT => 0; use constant TOKENIZER_DEBUG_FLAG_EXPECT => 0;
use constant TOKENIZER_DEBUG_FLAG_NSCAN => 0; use constant TOKENIZER_DEBUG_FLAG_NSCAN => 0;
skipping to change at line 367 skipping to change at line 367
sub get_saw_brace_error { sub get_saw_brace_error {
my $logger_object = $tokenizer_self->{_logger_object}; my $logger_object = $tokenizer_self->{_logger_object};
if ($logger_object) { if ($logger_object) {
return $logger_object->get_saw_brace_error(); return $logger_object->get_saw_brace_error();
} }
else { else {
return 0; return 0;
} }
} }
sub get_unexpected_error_count {
my ($self) = shift;
return $self->{_unexpected_error_count};
}
# interface to Perl::Tidy::Diagnostics routines # interface to Perl::Tidy::Diagnostics routines
sub write_diagnostics { sub write_diagnostics {
my $msg = shift; my $msg = shift;
if ( $tokenizer_self->{_diagnostics_object} ) { if ( $tokenizer_self->{_diagnostics_object} ) {
$tokenizer_self->{_diagnostics_object}->write_diagnostics($msg); $tokenizer_self->{_diagnostics_object}->write_diagnostics($msg);
} }
return; return;
} }
sub report_tokenization_errors { sub report_tokenization_errors {
skipping to change at line 2058 skipping to change at line 2063
my $is_pattern; my $is_pattern;
# Patch for rt #126965 # Patch for rt #126965
# a pattern cannot follow certain keywords which take optional # a pattern cannot follow certain keywords which take optional
# arguments, like 'shift' and 'pop'. See also '/'. # arguments, like 'shift' and 'pop'. See also '/'.
if ( $last_nonblank_type eq 'k' if ( $last_nonblank_type eq 'k'
&& $is_keyword_taking_optional_args{$last_nonblank_token} ) && $is_keyword_taking_optional_args{$last_nonblank_token} )
{ {
$is_pattern = 0; $is_pattern = 0;
} }
# patch for RT#131288, user constant function without prototype
# last type is 'U' followed by ?.
elsif ( $last_nonblank_type =~ /^[FUY]$/ ) {
$is_pattern = 0;
}
elsif ( $expecting == UNKNOWN ) { elsif ( $expecting == UNKNOWN ) {
# In older versions of Perl, a bare ? can be a pattern
# delimiter. Sometime after Perl 5.10 this seems to have
# been dropped, but we have to support it in order to format
# older programs. For example, the following line worked
# at one time:
# ?(.*)? && (print $1,"\n");
# In current versions it would have to be written with slashes:
# /(.*)/ && (print $1,"\n");
my $msg; my $msg;
( $is_pattern, $msg ) = ( $is_pattern, $msg ) =
guess_if_pattern_or_conditional( $i, $rtokens, $rtoken_map, guess_if_pattern_or_conditional( $i, $rtokens, $rtoken_map,
$max_token_index ); $max_token_index );
if ($msg) { write_logfile_entry($msg) } if ($msg) { write_logfile_entry($msg) }
} }
else { $is_pattern = ( $expecting == TERM ) } else { $is_pattern = ( $expecting == TERM ) }
if ($is_pattern) { if ($is_pattern) {
skipping to change at line 6422 skipping to change at line 6441
# Otherwise, we assume it is a SIGNATURE rather than a # Otherwise, we assume it is a SIGNATURE rather than a
# PROTOTYPE and let the normal tokenizer handle it as a list # PROTOTYPE and let the normal tokenizer handle it as a list
if ( !$saw_opening_paren ) { if ( !$saw_opening_paren ) {
$id_scan_state = 'sub'; # we must come back to get proto $id_scan_state = 'sub'; # we must come back to get proto
$package_saved = $package; $package_saved = $package;
$subname_saved = $subname; $subname_saved = $subname;
} }
$statement_type = $tok; $statement_type = $tok;
} }
elsif ($next_nonblank_token) { # EOF technically ok elsif ($next_nonblank_token) { # EOF technically ok
$subname = "" unless defined($subname);
warning( warning(
"expecting ':' or ';' or '{' after definition or declaration of sub '$subname' b ut saw '$next_nonblank_token'\n" "expecting ':' or ';' or '{' after definition or declaration of sub '$subname' b ut saw '$next_nonblank_token'\n"
); );
} }
check_prototype( $proto, $package, $subname ); check_prototype( $proto, $package, $subname );
} }
# no match but line not blank # no match but line not blank
else { else {
} }
 End of changes. 5 change blocks. 
1 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)