my $block_count = 0;
my $elsif_count = 0;
- # we are tracing the sequence numbers of each if/elsif/else block
+ # we are tracing the sequence numbers of consecutive if/elsif/else blocks
my $seqno = $seqno_if;
while ($seqno) {
push @seqno_list, $seqno;
unless ( $type_k eq 'k'
&& ( $token_k eq 'elsif' || $token_k eq 'else' ) );
- # Handle 'else' : next token be the opening block brace
+ # Handle keyword 'else' : next token be the opening block brace
if ( $token_k eq 'else' ) {
# } else {
last;
}
- # Handle 'elsif':
+ # Handle keyword 'elsif':
# } elsif ( $something ) {
# ^ ^ ^ ^ ^
# Handle a list container
if ( $is_list && !$block_type ) {
$ris_list_by_seqno->{$seqno} = $seqno;
+
+ # Update parent container properties
my $depth = 0;
my $seqno_parent = $seqno;
while ( $seqno_parent = $rparent_of_seqno->{$seqno_parent} ) {
# Handle code blocks ...
# The -lp option needs to know if a container holds a code block
elsif ( $block_type && $rOpts_line_up_parentheses ) {
+
+ # Update parent container properties
my $seqno_parent = $seqno;
while ( $seqno_parent = $rparent_of_seqno->{$seqno_parent} ) {
last if ( $seqno_parent == SEQ_ROOT );
# Find containers with ternaries, needed for -lp formatting.
foreach my $seqno ( keys %{$K_opening_ternary} ) {
+
+ # Update parent container properties
my $seqno_parent = $seqno;
while ( $seqno_parent = $rparent_of_seqno->{$seqno_parent} ) {
last if ( $seqno_parent == SEQ_ROOT );
# $seqno of the sub, or
# nothing if no sub found
return unless defined($seqno_paren);
+
+ # Search upward
my $parent_seqno = $seqno_paren;
while ( $parent_seqno = $self->[_rparent_of_seqno_]->{$parent_seqno} ) {
last if ( $parent_seqno == SEQ_ROOT );
$Knext = $Knext_guess + 1;
}
+ # search for the change in input line number
while ($Knext <= $Kmax
&& $rLL->[$Knext]->[_LINE_INDEX_] <= $iline )
{
my $ii = $package_stack[-1];
my $Kc = $package_info_list[$ii]->{K_closing};
- # pop any inactive stack items
+ # pop an inactive stack item and keep going
if ( $Kc < $K_opening ) {
pop @package_stack;
my $i_top = $package_stack[-1];