Perl-Tidy
view release on metacpan or search on metacpan
lib/Perl/Tidy/Tokenizer.pm view on Meta::CPAN
# WARNING: do not include |map|grep|eval or perl may die on
# syntax errors (map1.t).
my @keyword_taking_list = qw(
and chmod chomp chop
chown dbmopen die elsif
exec fcntl for foreach
formline getsockopt given if
index ioctl join kill
local msgctl msgrcv msgsnd
my open or our
pack print printf push
read readpipe recv return
reverse rindex seek select
semctl semget send setpriority
setsockopt shmctl shmget shmread
shmwrite socket socketpair sort
splice split sprintf state
substr syscall sysopen sysread
sysseek system syswrite tie
unless unlink unpack unshift
until vec warn when
while
);
# NOTE: This hash is available but not currently used
$is_keyword_taking_list{$_} = 1 for @keyword_taking_list;
# perl functions which may be unary operators.
# This list is used to decide if a pattern delimited by slashes, /pattern/,
# can follow one of these keywords.
@q = qw( chomp eof eval fc lc pop shift uc undef );
$is_keyword_rejecting_slash_as_pattern_delimiter{$_} = 1 for @q;
# These are keywords for which an arg may optionally be omitted. They are
# currently only used to disambiguate a ? used as a ternary from one used
# as a (deprecated) pattern delimiter. In the future, they might be used
# to give a warning about ambiguous syntax before a /.
# Note: split has been omitted (see note below).
my @keywords_taking_optional_arg = qw(
abs alarm caller chdir chomp chop
chr chroot close cos defined die
eof eval evalbytes exit exp fc
getc glob gmtime hex int last
lc lcfirst length localtime log lstat
mkdir next oct ord pop pos
print printf prototype quotemeta rand readline
readlink readpipe redo ref require reset
reverse rmdir say select shift sin
sleep sqrt srand stat study tell
uc ucfirst umask undef unlink warn
write
);
$is_keyword_taking_optional_arg{$_} = 1 for @keywords_taking_optional_arg;
# This list is used to decide if a pattern delimited by question marks,
# ?pattern?, can follow one of these keywords. Note that from perl 5.22
# on, a ?pattern? is not recognized, so we can be much more strict than
# with a /pattern/. Note that 'split' is not in this list. In current
# versions of perl a question following split must be a ternary, but
# in older versions it could be a pattern. The guessing algorithm will
# decide. We are combining two lists here to simplify the test.
@q = ( @keywords_taking_optional_arg, @operator_requestor );
$is_keyword_rejecting_question_as_pattern_delimiter{$_} = 1 for @q;
# These are not used in any way yet
# my @unused_keywords = qw(
# __FILE__
# __LINE__
# __PACKAGE__
# );
# The list of keywords was originally extracted from function 'keyword' in
# perl file toke.c version 5.005.03, using this utility, plus a
# little editing: (file getkwd.pl):
# while (<>) { while (/\"(.*)\"/g) { print "$1\n"; } }
# Add 'get' prefix where necessary, then split into the above lists.
# This list should be updated as necessary.
# The list should not contain these special variables:
# ARGV DATA ENV SIG STDERR STDIN STDOUT
# __DATA__ __END__
$is_keyword{$_} = 1 for @Keywords;
%matching_end_token = (
'{' => '}',
'(' => ')',
'[' => ']',
'<' => '>',
);
} ## end BEGIN
} ## end package Perl::Tidy::Tokenizer
1;
( run in 0.507 second using v1.01-cache-2.11-cpan-71847e10f99 )