######################################################################
#
-# the Perl::Tidy::Tokenizer package is essentially a filter which
+# The Perl::Tidy::Tokenizer package is essentially a filter which
# reads lines of perl source code from a source object and provides
# corresponding tokenized lines through its get_line() method. Lines
# flow from the source_object to the caller like this:
@_ = qw(for foreach);
@is_for_foreach{@_} = (1) x scalar(@_);
- my %is_my_our;
- @_ = qw(my our);
- @is_my_our{@_} = (1) x scalar(@_);
+ my %is_my_our_state;
+ @_ = qw(my our state);
+ @is_my_our_state{@_} = (1) x scalar(@_);
# These keywords may introduce blocks after parenthesized expressions,
# in the form:
# ATTRS: check for a ':' which introduces an attribute list
# either after a 'sub' keyword or within a paren list
- elsif ($statement_type =~ /^sub\b/ ) {
+ elsif ( $statement_type =~ /^sub\b/ ) {
+ $type = 'A';
+ $in_attribute_list = 1;
+ }
+
+ # Withing a signature, unless we are in a ternary. For example,
+ # from 't/filter_example.t':
+ # method foo4 ( $class: $bar ) { $class->bar($bar) }
+ elsif ( $paren_type[$paren_depth] =~ /^sub\b/
+ && !is_balanced_closing_container(QUESTION_COLON) )
+ {
$type = 'A';
$in_attribute_list = 1;
}
# check for scalar attribute, such as
# my $foo : shared = 1;
- elsif ($is_my_our{$statement_type}
+ elsif ($is_my_our_state{$statement_type}
&& $current_depth[QUESTION_COLON] == 0 )
{
$type = 'A';
$type = 'J';
}
- # Withing a signature. For example,
- # from 't/filter_example.t':
- # method foo4 ( $class: $bar ) { $class->bar($bar) }
- elsif ( !is_balanced_closing_container(QUESTION_COLON)
- && $paren_type[$paren_depth] =~ /^sub\b/ )
- {
- $type = 'A';
- $in_attribute_list = 1;
- }
-
# otherwise, it should be part of a ?/: operator
else {
( $type_sequence, $indent_flag ) =
}
# remember my and our to check for trailing ": shared"
- elsif ( $is_my_our{$tok} ) {
+ elsif ( $is_my_our_state{$tok} ) {
$statement_type = $tok;
}
if ($in_quote) {
- # we didn't find an ending / on this line, so we bias towards
- # division
+ # we didn't find an ending / on this line, so we bias towards
+ # division
if ( $divide_expected >= 0 ) {
$is_pattern = 0;
$msg .= "division (no ending / on this line)\n";
}
else {
- # assuming a multi-line pattern ... this is risky, but division
- # does not seem possible. If this fails, it would either be due
+ # assuming a multi-line pattern ... this is risky, but division
+ # does not seem possible. If this fails, it would either be due
# to a syntax error in the code, or the division_expected logic
# needs to be fixed.
$msg = "multi-line pattern (division not possible)\n";
# particular, we stop if we see any nested parens, braces, or commas.
# Also note, a valid prototype cannot contain any alphabetic character
# -- see https://perldoc.perl.org/perlsub
- # old PROTO:
+ # But it appears that an underscore is valid in a prototype, so the
+ # regex below uses [A-Za-z] rather than \w
+ # This is the old regex which has been replaced:
# $input_line =~ m/\G(\s*\([^\)\(\}\{\,#]*\))? # PROTO
my $saw_opening_paren = $input_line =~ /\G\s*\(/;
if (
sqrt
srand
stat
+ state
study
substr
symlink
splice
split
sprintf
+ state
substr
syscall
sysopen