Skip Menu |

This queue is for tickets about the Perl-Tidy CPAN distribution.

Report information
The Basics
Id: 19436
Status: resolved
Priority: 0/
Queue: Perl-Tidy

People
Owner: Nobody in particular
Requestors: SAPER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] Support for defined-or operators
Hello, The attached patch provides support for handling the defined-or operators that will be available in Perl 5.10 and are already available in Perl 5.8 thanks to H.Merijn Brand DOR-patches. Regards
Subject: Perl-Tidy-dor.patch
--- Perl-Tidy-20031021-orig/lib/Perl/Tidy.pm 2003-10-22 06:12:43.000000000 +0200 +++ Perl-Tidy-20031021/lib/Perl/Tidy.pm 2006-05-23 15:00:59.778856397 +0200 @@ -3909,7 +3909,7 @@ # my @list = qw" == != < > <= <=> "; # @token_long_names{@list} = ('numerical-comparison') x scalar(@list); # - # my @list = qw" && || ! &&= ||= "; + # my @list = qw" && || // ! &&= ||= //= "; # @token_long_names{@list} = ('logical') x scalar(@list); # # my @list = qw" . .= =~ !~ x x= "; @@ -5179,17 +5179,17 @@ $bli_list_string = 'if else elsif unless while for foreach do : sub'; @_ = qw( - .. :: << >> ** && .. || -> => += -= .= %= &= |= ^= *= <> + .. :: << >> ** && .. || // -> => += -= .= %= &= |= ^= *= <> <= >= == =~ !~ != ++ -- /= x= ); @is_digraph{@_} = (1) x scalar(@_); - @_ = qw( ... **= <<= >>= &&= ||= <=> ); + @_ = qw( ... **= <<= >>= &&= ||= //= <=> ); @is_trigraph{@_} = (1) x scalar(@_); @_ = qw( = **= += *= &= <<= &&= - -= /= |= >>= ||= + -= /= |= >>= ||= //= .= %= ^= x= ); @@ -5205,7 +5205,7 @@ ); @is_keyword_returning_list{@_} = (1) x scalar(@_); - @_ = qw(is if unless and or last next redo return); + @_ = qw(is if unless and or err last next redo return); @is_if_unless_and_or_last_next_redo_return{@_} = (1) x scalar(@_); @_ = qw(last next redo return); @@ -5223,7 +5223,7 @@ @_ = qw(if unless); @is_if_unless{@_} = (1) x scalar(@_); - @_ = qw(and or); + @_ = qw(and or err); @is_and_or{@_} = (1) x scalar(@_); # We can remove semicolons after blocks preceded by these keywords @@ -6507,7 +6507,7 @@ # default keywords for which space is introduced before an opening paren # (at present, including them messes up vertical alignment) - @_ = qw(my local our and or eq ne if else elsif until + @_ = qw(my local our and or err eq ne if else elsif until unless while for foreach return switch case given when); @space_after_keyword{@_} = (1) x scalar(@_); @@ -6557,7 +6557,7 @@ # make note if breaks are before certain key types %want_break_before = (); - foreach my $tok ( '.', ',', ':', '?', '&&', '||', 'and', 'or', 'xor' ) { + foreach my $tok ( '.', ',', ':', '?', '&&', '||', 'and', 'or', 'err', 'xor' ) { $want_break_before{$tok} = $left_bond_strength{$tok} < $right_bond_strength{$tok}; } @@ -7128,9 +7128,9 @@ @is_closing_type{@_} = (1) x scalar(@_); my @spaces_both_sides = qw" - + - * / % ? = . : x < > | & ^ .. << >> ** && .. || => += -= + + - * / % ? = . : x < > | & ^ .. << >> ** && .. || // => += -= .= %= x= &= |= ^= *= <> <= >= == =~ !~ /= != ... <<= >>= - &&= ||= <=> A k f w F n C Y U G v + &&= ||= //= <=> A k f w F n C Y U G v "; my @spaces_left_side = qw" @@ -8892,7 +8892,7 @@ my %is_chain_operator; BEGIN { - @_ = qw(&& || and or : ? .); + @_ = qw(&& || and or err : ? .); @is_chain_operator{@_} = (1) x scalar(@_); } @@ -11038,12 +11038,12 @@ BEGIN { @_ = qw# - = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x= + = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x= { ? : => =~ && || #; @is_vertical_alignment_type{@_} = (1) x scalar(@_); - @_ = qw(if unless and or eq ne for foreach while until); + @_ = qw(if unless and or err eq ne for foreach while until); @is_vertical_alignment_keyword{@_} = (1) x scalar(@_); } @@ -11375,7 +11375,7 @@ # it is very good to break AFTER various assignment operators @_ = qw( = **= += *= &= <<= &&= - -= /= |= >>= ||= + -= /= |= >>= ||= //= .= %= ^= x= ); @@ -11383,12 +11383,16 @@ @right_bond_strength{@_} = ( 0.4 * WEAK + 0.6 * VERY_WEAK ) x scalar(@_); - # break BEFORE '&&' and '||' + # break BEFORE '&&', '||' and '//' # set strength of '||' to same as '=' so that chains like # $a = $b || $c || $d will break before the first '||' $right_bond_strength{'||'} = NOMINAL; $left_bond_strength{'||'} = $right_bond_strength{'='}; + # same thing for '//' + $right_bond_strength{'//'} = NOMINAL; + $left_bond_strength{'//'} = $right_bond_strength{'='}; + # set strength of && a little higher than || $right_bond_strength{'&&'} = NOMINAL; $left_bond_strength{'&&'} = $left_bond_strength{'||'} + 0.1; @@ -11417,12 +11421,14 @@ $right_bond_strength{','} = VERY_WEAK; # Set bond strengths of certain keywords - # make 'or', 'and' slightly weaker than a ',' + # make 'or', 'err', 'and' slightly weaker than a ',' $left_bond_strength{'and'} = VERY_WEAK - 0.01; $left_bond_strength{'or'} = VERY_WEAK - 0.02; + $left_bond_strength{'err'} = VERY_WEAK - 0.02; $left_bond_strength{'xor'} = NOMINAL; $right_bond_strength{'and'} = NOMINAL; $right_bond_strength{'or'} = NOMINAL; + $right_bond_strength{'err'} = NOMINAL; $right_bond_strength{'xor'} = STRONG; } @@ -11662,6 +11668,12 @@ $bond_str += $or_bias; $or_bias += $delta_bias; } + elsif ($next_nonblank_token eq 'err' + && $want_break_before{$next_nonblank_token} ) + { + $bond_str += $or_bias; + $or_bias += $delta_bias; + } # FIXME: needs more testing elsif ( $is_keyword_returning_list{$next_nonblank_token} ) { @@ -11701,6 +11713,12 @@ $bond_str += $or_bias; $or_bias += $delta_bias; } + elsif ( $token eq 'err' + && !$want_break_before{$token} ) + { + $bond_str += $or_bias; + $or_bias += $delta_bias; + } } # keep matrix and hash indices together @@ -12142,7 +12160,7 @@ my %is_logical_container; BEGIN { - @_ = qw# if elsif unless while and or not && | || ? : ! #; + @_ = qw# if elsif unless while and or err not && | || ? : ! #; @is_logical_container{@_} = (1) x scalar(@_); } @@ -18892,9 +18910,9 @@ Here is a list of the token types currently used for lines of type 'CODE'. For the following tokens, the "type" of a token is just the token itself. -.. :: << >> ** && .. || -> => += -= .= %= &= |= ^= *= <> +.. :: << >> ** && .. || // -> => += -= .= %= &= |= ^= *= <> ( ) <= >= == =~ !~ != ++ -- /= x= -... **= <<= >>= &&= ||= <=> +... **= <<= >>= &&= ||= //= <=> , + - / * | % ! x ~ = \ ? : . < > ^ & The following additional token types are defined: @@ -19195,6 +19213,7 @@ ## '^=' => undef, ## '|=' => undef, ## '||=' => undef, +## '//=' => undef, ## '~' => undef, '>' => sub { @@ -19916,7 +19935,7 @@ @is_not_zero_continuation_block_type{@_} = (1) x scalar(@_); my %is_logical_container; - @_ = qw(if elsif unless while and or not && ! || for foreach); + @_ = qw(if elsif unless while and or err not && ! || for foreach); @is_logical_container{@_} = (1) x scalar(@_); my %is_binary_type; @@ -19924,7 +19943,7 @@ @is_binary_type{@_} = (1) x scalar(@_); my %is_binary_keyword; - @_ = qw(and or eq ne cmp); + @_ = qw(and or err eq ne cmp); @is_binary_keyword{@_} = (1) x scalar(@_); # 'L' is token for opening { at hash key @@ -24033,12 +24052,12 @@ @closing_brace_names = qw# '}' ']' ')' ':' #; my @digraphs = qw( - .. :: << >> ** && .. || -> => += -= .= %= &= |= ^= *= <> + .. :: << >> ** && .. || // -> => += -= .= %= &= |= ^= *= <> <= >= == =~ !~ != ++ -- /= x= ); @is_digraph{@digraphs} = (1) x scalar(@digraphs); - my @trigraphs = qw( ... **= <<= >>= &&= ||= <=> ); + my @trigraphs = qw( ... **= <<= >>= &&= ||= //= <=> ); @is_trigraph{@trigraphs} = (1) x scalar(@trigraphs); # make a hash of all valid token types for self-checking the tokenizer @@ -24362,8 +24381,8 @@ # note: pp and mm are pre-increment and decrement # f=semicolon in for, F=file test operator my @value_requestor_type = qw# - L { ( [ ~ !~ =~ ; . .. ... A : && ! || = + - x - **= += -= .= /= *= %= x= &= |= ^= <<= >>= &&= ||= + L { ( [ ~ !~ =~ ; . .. ... A : && ! || // = + - x + **= += -= .= /= *= %= x= &= |= ^= <<= >>= &&= ||= //= <= >= == != => \ > < % * / ? & | ** <=> f F pp mm Y p m U J G #;
A release with this update is out. Thanks again. On Tue May 23 09:20:28 2006, guest wrote: Show quoted text
> Hello, > > The attached patch provides support for handling the defined-or > operators that will be available in Perl 5.10 and are already available > in Perl 5.8 thanks to H.Merijn Brand DOR-patches. > > > Regards