# if ( !Boucherot::SetOfConnections->new->handler->execute(
# ^--K_o_o ^--K_i_o
# @array) )
+ my $Kn_first = $K_outer_opening;
for (
my $Kn = $K_outer_opening + 1 ;
$Kn <= $K_inner_opening ;
)
{
next if ( $rLL->[$Kn]->[_TYPE_] eq 'b' );
+ if ( !$nonblank_count ) { $Kn_first = $Kn }
if ( $Kn eq $K_inner_opening ) { $nonblank_count++; last; }
# skip chain of identifier tokens
last if ( $nonblank_count > 2 );
}
- if ( $nonblank_count == 1
- || $nonblank_count == 2
- && $rLL->[$K_outer_opening]->[_TOKEN_] eq '(' )
+ if (
+
+ # adjacent opening containers, like: do {{
+ $nonblank_count == 1
+
+ # short item following opening paren, like: fun( yyy (
+ || ( $nonblank_count == 2
+ && $rLL->[$K_outer_opening]->[_TOKEN_] eq '(' )
+
+ # anonymous sub + prototype or sig: )->then( sub ($code) {
+ || ( $rLL->[$K_inner_opening]->[_BLOCK_TYPE_] eq 'sub'
+ && $rLL->[$Kn_first]->[_TOKEN_] eq 'sub' )
+ )
{
push @nested_pairs,
[ $inner_seqno, $outer_seqno, $K_inner_closing ];
{
$op_expected = OPERATOR;
+ # Patch: The following snippet from 'signatures.t' splits the $ from
+ # the variable name with a side comment. To avoid an error message we
+ # can mark this special case as UNKNOWN.
+ # sub t086
+ # ( #foo)))
+ # $ #foo)))
+ # a #foo))) <-This 'a' is split from its $
+ # ) #foo)))
+ # { $a.$b }
+ if ( $last_nonblank_token eq '$' ) { $op_expected = UNKNOWN }
+
# in a 'use' statement, numbers and v-strings are not true
# numbers, so to avoid incorrect error messages, we will
# mark them as unknown for now (use.t)
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 {
- # going down the rabbit hole...
+ # 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";
$is_pattern = 1;
}
my $in_prototype_or_signature = $container_type =~ /^sub\b/;
# these flags will be used to help figure out the type:
- ##my $saw_alpha = ( $tok =~ /^\w/ ); # This was slow
- my $saw_alpha;
+ my $saw_alpha;
my $saw_type;
# allow old package separator (') except in 'use' statement
}
elsif ( $tok =~ /^\w/ ) {
$id_scan_state = ':';
- $saw_alpha = 1;
+ $saw_alpha = 1;
}
elsif ( $tok eq '->' ) {
$id_scan_state = '$';
my $i_save = $i;
while ( $i < $max_token_index ) {
- ##$i_save = $i unless ( $tok =~ /^\s*$/ ); # This was a slow statement
if ($tok_is_blank) { $tok_is_blank = undef }
else { $i_save = $i }
}
# $# and POSTDEFREF ->$#
- elsif ( ( $tok eq '#' ) && ( $identifier =~ /\$$/ ) ) { # $#array
+ elsif (
+ ( $tok eq '#' )
+ && ( $identifier =~ /\$$/ )
+
+ # a # inside a prototype or signature can only start a comment
+ && !$in_prototype_or_signature
+ )
+ { # $#array
$identifier .= $tok; # keep same state, a $ could follow
}
+
elsif ( $tok eq '{' ) {
# check for something like ${#} or ${©}
}
else { # something else
- if ( $in_prototype_or_signature && $tok =~ /^[\),=]/ ) {
+ if ( $in_prototype_or_signature && $tok =~ /^[\),=#]/ ) {
$id_scan_state = '';
$i = $i_save;
$type = 'i'; # probably punctuation variable
$id_scan_state = ':'; # now need ::
$saw_alpha = 1;
}
- ##elsif ( ( $identifier =~ /^sub / ) && ( $tok =~ /^\s*$/ ) ) {
elsif ( $tok_is_blank && $identifier =~ /^sub / ) {
$id_scan_state = '(';
$identifier .= $tok;
}
- ##elsif ( ( $identifier =~ /^sub / ) && ( $tok eq '(' ) ) {
elsif ( $tok eq '(' && $identifier =~ /^sub / ) {
$id_scan_state = ')';
$identifier .= $tok;
$identifier .= $tok;
}
}
- ##elsif ( ( $identifier =~ /^sub / ) && ( $tok =~ /^\s*$/ ) ) {
elsif ( $tok_is_blank && $identifier =~ /^sub / ) {
$id_scan_state = '(';
$identifier .= $tok;
}
- ##elsif ( ( $identifier =~ /^sub / ) && ( $tok eq '(' ) ) {
elsif ( $tok eq '(' && $identifier =~ /^sub / ) {
$id_scan_state = ')';
$identifier .= $tok;
# does not look like a prototype, we assume it is a SIGNATURE and we
# will stop and let the the standard tokenizer handle it. In
# particular, we stop if we see any nested parens, braces, or commas.
+ # Note, a valid prototype cannot contain any alphabetic character
+ # see https://perldoc.perl.org/perlsub
+ # But it appears that an underscore may be valid now
my $saw_opening_paren = $input_line =~ /\G\s*\(/;
if (
- $input_line =~ m/\G(\s*\([^\)\(\}\{\,]*\))? # PROTO
+ ## FIXME: this should be the future version after some
+ ## problems are resolved
+ ## $input_line =~ m/\G(\s*\([^\)\(\}\{\,#A-Za-z]*\))? # PROTO
+ $input_line =~ m/\G(\s*\([^\)\(\}\{\,#]*\))? # PROTO
(\s*:)? # ATTRS leading ':'
/gcx
&& ( $1 || $2 )
@is_keyword{@Keywords} = (1) x scalar(@Keywords);
}
1;
-