From: Steve Hancock Date: Mon, 1 Mar 2021 15:32:52 +0000 (-0800) Subject: Update tokenizer recognition of indirect object X-Git-Tag: 20210402~27 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=49cd66fad3bb95be6b915452f35fab01bc5728fd;p=perltidy.git Update tokenizer recognition of indirect object --- diff --git a/bin/perltidy b/bin/perltidy index 83007028..3008a553 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -2865,7 +2865,12 @@ example: To simplify input even further for the case in which both opening and closing non-block containers are stacked, the flag B<-sac> or B<--stack-all-containers> -is an abbreviation for B<-sot -sot>. +is an abbreviation for B<-sot -sct>. + +Please note that if both opening and closing tokens are to be stacked, then the +newer flag B<-weld-nested-containers> may be preferable because it insures that +stacking is always done symmetrically. It does this by working on formatting +globally rather than locally, as the B<-sot> and B<-sct> flags do. =item B<-dnl>, B<--delete-old-newlines> diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index d45cc405..df08f0d4 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -6167,8 +6167,9 @@ sub scan_bare_identifier_do { # may not be indirect object unless followed by a space; # updated 2021-01-16 to consider newline to be a space. + # updated for case b990 to look for either ';' or space if ( pos($input_line) == length($input_line) - || $input_line =~ m/\G\s+/gc ) + || $input_line =~ m/\G[;\s]/gc ) { $type = 'Y'; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 1a3c3fd8..286e234d 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,38 @@ =over 4 +=item B + +This is the parameter file b990.pro: + --noadd-whitespace + --continuation-indentation=0 + --maximum-line-length=7 + --space-terminal-semicolon + +Applying perltidy -pro=b990.pro to the following snippet gave two states + + # State 1 + print + H; + + # State 2 + print H + ; + +The tokenizer was alternately parsing 'H' as either possble indirect object, 'Z', +or indirect object, 'Y'. Two fixes were tested. The first was to modify +the tokenizer to recognize a ';' as well as a space as a direct object +terminator. An alternative fix is to not allowing a break before type 'Y' +so that the tokenizer kept parsing as type 'Y'. Both fixes work, but the latter fix +would change existing formatting by the -extrude option, so the first fix was +used. With this fix, the stable state is 'State 1' above. + +This update is a generalization of the update L +of 16 Jan 2021. + +This fixes case b990. +1 Mar 2021. + =item B Perltidy does final formatting in discrete batches of tokens, where a batch is @@ -37,7 +69,7 @@ as requested with the -okw flag. This update fixes cases b149 b888 b984 b985 b986 b987. -28 Feb 2021. +28 Feb 2021, 8aaf599. =item B