_square_bracket_depth => $square_bracket_depth,
_paren_depth => $paren_depth,
_quote_character => EMPTY_STRING,
-## _rtoken_type => undef,
-## _rtokens => undef,
-## _rlevels => undef,
-## _rblock_type => undef,
-## _rcontainer_type => undef,
-## _rcontainer_environment => undef,
-## _rtype_sequence => undef,
-## _rnesting_tokens => undef,
-## _rci_levels => undef,
-## _rnesting_blocks => undef,
-## _starting_in_quote => 0,
-## _ending_in_quote => 0,
+## _rtoken_type => undef,
+## _rtokens => undef,
+## _rlevels => undef,
+## _rblock_type => undef,
+## _rtype_sequence => undef,
+## _rci_levels => undef,
+## _starting_in_quote => 0,
+## _ending_in_quote => 0,
};
# must print line unchanged if we are in a here document
my $tok_begin = $tok;
my $number;
- ##################################
+ #---------------------------------
# Quick check for (signed) integer
- ##################################
+ #---------------------------------
# This will be the string of digits:
my $i_d = $i;
}
}
- #######################################
+ #--------------------------------------
# Verify correctness during development
- #######################################
+ #--------------------------------------
if ( VERIFY_FASTNUM && defined($number) ) {
# We will call the full method
}
}
- #########################################
+ #----------------------------------------
# call full scanner if may not be integer
- #########################################
+ #----------------------------------------
if ( !defined($number) ) {
$number = scan_number();
}
);
}
}
- elsif ( $tok eq 'continue' ) {
- if ( $last_nonblank_token ne ';'
- && $last_nonblank_block_type !~
- /(^(\{|\}|;|while|until|for|foreach)|:$)/ )
- {
-
- # note: ';' '{' and '}' in list above
- # because continues can follow bare blocks;
- # ':' is labeled block
- #
- ############################################
- # NOTE: This check has been deactivated because
- # continue has an alternative usage for given/when
- # blocks in perl 5.10
- ## warning("'$tok' should follow a block\n");
- ############################################
- }
- }
# patch for SWITCH/CASE if 'case' and 'when are
# treated as keywords. Also 'default' for Switch::Plain
$statement_type = $tok; # next '{' is block
}
- #
- # indent trailing if/unless/while/until
- # outdenting will be handled by later indentation loop
-## DEACTIVATED: unfortunately this can cause some unwanted indentation like:
-##$opt_o = 1
-## if !(
-## $opt_b
-## || $opt_c
-## || $opt_d
-## || $opt_f
-## || $opt_i
-## || $opt_l
-## || $opt_o
-## || $opt_x
-## );
-## if ( $tok =~ /^(if|unless|while|until)$/
-## && $next_nonblank_token ne '(' )
-## {
-## $indent_flag = 1;
-## }
return;
} ## end sub do_KEYWORD
sub do_QUOTE_OPERATOR {
-##NICOL PATCH
+
if ( $expecting == OPERATOR ) {
# Be careful not to call an error for a qw quote
$in_attribute_list = 0;
}
- ###############################################################
+ #--------------------------------------------------------
# We have the next token, $tok.
# Now we have to examine this token and decide what it is
# and define its $type
#
# section 1: bare words
- ###############################################################
+ #--------------------------------------------------------
if ( $pre_type eq 'w' ) {
$expecting =
last if ($is_last);
}
- ###############################################################
+ #-----------------------------
# section 2: strings of digits
- ###############################################################
+ #-----------------------------
elsif ( $pre_type eq 'd' ) {
$expecting =
operator_expected( [ $prev_type, $tok, $next_type ] );
do_DIGITS();
}
- ###############################################################
+ #----------------------------
# section 3: all other tokens
- ###############################################################
+ #----------------------------
else {
my $code = $tokenization_code->{$tok};
if ($code) {
my $rtoken_map_im;
foreach my $i ( @{$routput_token_list} ) {
- # Get $tok_i, the PRE-token. It only equals the token for symbols
my $type_i = $routput_token_type->[$i];
- my $tok_i = $rtokens->[$i];
# Quick handling of indentation levels for blanks and comments
if ( $type_i eq 'b' || $type_i eq '#' ) {
# All other types
else {
+ # $tok_i is the PRE-token. It only equals the token for symbols
+ my $tok_i = $rtokens->[$i];
+
# Check for an invalid token type..
# This can happen by running perltidy on non-scripts although
# it could also be bug introduced by programming change. Perl
} ## end sub tokenizer_wrapup_line
} ## end tokenize_this_line
-#########i#############################################################
+#######################################################################
# Tokenizer routines which assist in identifying token types
#######################################################################
my ($rarg) = @_;
- ##############
+ #-------------
# Table lookup
- ##############
+ #-------------
# Many types are can be obtained by a table lookup given the previous type.
# This typically handles half or more of the calls.
return $op_expected;
}
- ######################
+ #---------------------
# Handle special cases
- ######################
+ #---------------------
$op_expected = UNKNOWN;
my ( $prev_type, $tok, $next_type ) = @{$rarg};
$op_expected = OPERATOR; # block mode following }
}
- ##elsif ( $last_nonblank_token =~ /^(\)|\$|\-\>)/ ) {
+ # $last_nonblank_token =~ /^(\)|\$|\-\>)/
elsif ( $is_paren_dollar{ substr( $last_nonblank_token, 0, 1 ) }
|| substr( $last_nonblank_token, 0, 2 ) eq '->' )
{
}
}
- ################################################################
+ #--------------------------------------------------------------
# NOTE: braces after type characters start code blocks, but for
# simplicity these are not identified as such. See also
# sub is_non_structural_brace.
- ################################################################
+ #--------------------------------------------------------------
## elsif ( $last_nonblank_type eq 't' ) {
## return $last_nonblank_token;
# return 0;
# }
- ################################################################
+ #--------------------------------------------------------------
# NOTE: braces after type characters start code blocks, but for
# simplicity these are not identified as such. See also
# sub code_block_type
- ################################################################
+ #--------------------------------------------------------------
##if ($last_nonblank_type eq 't') {return 0}
);
} ## end sub is_non_structural_brace
-#########i#############################################################
+#######################################################################
# Tokenizer routines for tracking container nesting depths
#######################################################################
# a unique set of numbers but still allows the relative location
# of any type to be determined.
- ########################################################################
- # OLD SEQNO METHOD for incrementing sequence numbers.
- # Keep this coding awhile for possible testing.
- ## $nesting_sequence_number[$aa] += scalar(@closing_brace_names);
- ## my $seqno = $nesting_sequence_number[$aa];
-
- # NEW SEQNO METHOD, continuous sequence numbers. This allows sequence
- # numbers to be used as array indexes, and allows them to be compared.
+ # make a new unique sequence number
my $seqno = $next_sequence_number++;
- ########################################################################
$current_sequence_number[$aa][ $current_depth[$aa] ] = $seqno;
return;
} ## end sub check_final_nesting_depths
-#########i#############################################################
+#######################################################################
# Tokenizer routines for looking ahead in input stream
#######################################################################
return;
} ## end sub peek_ahead_for_nonblank_token
-#########i#############################################################
+#######################################################################
# Tokenizer guessing routines for ambiguous situations
#######################################################################
return $here_doc_expected;
} ## end sub guess_if_here_doc
-#########i#############################################################
+#######################################################################
# Tokenizer Routines for scanning identifiers and related items
#######################################################################
# return flag telling caller to split the pretoken
my $split_pretoken_flag;
- ####################
+ #-------------------
# Initialize my vars
- ####################
+ #-------------------
initialize_my_scan_id_vars();
- #########################################################
+ #--------------------------------------------------------
# get started by defining a type and a state if necessary
- #########################################################
+ #--------------------------------------------------------
if ( !$id_scan_state ) {
$context = UNKNOWN_CONTEXT;
}
}
- ###############################
+ #------------------------------
# loop to gather the identifier
- ###############################
+ #------------------------------
$i_save = $i;
} ## end of main loop
- ##############
+ #-------------
# Check result
- ##############
+ #-------------
# Be sure a valid state is returned
if ($id_scan_state) {
} ## end sub do_scan_sub
}
-#########i###############################################################
+#########################################################################
# Tokenizer utility routines which may use CONSTANTS but no other GLOBALS
#########################################################################
# characters, whereas for a non-alphanumeric delimiter, only tokens of
# length 1 can match.
- ###################################################################
+ #----------------------------------------------------------------
# Case 1 (rare): loop for case of alphanumeric quote delimiter..
# "quote_pos" is the position the current word to begin searching
- ###################################################################
+ #----------------------------------------------------------------
if ( $beginning_tok =~ /\w/ ) {
# Note this because it is not recommended practice except
}
}
- ########################################################################
+ #-----------------------------------------------------------------------
# Case 2 (normal): loop for case of a non-alphanumeric quote delimiter..
- ########################################################################
+ #-----------------------------------------------------------------------
else {
while ( $i < $max_token_index ) {