]> git.donarmstrong.com Git - perltidy.git/commitdiff
tokenize non-operator '&^' as type identifier
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 23 Oct 2023 14:48:52 +0000 (07:48 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 23 Oct 2023 14:48:52 +0000 (07:48 -0700)
perl takes this to be a call to a sub '^'

dev-bin/run_tokenizer_tests.pl.data
lib/Perl/Tidy/Tokenizer.pm

index 69bf15bd351715c152dfcfcf171367bc29404eb5..6056df933a17d70e848aa600bf06f0f81ca9edd7 100644 (file)
@@ -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'
index 35ad51ef37d34c7c457f4aa7fa21f9d0a43ad8e1..30e6db39afeb0232ffb42cd84a5c440634395142 100644 (file)
@@ -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;
                 }
             }