1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
|
" Vim syntax file;
" Language: Perl
" Maintainer: Nick Hibma <nick.hibma@jrc.it>
" Last change: 1998 Aug 26
"
" Original version: Sonia Heimann <niania@netsurf.org>
" 1998/08/25 NWH Added perl_sync_dist
" 1998/08/26 NWH Cleaned it up and added help files.
" Remove any old syntax stuff hanging around
syn clear
"
" the following parameters are available for tuning the
" perl syntax highlighting
"
"let perl_want_scope_in_variables = 1
"let perl_extended_vars = 1
"let perl_highlight_matches = 1
"let perl_no_sync_on_sub = 1
"let perl_sync_dist = 200
" First, treat the the #!/bin/perl
syn match perlSharpBang "^#!.\+$"
" All other # are comment, when at the beginning of a line or after a space
" (avoid m## case ...)
syn match perlComment "^#\([^!].*\)\=$\|\s#.*" contains=perlTodo
"
" POD documentation
"
" POD starts with ^=head and ends with =cut
" Set the variable "perl_embedded_pod" to use embedded POD syntax file.
if !exists("perl_embedded_pod")
syntax region perlPOD start=+^=head+ end=+=cut+
syn sync match perlSyncPOD grouphere perlPOD "^=head"
syn sync match perlSyncPOD groupthere NONE "^=cut"
else
let b:embedded_pod = 1
source <sfile>:p:h/pod.vim
unlet b:embedded_pod
syn region perlEmbeddedPod start="^=pod" start="^=head1" matchgroup=podCommand end="^=cut" contains=podCommand,podVerbatimLine,podSpecial,podFormat
syn sync match perlEmbeddedPod grouphere perlEmbeddedPod "^=pod"
syn sync match perlEmbeddedPod grouphere perlEmbeddedPod "^=head1"
syn sync match perlEmbeddedPod groupthere NONE "^=cut"
endif
"
" Syncing to speed up processing
"
if !exists("perl_no_sync_on_sub")
syn sync match perlSync grouphere NONE "^package\s+"
syn sync match perlSync grouphere NONE "^sub\s\+"
endif
if exists("perl_sync_dist")
execute "syn sync maxlines=" . perl_sync_dist
else
syn sync maxlines=100
endif
"
" All keywords
"
syn keyword perlLabel case default
syn keyword perlConditional if elsif unless else switch eq ne gt lt ge le cmp not and or xor
syn keyword perlRepeat while for foreach do until
syn keyword perlOperator defined undef and or not bless ref
syn keyword perlControl BEGIN END
syn keyword perlStatementStorageClass my local
syn keyword perlStatementControl goto return last next continue redo
syn keyword perlStatementScalar chomp chop chr crypt index lc lcfirst length ord pack reverse rindex sprintf substr uc ucfirst
syn keyword perlStatementRegexp pos quotemeta split study
syn keyword perlStatementNumeric abs atan2 cos exp hex int log oct rand sin sqrt srand
syn keyword perlStatementList splice unshift shift push pop split join reverse grep map qw sort unpack
syn keyword perlStatementHash each exists keys values
syn keyword perlStatementIOfunc binmode close closedir dbmclose dbmopen die eof fileno flock format getc print printf read readdir rewinddir seek seekdir select syscall sysopen sysread syswrite tell telldir truncate warn write
syn keyword perlStatementFixedlength pack vec
syn keyword perlStatementFiles chdir chmod chown chroot fcntl glob ioctl link lstat mkdir open opendir readlink rename rmdir stat symlink umask unlink utime
syn keyword perlStatementFlow caller die dump eval exit wantarray
syn keyword perlStatementInclude use require
syn keyword perlStatementScope import
syn keyword perlStatementProc alarm exec fork getpgrp getppid getpriority kill pipe qx setpgrp setpriority sleep system times wait waitpid
syn keyword perlStatementSocket accept bind connect getpeername getsockname getsockopt listen recv send setsockopt shutdown socket socketpair
syn keyword perlStatementIPC msgctl msgget msgrcv msgsnd semctl semget semop shmctl shmget shmread shmwrite
syn keyword perlStatementNetwork endprotoent endservent gethostbyaddr gethostbyname gethostent getnetbyaddr getnetbyname getnetent getprotobyname getprotobynumber getprotoent getservbyname getservbyport getservent sethostent setnetent setprotoent setservent
syn keyword perlStatementTime gmtime localtime time times
syn keyword perlStatementMisc print warn formline reset scalar new delete STDIN STDOUT STDERR
syn keyword perlTodo contained TODO TBD FIXME
"
" Perl Identifiers.
"
" Plain identifier:
" Scalar identifier: $foo
" Array identifier: @foo
" Array Length: $#foo
" Hash identifier: %foo
" Function identifier: &foo
" Reference dereferences: @$foo, %$$foo, &$foo, $$foo, ...
" We do not process complex things such as @{${"foo"}}. Too complicated, and
" too slow. And what is after the -> is *not* considered as part of the
" variable - there again, too complicated and too slow.
" Special variables first ($^A, ...) and ($|, $', ...)
syn match perlVarPlain "$^[\u\\\"\[\]'&`+*.,;=%~^!@$<>(0-9-]"
syn match perlVarPlain "$[\\\"\[\]'&`+*.,;=%~^!@$<>(0-9-]"
" Same as above, but avoids confusion in $::hello (equivalent to $main::hello)
syn match perlVarPlain "$:[^:]"
" These variables are not recognized within matches.
syn match perlVarNotInMatches "$[|)]"
" This variable is not recognized within matches delimited by //.
syn match perlVarSlash "$/"
" And plain identifiers
syn match perlPackageRef "\(\h\w*\)\=\(::\|'\)\I"me=e-1 contained
" To highlight packages in variables as a scope reference - i.e. in $pack::var,
" pack:: is a scope, just set "perl_want_scope_in_variables"
" If you *want* complex things like @{${"foo"}} to be processed,
" just set the variable "perl_extended_vars"...
if exists("perl_want_scope_in_variables")
syn match perlVarPlain "\\\=\(\$#\|[@%&$]\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember
else
syn match perlVarPlain "\\\=\(\$#\|[@%&$]\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember
endif
if exists("perl_extended_vars")
syn region perlVarPlain start="\($#\|[@%\$]\){" skip="\\}" end="}" contains=perlVarPlain,perlVarNotInMatches,perlVarSlash nextgroup=perlVarMember
syn region perlVarMember start="\(->\)\={" skip="\\}" end="}" contained contains=perlVarPlain,perlVarNotInMatches,perlVarSlash nextgroup=perlVarMember
syn region perlVarMember start="\(->\)\=\[" skip="\\]" end="]" contained contains=perlVarPlain,perlVarNotInMatches,perlVarSlash nextgroup=perlVarMember
endif
"
" String and Character constants
"
" Highlight special characters (those which have a backslash) differently
syn match perlSpecial contained "\\\(\d\+\|[xX]\x\+\|.\)"
" "" String may contain variables
syn match perlCharacter "'[^\\]'"
syn match perlSpecialCharacter "'\\.'"
" version < 5.2f
"syn match perlSpecialCharacter "'\\[0-9][0-9][0-9]'"
" versions >= 5.2f
syn match perlSpecialCharacter "'\\\d\d\d'"
" Strings
syn region perlString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=perlSpecial,perlVarPlain,perlVarNotInMatches,perlVarSlash
" '' Strings may not contain anything
syn region perlStringUnexpanded start=+'+ skip=+\\\\\|\\"+ end=+'+
"contains=perlSpecial
syn region perlStringUnexpanded start="qw("hs=s+2 skip="\\\\\|\\)" end=")"
"contains=perlSpecial
" Shell commands
syn region perlShellCommand start=+`+ skip=+\\\\\|\\"+ end=+`+ contains=perlSpecial,perlVarPlain
" Numbers
syn match perlNumber "-\=\<\d\+L\=\>\|0[xX]\x\+\>"
" Constructs such as print <<EOF [...] EOF
syn region perlUntilEOF start=+<<\(["`]\=\)EOF\1+hs=s+2 end=+^EOF$+ contains=perlSpecial,perlVarPlain,perlVarNotInMatches,perlVarSlash
syn region perlUntilEOF start=+<<'EOF'+hs=s+2 end=+^EOF$+ contains=perlSpecial
" When vim supports it, try to use something as
" syntax region perlUntilEOF start=+<<\(["`]\=\)\([a-zA-Z]\+\)\1+s+2 end=+^\2$+
" to allow any keyword, not just EOF. The \2 in the end pattern refers of
" course to the second group in the start pattern.
"
" Perl regexps, second version, thanks to Michael Firestone
"
" any qq## expression
syn match perlQQ "\<q[qxw]\=\([^\s\w]\).*[^\\]\(\\\\\)*\1" contains=perlVarPlain, perlVarSlash
" Any m## match
syn match perlMatchAny "\<m\([^\s\w]\).*[^\\]\(\\\\\)*\1[xosmige]*" contains=perlVarPlain,perlVarSlash
" Plain m// match
syn match perlMatchAny "\<m/.*[^\\]\(\\\\\)*/[xosmige]*" contains=perlVarPlain
" Any s### substitute
" s/// is handled separately, since it can't contain $/ as a variable.
syn match perlSubstitute "\<s\([^\w\s]\).\{-}[^\\]\(\\\\\)*\1.\{-}[^\\]\(\\\\\)*\1[xosmige]*" contains=perlVarPlain,perlVarSlash
syn match perlSubstitute "\<\(s\|y\|tr\)/.\{-}[^\\]\(\\\\\)*/.\{-}[^\\]\(\\\\\)*/[xosmige]*" contains=perlVarPlain
" Note that the above rules don't match substitutions with empty
" replacement texts (like s/deleteme//); these rules cover those.
syn match perlSubstitute "\<s\([^\w\s]\).\{-}[^\\]\(\\\\\)*\1\1[xosmige]*" contains=perlVarPlain,perlVarSlash
syn match perlSubstitute "\<\(s\|y\|tr\)/.\{-}[^\\]\(\\\\\)*//[xosmige]*" contains=perlVarPlain
" The classical // construct
syn match perlMatch "/\(\\/\|[^/]\)*[^\\]\(\\\\\)*/[xosmige]*" contains=perlVarPlain
syn match perlClassDecl "^\s*package\>[^;]*"
"syn match perlLineSkip "\\$"
"
" Functions
"
" find ^sub foo { . Only highlight foo.
" Function is sub foo { , sub foo( , sub foo;
" Sneaky: Instead of terminating the region at a '(' (the start of a
" prototype), contain the prototype in the region and give it no
" highlighting; that way, things inside the prototype that look like
" variables won't be highlighted as variables.
syn region perlFunction start=+^\s*sub\s\++ end=+[;{]+me=s-1 contains=perlFunction,perlFunctionPrototype
syn match perlFunctionPrototype "([^)]*)" contained
syn match perlStatementSub "sub" contained
if !exists("did_perl_syntax_inits")
let did_perl_syntax_inits = 1
" The default methods for highlighting. Can be overridden later
hi link perlSharpBang PreProc
hi link perlLabel Label
hi link perlConditional Conditional
hi link perlRepeat Repeat
hi link perlOperator Operator
hi link perlList perlStatement
hi link perlMisc perlStatement
hi link perlVarPlain perlIdentifier
hi link perlVarMember perlIdentifier
hi link perlVarNotInMatches perlIdentifier
hi link perlVarSlash perlIdentifier
hi link perlQQ perlString
hi link perlUntilEOF perlString
hi link perlStringUnexpanded perlString
hi link perlCharacter Character
hi link perlSpecialCharacter perlSpecial
hi link perlMatchAny perlMatch
hi link perlSubstitute perlMatch
" I happen to prefer having matches and substitutions highlighted; if you
" agree, set the variable "perl_highlight_matches".
if exists("perl_highlight_matches")
hi link perlMatch perlString
endif
hi link perlNumber Number
hi link perlClassDecl Typedef
hi link perlStorageClass perlType
hi link perlPackageRef perlType
hi link perlInclude Include
hi link perlControl PreProc
hi link perlStatementStorageClass perlStatement
hi link perlStatementControl perlStatement
hi link perlStatementScalar perlStatement
hi link perlStatementRegexp perlStatement
hi link perlStatementNumeric perlStatement
hi link perlStatementList perlStatement
hi link perlStatementHash perlStatement
hi link perlStatementIOfunc perlStatement
hi link perlStatementFixedlength perlStatement
hi link perlStatementFiles perlStatement
hi link perlStatementFlow perlStatement
hi link perlStatementScope perlStatement
hi link perlStatementInclude perlStatement
hi link perlStatementProc perlStatement
hi link perlStatementSocket perlStatement
hi link perlStatementIPC perlStatement
hi link perlStatementNetwork perlStatement
hi link perlStatementTime perlStatement
hi link perlStatementMisc perlStatement
hi link perlStatementSub perlStatement
hi link perlStatement Statement
hi link perlType Type
hi link perlString String
hi link perlPOD perlComment
hi link perlShellCommand Special
hi link perlComment Comment
hi link perlSpecial Special
hi link perlTodo Todo
hi link perlFunction Function
hi link perlIdentifier Identifier
endif
let b:current_syntax = "perl"
" vim: ts=8
|