From: Steve Hancock Date: Mon, 23 Oct 2023 14:48:52 +0000 (-0700) Subject: tokenize non-operator '&^' as type identifier X-Git-Tag: 20230912.05~19 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0c1175cdcd50472c5cf3da4e91277b99433ec1b1;p=perltidy.git tokenize non-operator '&^' as type identifier perl takes this to be a call to a sub '^' --- diff --git a/dev-bin/run_tokenizer_tests.pl.data b/dev-bin/run_tokenizer_tests.pl.data index 69bf15bd..6056df93 100644 --- a/dev-bin/run_tokenizer_tests.pl.data +++ b/dev-bin/run_tokenizer_tests.pl.data @@ -123,6 +123,15 @@ index?#sc# ;#sc# }#sc# +==> c068.in <== +my $var = $^; +my @list = @^; +my %hash = %^; +my $glob = *^; +my $call = &^; +my $aa = $^ ? "defined" : "not defined"; +my $bb = &^ ? "none" : "ok"; + ==> c103.in <== print $l<3? $_ : $l & 4 ? --$_ ? $_ : "No more" : $l & 3 ? $_ > 1 ? "if one of those" : "if that" : "e", " cop", $_ ^ 1 ? "ies " : "y ", $l ^ 3 ? $l & 2 ? "w" : $l & 4 ? "z" : "y" : "x"; print STDERR < BLABLA>; # ok prints the word 'BLABLA' diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 35ad51ef..30e6db39 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -8242,7 +8242,6 @@ sub do_scan_package { my $self = shift; # Starting sub call after seeing an '&' - if ( $tok =~ /^[\$\w]/ ) { # alphanumeric .. $id_scan_state = $scan_state_COLON; # now need :: $saw_alpha = 1; @@ -8278,9 +8277,10 @@ sub do_scan_package { # Special variable (c066) $identifier .= $tok; - $type = '&'; + $type = 'i'; - # There may be one more character, not a space, after the ^ + # To be a special $^ variable, there may be one more character, + # not a space, after the ^ my $next1 = $rtokens->[ $i + 1 ]; my $chr = substr( $next1, 0, 1 ); if ( $is_special_variable_char{$chr} ) { @@ -8296,7 +8296,9 @@ sub do_scan_package { } else { - # it is &^ + # It is &^. This is parsed by perl as a call to sub '^', + # even though it would be difficult to create a sub '^'. + # So we mark it as an identifier (c068). $id_scan_state = EMPTY_STRING; } }