]> git.donarmstrong.com Git - perltidy.git/commitdiff
add v-string underscores; warn of leading commas
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 1 Jun 2021 01:46:06 +0000 (18:46 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 1 Jun 2021 01:46:06 +0000 (18:46 -0700)
lib/Perl/Tidy/Tokenizer.pm
local-docs/BugLog.pod

index 2e5f6bc84565524ee3dd0770fac83d56836e1261..72fa967588018435adf9bfb7729c0b28d3b64c33 100644 (file)
@@ -2132,12 +2132,16 @@ EOM
                 complain("Repeated ','s \n");
             }
 
+            # Note that we have to check both token and type here because a
+            # comma following a qw list can have last token='(' but type = 'q'
+            elsif ( $last_nonblank_token eq '(' && $last_nonblank_type eq '{' )
+            {
+                warning("Unexpected leading ',' after a '('\n");
+            }
+
             # patch for operator_expected: note if we are in the list (use.t)
             if ( $statement_type eq 'use' ) { $statement_type = '_use' }
-##                FIXME: need to move this elsewhere, perhaps check after a '('
-##                elsif ($last_nonblank_token eq '(') {
-##                    warning("Leading ','s illegal in some versions of perl\n");
-##                }
+
         },
         ';' => sub {
             $context        = UNKNOWN_CONTEXT;
@@ -2241,8 +2245,7 @@ EOM
 
             # ATTRS: for a '{' following an attribute list, reset
             # things to look like we just saw the sub name
-            # FIXME: need to end with \b here??
-            if ( $statement_type =~ /^sub/ ) {
+            if ( $statement_type =~ /^sub\b/ ) {
                 $last_nonblank_token = $statement_type;
                 $last_nonblank_type  = 'i';
                 $statement_type      = "";
@@ -2845,12 +2848,12 @@ EOM
         '&&' => sub {
             error_if_expecting_TERM()
               if ( $expecting == TERM && $last_nonblank_token ne ',' );    #c015
-          },
+        },
 
         '||' => sub {
             error_if_expecting_TERM()
               if ( $expecting == TERM && $last_nonblank_token ne ',' );    #c015
-          },
+        },
 
         '//' => sub {
             error_if_expecting_TERM()
@@ -3619,7 +3622,7 @@ EOM
                         }
                     }
 
-                    # FIXME: Patch: mark something like x4 as an integer for now
+                    # NOTE: mark something like x4 as an integer for now
                     # It gets fixed downstream.  This is easier than
                     # splitting the pretoken.
                     else {
@@ -3706,8 +3709,6 @@ EOM
                             }
                         }
 
-                        # FIXME: could check for error in which next token is
-                        # not a word (number, punctuation, ..)
                         else {
                             $is_constant{$current_package}{$next_nonblank_token}
                               = 1;
@@ -5773,8 +5774,6 @@ sub guess_if_pattern_or_conditional {
     #   msg = a warning or diagnostic message
     # USES GLOBAL VARIABLES: $last_nonblank_token
 
-    # FIXME: this needs to be rewritten
-
     my ( $i, $rtokens, $rtoken_map, $max_token_index ) = @_;
     my $is_pattern = 0;
     my $msg        = "guessing that ? after $last_nonblank_token starts a ";
@@ -7722,9 +7721,10 @@ sub scan_number_do {
 
     # handle v-string without leading 'v' character ('Two Dot' rule)
     # (vstring.t)
-    # TODO: v-strings may contain underscores
+    # Here is the format prior to including underscores:
+    ## if ( $input_line =~ /\G((\d+)?\.\d+(\.\d+)+)/g ) {
     pos($input_line) = $pos_beg;
-    if ( $input_line =~ /\G((\d+)?\.\d+(\.\d+)+)/g ) {
+    if ( $input_line =~ /\G((\d[_\d]*)?\.[\d_]+(\.[\d_]+)+)/g ) {
         $pos = pos($input_line);
         my $numc = $pos - $pos_beg;
         $number = substr( $input_line, $pos_beg, $numc );
index 57f539a690a21b8ce588476b72a53ec08e711710..6b89eb8f7b658c7c1e142243556d6ab8f53fd768 100644 (file)
@@ -2,6 +2,24 @@
 
 =over 4
 
+=item B<add v-string underscores; warn of leading commas>
+
+This update cleans up a couple of open issues in the tokenizer.
+
+A warning message will be produced for a list which begins with a comma:
+
+            my %string = (
+              ,       "saddr",    $stest,  "daddr",
+              $dtest, "source",   $sname,  "dest")
+
+This warning had been temporarily deactivated.
+
+Underscores in v-strings without a leading 'v' are now parsed correctly.
+
+Several comments have been updated.
+
+31 May 2021.
+
 =item B<Fix parsing error at operator following a comma>
 
 The following lines are syntactically correct but some were producing a
@@ -20,7 +38,7 @@ For example, the first line produced this message
 
 This has been fixed. This fixes case c015.
 
-27 May 2021.
+27 May 2021, b537a72.
 
 =item B<Added optional o in octal number definitions>