3 " Maintainer: Nick Hibma <nick@van-laarhoven.org>
4 " Last Change: 2006 November 23
5 " Location: http://www.van-laarhoven.org/vim/syntax/perl.vim
7 " Please download most recent version first before mailing
9 " See also the file perl.vim.regression.pl to check whether your
10 " modifications work in the most odd cases
11 " http://www.van-laarhoven.org/vim/syntax/perl.vim.regression.pl
13 " Original version: Sonia Heimann <niania@netsurf.org>
14 " Thanks to many people for their contribution.
16 " The following parameters are available for tuning the
17 " perl syntax highlighting, with defaults given:
19 " unlet perl_include_pod
20 " unlet perl_want_scope_in_variables
21 " unlet perl_extended_vars
22 " unlet perl_string_as_statement
23 " unlet perl_no_sync_on_sub
24 " unlet perl_no_sync_on_global_var
25 " let perl_sync_dist = 100
27 " unlet perl_fold_blocks
28 " let perl_nofold_packages = 1
29 " let perl_nofold_subs = 1
31 " Remove any old syntax stuff that was loaded (5.x) or quit when a syntax file
32 " was already loaded (6.x).
35 elseif exists("b:current_syntax")
39 " Unset perl_fold if it set but vim doesn't support it.
40 if version < 600 && exists("perl_fold")
45 " POD starts with ^=<word> and ends with ^=cut
47 if exists("perl_include_pod")
48 " Include a while extra syntax file
49 syn include @Pod syntax/pod.vim
50 unlet b:current_syntax
51 if exists("perl_fold")
52 syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend fold
53 syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend fold
55 syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend
56 syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend
59 " Use only the bare minimum of rules
60 if exists("perl_fold")
61 syn region perlPOD start="^=[a-z]" end="^=cut" fold
63 syn region perlPOD start="^=[a-z]" end="^=cut"
70 if exists("perl_fold") && exists("perl_fold_blocks")
71 syn match perlConditional "\<if\>"
72 syn match perlConditional "\<elsif\>"
73 syn match perlConditional "\<unless\>"
74 syn match perlConditional "\<else\>" nextgroup=perlElseIfError skipwhite skipnl skipempty
76 syn keyword perlConditional if elsif unless
77 syn keyword perlConditional else nextgroup=perlElseIfError skipwhite skipnl skipempty
79 syn keyword perlConditional switch eq ne gt lt ge le cmp not and or xor err
80 if exists("perl_fold") && exists("perl_fold_blocks")
81 syn match perlRepeat "\<while\>"
82 syn match perlRepeat "\<for\>"
83 syn match perlRepeat "\<foreach\>"
84 syn match perlRepeat "\<do\>"
85 syn match perlRepeat "\<until\>"
86 syn match perlRepeat "\<continue\>"
88 syn keyword perlRepeat while for foreach do until continue
90 syn keyword perlOperator defined undef and or not bless ref
91 if exists("perl_fold")
92 " if BEGIN/END would be a keyword the perlBEGINENDFold does not work
93 syn match perlControl "\<BEGIN\|CHECK\|INIT\|END\>" contained
95 syn keyword perlControl BEGIN END CHECK INIT
98 syn keyword perlStatementStorage my local our
99 syn keyword perlStatementControl goto return last next redo
100 syn keyword perlStatementScalar chomp chop chr crypt index lc lcfirst length ord pack reverse rindex sprintf substr uc ucfirst
101 syn keyword perlStatementRegexp pos quotemeta split study
102 syn keyword perlStatementNumeric abs atan2 cos exp hex int log oct rand sin sqrt srand
103 syn keyword perlStatementList splice unshift shift push pop split join reverse grep map sort unpack
104 syn keyword perlStatementHash each exists keys values tie tied untie
105 syn keyword perlStatementIOfunc carp confess croak dbmclose dbmopen die syscall
106 syn keyword perlStatementFiledesc binmode close closedir eof fileno getc lstat print printf readdir readline readpipe rewinddir select stat tell telldir write nextgroup=perlFiledescStatementNocomma skipwhite
107 syn keyword perlStatementFiledesc fcntl flock ioctl open opendir read seek seekdir sysopen sysread sysseek syswrite truncate nextgroup=perlFiledescStatementComma skipwhite
108 syn keyword perlStatementVector pack vec
109 syn keyword perlStatementFiles chdir chmod chown chroot glob link mkdir readlink rename rmdir symlink umask unlink utime
110 syn match perlStatementFiles "-[rwxoRWXOezsfdlpSbctugkTBMAC]\>"
111 syn keyword perlStatementFlow caller die dump eval exit wantarray
112 syn keyword perlStatementInclude require
113 syn match perlStatementInclude "\<\(use\|no\)\s\+\(\(integer\|strict\|lib\|sigtrap\|subs\|vars\|warnings\|utf8\|byte\|base\|fields\)\>\)\="
114 syn keyword perlStatementScope import
115 syn keyword perlStatementProc alarm exec fork getpgrp getppid getpriority kill pipe setpgrp setpriority sleep system times wait waitpid
116 syn keyword perlStatementSocket accept bind connect getpeername getsockname getsockopt listen recv send setsockopt shutdown socket socketpair
117 syn keyword perlStatementIPC msgctl msgget msgrcv msgsnd semctl semget semop shmctl shmget shmread shmwrite
118 syn keyword perlStatementNetwork endhostent endnetent endprotoent endservent gethostbyaddr gethostbyname gethostent getnetbyaddr getnetbyname getnetent getprotobyname getprotobynumber getprotoent getservbyname getservbyport getservent sethostent setnetent setprotoent setservent
119 syn keyword perlStatementPword getpwuid getpwnam getpwent setpwent endpwent getgrent getgrgid getlogin getgrnam setgrent endgrent
120 syn keyword perlStatementTime gmtime localtime time times
122 syn keyword perlStatementMisc warn formline reset scalar delete prototype lock
123 syn keyword perlStatementNew new
125 syn keyword perlTodo TODO TBD FIXME XXX contained
129 " Should be cleaned up to better handle identifiers in particular situations
130 " (in hash keys for example)
132 " Plain identifiers: $foo, @foo, $#foo, %foo, &foo and dereferences $$foo, @$foo, etc.
133 " We do not process complex things such as @{${"foo"}}. Too complicated, and
134 " too slow. And what is after the -> is *not* considered as part of the
135 " variable - there again, too complicated and too slow.
137 " Special variables first ($^A, ...) and ($|, $', ...)
138 syn match perlVarPlain "$^[ADEFHILMOPSTWX]\="
139 syn match perlVarPlain "$[\\\"\[\]'&`+*.,;=%~!?@#$<>(-]"
140 syn match perlVarPlain "$\(0\|[1-9][0-9]*\)"
141 " Same as above, but avoids confusion in $::foo (equivalent to $main::foo)
142 syn match perlVarPlain "$:[^:]"
143 " These variables are not recognized within matches.
144 syn match perlVarNotInMatches "$[|)]"
145 " This variable is not recognized within matches delimited by m//.
146 syn match perlVarSlash "$/"
148 " And plain identifiers
149 syn match perlPackageRef "\(\h\w*\)\=\(::\|'\)\I"me=e-1 contained
151 " To highlight packages in variables as a scope reference - i.e. in $pack::var,
152 " pack:: is a scope, just set "perl_want_scope_in_variables"
153 " If you *want* complex things like @{${"foo"}} to be processed,
154 " just set the variable "perl_extended_vars"...
156 " FIXME value between {} should be marked as string. is treated as such by Perl.
157 " At the moment it is marked as something greyish instead of read. Probably todo
158 " with transparency. Or maybe we should handle the bare word in that case. or make it into
160 if exists("perl_want_scope_in_variables")
161 syn match perlVarPlain "\\\=\([@$]\|\$#\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
162 syn match perlVarPlain2 "\\\=%\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
163 syn match perlFunctionName "\\\=&\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember
165 syn match perlVarPlain "\\\=\([@$]\|\$#\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
166 syn match perlVarPlain2 "\\\=%\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember,perlMethod
167 syn match perlFunctionName "\\\=&\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember
170 if exists("perl_extended_vars")
171 syn cluster perlExpr contains=perlStatementScalar,perlStatementRegexp,perlStatementNumeric,perlStatementList,perlStatementHash,perlStatementFiles,perlStatementTime,perlStatementMisc,perlVarPlain,perlVarPlain2,perlVarNotInMatches,perlVarSlash,perlVarBlock,perlShellCommand,perlFloat,perlNumber,perlStringUnexpanded,perlString,perlQQ
172 syn region perlVarBlock matchgroup=perlVarPlain start="\($#\|[@%$]\)\$*{" skip="\\}" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
173 syn region perlVarBlock matchgroup=perlVarPlain start="&\$*{" skip="\\}" end="}" contains=@perlExpr
174 syn match perlVarPlain "\\\=\(\$#\|[@%&$]\)\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember
175 syn region perlVarMember matchgroup=perlVarPlain start="\(->\)\={" skip="\\}" end="}" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
176 syn match perlVarSimpleMember "\(->\)\={\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember contains=perlVarSimpleMemberName contained
177 syn match perlVarSimpleMemberName "\I\i*" contained
178 syn region perlVarMember matchgroup=perlVarPlain start="\(->\)\=\[" skip="\\]" end="]" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
179 syn match perlMethod "\(->\)\I\i*" contained
183 syn match perlFiledescRead "[<]\h\w\+[>]"
185 syn match perlFiledescStatementComma "(\=\s*\u\w*\s*,"me=e-1 transparent contained contains=perlFiledescStatement
186 syn match perlFiledescStatementNocomma "(\=\s*\u\w*\s*[^, \t]"me=e-1 transparent contained contains=perlFiledescStatement
188 syn match perlFiledescStatement "\u\w*" contained
190 " Special characters in strings and matches
191 syn match perlSpecialString "\\\(\d\+\|[xX]\x\+\|c\u\|.\)" contained
192 syn match perlSpecialStringU "\\['\\]" contained
193 syn match perlSpecialMatch "{\d\+\(,\(\d\+\)\=\)\=}" contained
194 syn match perlSpecialMatch "\[\(\]\|-\)\=[^\[\]]*\(\[\|\-\)\=\]" contained
195 syn match perlSpecialMatch "[+*()?.]" contained
196 syn match perlSpecialMatch "(?[#:=!]" contained
197 syn match perlSpecialMatch "(?[imsx]\+)" contained
198 " FIXME the line below does not work. It should mark end of line and
199 " begin of line as perlSpecial.
200 " syn match perlSpecialBEOM "^\^\|\$$" contained
204 " Highlight lines with only whitespace (only in blank delimited here documents) as errors
205 syn match perlNotEmptyLine "^\s\+$" contained
206 " Highlight '} else if (...) {', it should be '} else { if (...) { ' or
208 "syn keyword perlElseIfError if contained
210 " Variable interpolation
212 " These items are interpolated inside "" strings and similar constructs.
213 syn cluster perlInterpDQ contains=perlSpecialString,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBlock
214 " These items are interpolated inside '' strings and similar constructs.
215 syn cluster perlInterpSQ contains=perlSpecialStringU
216 " These items are interpolated inside m// matches and s/// substitutions.
217 syn cluster perlInterpSlash contains=perlSpecialString,perlSpecialMatch,perlVarPlain,perlVarBlock,perlSpecialBEOM
218 " These items are interpolated inside m## matches and s### substitutions.
219 syn cluster perlInterpMatch contains=@perlInterpSlash,perlVarSlash
222 syn region perlShellCommand matchgroup=perlMatchStartEnd start="`" end="`" contains=@perlInterpDQ
227 syn match perlNumber "[-+]\=\(\<\d[[:digit:]_]*L\=\>\|0[xX]\x[[:xdigit:]_]*\>\)"
228 syn match perlFloat "[-+]\=\<\d[[:digit:]_]*[eE][\-+]\=\d\+"
229 syn match perlFloat "[-+]\=\<\d[[:digit:]_]*\.[[:digit:]_]*\([eE][\-+]\=\d\+\)\="
230 syn match perlFloat "[-+]\=\<\.[[:digit:]_]\+\([eE][\-+]\=\d\+\)\="
233 " Simple version of searches and matches
234 " caters for m//, m##, m{} and m[] (and the !/ variant)
235 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]/+ end=+/[cgimosx]*+ contains=@perlInterpSlash
236 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]#+ end=+#[cgimosx]*+ contains=@perlInterpMatch
237 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]{+ end=+}[cgimosx]*+ contains=@perlInterpMatch
238 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]\[+ end=+\][cgimosx]*+ contains=@perlInterpMatch
240 " A special case for m!!x which allows for comments and extra whitespace in the pattern
241 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]!+ end=+![cgimosx]*+ contains=@perlInterpSlash,perlComment
243 " Below some hacks to recognise the // variant. This is virtually impossible to catch in all
244 " cases as the / is used in so many other ways, but these should be the most obvious ones.
245 syn region perlMatch matchgroup=perlMatchStartEnd start=+^split /+lc=5 start=+[^$@%]\<split /+lc=6 start=+^while /+lc=5 start=+[^$@%]\<while /+lc=6 start=+^if /+lc=2 start=+[^$@%]\<if /+lc=3 start=+[!=]\~\s*/+lc=2 start=+[(~]/+lc=1 start=+\.\./+lc=2 start=+\s/[^= \t0-9$@%]+lc=1,me=e-1,rs=e-1 start=+^/+ skip=+\\/+ end=+/[cgimosx]*+ contains=@perlInterpSlash
249 " caters for s///, s### and s[][]
250 " perlMatch is the first part, perlSubstitution* is the substitution part
251 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlSubstitutionSQ
252 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s"+ end=+"+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionDQ
253 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s/+ end=+/+me=e-1 contains=@perlInterpSlash nextgroup=perlSubstitutionSlash
254 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s#+ end=+#+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionHash
255 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s\[+ end=+\]+ contains=@perlInterpMatch nextgroup=perlSubstitutionBracket skipwhite skipempty skipnl
256 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s{+ end=+}+ contains=@perlInterpMatch nextgroup=perlSubstitutionCurly skipwhite skipempty skipnl
257 syn region perlSubstitutionSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[ecgimosx]*+ contained contains=@perlInterpSQ
258 syn region perlSubstitutionDQ matchgroup=perlMatchStartEnd start=+"+ end=+"[ecgimosx]*+ contained contains=@perlInterpDQ
259 syn region perlSubstitutionSlash matchgroup=perlMatchStartEnd start=+/+ end=+/[ecgimosx]*+ contained contains=@perlInterpDQ
260 syn region perlSubstitutionHash matchgroup=perlMatchStartEnd start=+#+ end=+#[ecgimosx]*+ contained contains=@perlInterpDQ
261 syn region perlSubstitutionBracket matchgroup=perlMatchStartEnd start=+\[+ end=+\][ecgimosx]*+ contained contains=@perlInterpDQ
262 syn region perlSubstitutionCurly matchgroup=perlMatchStartEnd start=+{+ end=+}[ecgimosx]*+ contained contains=@perlInterpDQ
264 " A special case for m!!x which allows for comments and extra whitespace in the pattern
265 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s!+ end=+!+me=e-1 contains=@perlInterpSlash,perlComment nextgroup=perlSubstitutionPling
266 syn region perlSubstitutionPling matchgroup=perlMatchStartEnd start=+!+ end=+![ecgimosx]*+ contained contains=@perlInterpDQ
269 " caters for tr///, tr### and tr[][]
270 " perlMatch is the first part, perlTranslation* is the second, translator part.
271 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationSQ
272 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)"+ end=+"+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationDQ
273 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)/+ end=+/+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationSlash
274 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)#+ end=+#+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationHash
275 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)\[+ end=+\]+ contains=@perlInterpSQ nextgroup=perlTranslationBracket skipwhite skipempty skipnl
276 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\){+ end=+}+ contains=@perlInterpSQ nextgroup=perlTranslationCurly skipwhite skipempty skipnl
277 syn region perlTranslationSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[cds]*+ contained
278 syn region perlTranslationDQ matchgroup=perlMatchStartEnd start=+"+ end=+"[cds]*+ contained
279 syn region perlTranslationSlash matchgroup=perlMatchStartEnd start=+/+ end=+/[cds]*+ contained
280 syn region perlTranslationHash matchgroup=perlMatchStartEnd start=+#+ end=+#[cds]*+ contained
281 syn region perlTranslationBracket matchgroup=perlMatchStartEnd start=+\[+ end=+\][cds]*+ contained
282 syn region perlTranslationCurly matchgroup=perlMatchStartEnd start=+{+ end=+}[cds]*+ contained
285 " The => operator forces a bareword to the left of it to be interpreted as
287 syn match perlString "\<\I\i*\s*=>"me=e-2
289 " Strings and q, qq, qw and qr expressions
292 syn region perlBrackets start=+(+ end=+)+ contained transparent contains=perlBrackets,@perlStringSQ
294 syn region perlStringUnexpanded matchgroup=perlStringStartEnd start="'" end="'" contains=@perlInterpSQ
295 syn region perlString matchgroup=perlStringStartEnd start=+"+ end=+"+ contains=@perlInterpDQ
296 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q#+ end=+#+ contains=@perlInterpSQ
297 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q|+ end=+|+ contains=@perlInterpSQ
298 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q(+ end=+)+ contains=@perlInterpSQ,perlBrackets
299 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q{+ end=+}+ contains=@perlInterpSQ
300 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q/+ end=+/+ contains=@perlInterpSQ
301 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]#+ end=+#+ contains=@perlInterpDQ
302 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]|+ end=+|+ contains=@perlInterpDQ
303 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx](+ end=+)+ contains=@perlInterpDQ,perlBrackets
304 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]{+ end=+}+ contains=@perlInterpDQ
305 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]/+ end=+/+ contains=@perlInterpDQ
306 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw#+ end=+#+ contains=@perlInterpSQ
307 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw|+ end=+|+ contains=@perlInterpSQ
308 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw(+ end=+)+ contains=@perlInterpSQ,perlBrackets
309 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw{+ end=+}+ contains=@perlInterpSQ
310 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw/+ end=+/+ contains=@perlInterpSQ
311 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr#+ end=+#[imosx]*+ contains=@perlInterpMatch
312 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr|+ end=+|[imosx]*+ contains=@perlInterpMatch
313 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr(+ end=+)[imosx]*+ contains=@perlInterpMatch
314 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr{+ end=+}[imosx]*+ contains=@perlInterpMatch
315 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr/+ end=+/[imosx]*+ contains=@perlInterpSlash
317 " Constructs such as print <<EOF [...] EOF, 'here' documents
320 " XXX Any statements after the identifier are in perlString colour (i.e.
321 " 'if $a' in 'print <<EOF if $a').
322 if exists("perl_fold")
323 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\).*+ end=+^\z1$+ contains=@perlInterpDQ fold
324 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z(.\{-}\)"+ end=+^\z1$+ contains=@perlInterpDQ fold
325 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z(.\{-}\)'+ end=+^\z1$+ contains=@perlInterpSQ fold
326 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine fold
327 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine fold
328 syn region perlAutoload matchgroup=perlStringStartEnd start=+<<['"]\z(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)['"]+ end=+^\z1$+ contains=ALL fold
330 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\)+ end=+^\z1$+ contains=@perlInterpDQ
331 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z(.\{-}\)"+ end=+^\z1$+ contains=@perlInterpDQ
332 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z(.\{-}\)'+ end=+^\z1$+ contains=@perlInterpSQ
333 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine
334 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine
335 syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\(['"]\|\)\z(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\z1$+ contains=ALL
338 syn match perlUntilEOFStart "<<EOF.*"lc=5 nextgroup=perlUntilEOFDQ skipnl transparent
339 syn match perlUntilEOFStart "<<\s*\"EOF\".*" nextgroup=perlUntilEOFDQ skipnl transparent
340 syn match perlUntilEOFStart "<<\s*'EOF'.*" nextgroup=perlUntilEOFSQ skipnl transparent
341 syn match perlUntilEOFStart "<<\s*\"\".*" nextgroup=perlUntilEmptyDQ skipnl transparent
342 syn match perlUntilEOFStart "<<\s*''.*" nextgroup=perlUntilEmptySQ skipnl transparent
343 syn region perlUntilEOFDQ matchgroup=perlStringStartEnd start=++ end="^EOF$" contains=@perlInterpDQ contained
344 syn region perlUntilEOFSQ matchgroup=perlStringStartEnd start=++ end="^EOF$" contains=@perlInterpSQ contained
345 syn region perlUntilEmptySQ matchgroup=perlStringStartEnd start=++ end="^$" contains=@perlInterpDQ,perlNotEmptyLine contained
346 syn region perlUntilEmptyDQ matchgroup=perlStringStartEnd start=++ end="^$" contains=@perlInterpSQ,perlNotEmptyLine contained
347 syn match perlHereIdentifier "<<EOF"
348 syn region perlAutoload matchgroup=perlStringStartEnd start=+<<\(['"]\|\)\(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)\1+ end=+^\(END_\(SUB\|OF_FUNC\|OF_AUTOLOAD\)\)$+ contains=ALL
354 syn match perlPackageDecl "^\s*\<package\s\+\S\+" contains=perlStatementPackage
355 syn keyword perlStatementPackage package contained
358 " sub [name] [(prototype)] {
360 syn region perlFunction start="\s*\<sub\>" end="[;{]"he=e-1 contains=perlStatementSub,perlFunctionPrototype,perlFunctionPRef,perlFunctionName,perlComment
361 syn keyword perlStatementSub sub contained
363 syn match perlFunctionPrototype "([^)]*)" contained
364 if exists("perl_want_scope_in_variables")
365 syn match perlFunctionPRef "\h\w*::" contained
366 syn match perlFunctionName "\h\w*[^:]" contained
368 syn match perlFunctionName "\h[[:alnum:]_:]*" contained
371 " All other # are comments, except ^#!
372 syn match perlComment "#.*" contains=perlTodo
373 syn match perlSharpBang "^#!.*"
376 syn region perlFormat matchgroup=perlStatementIOFunc start="^\s*\<format\s\+\k\+\s*=\s*$"rs=s+6 end="^\s*\.\s*$" contains=perlFormatName,perlFormatField,perlVarPlain,perlVarPlain2
377 syn match perlFormatName "format\s\+\k\+\s*="lc=7,me=e-1 contained
378 syn match perlFormatField "[@^][|<>~]\+\(\.\.\.\)\=" contained
379 syn match perlFormatField "[@^]#[#.]*" contained
380 syn match perlFormatField "@\*" contained
381 syn match perlFormatField "@[^A-Za-z_|<>~#*]"me=e-1 contained
382 syn match perlFormatField "@$" contained
384 " __END__ and __DATA__ clauses
385 if exists("perl_fold")
386 syntax region perlDATA start="^__\(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA fold
388 syntax region perlDATA start="^__\(DATA\|END\)__$" skip="." end="." contains=perlPOD,@perlDATA
395 if exists("perl_fold")
396 if !exists("perl_nofold_packages")
397 syn region perlPackageFold start="^package \S\+;\s*\(#.*\)\=$" end="^1;\s*\(#.*\)\=$" end="\n\+package"me=s-1 transparent fold keepend
399 if !exists("perl_nofold_subs")
400 syn region perlSubFold start="^\z(\s*\)\<sub\>.*[^};]$" end="^\z1}\s*\(#.*\)\=$" transparent fold keepend
401 syn region perlSubFold start="^\z(\s*\)\<\(BEGIN\|END\|CHECK\|INIT\)\>.*[^};]$" end="^\z1}\s*$" transparent fold keepend
404 if exists("perl_fold_blocks")
405 syn region perlBlockFold start="^\z(\s*\)\(if\|elsif\|unless\|for\|while\|until\)\s*(.*)\(\s*{\)\=\s*\(#.*\)\=$" start="^\z(\s*\)foreach\s*\(\(my\|our\)\=\s*\S\+\s*\)\=(.*)\(\s*{\)\=\s*\(#.*\)\=$" end="^\z1}\s*;\=\(#.*\)\=$" transparent fold keepend
406 syn region perlBlockFold start="^\z(\s*\)\(do\|else\)\(\s*{\)\=\s*\(#.*\)\=$" end="^\z1}\s*while" end="^\z1}\s*;\=\(#.*\)\=$" transparent fold keepend
409 setlocal foldmethod=syntax
412 " fromstart above seems to set minlines even if perl_fold is not set.
417 if version >= 508 || !exists("did_perl_syn_inits")
419 let did_perl_syn_inits = 1
420 command -nargs=+ HiLink hi link <args>
422 command -nargs=+ HiLink hi def link <args>
425 " The default highlighting.
426 HiLink perlSharpBang PreProc
427 HiLink perlControl PreProc
428 HiLink perlInclude Include
429 HiLink perlSpecial Special
430 HiLink perlString String
431 HiLink perlCharacter Character
432 HiLink perlNumber Number
433 HiLink perlFloat Float
435 HiLink perlIdentifier Identifier
436 HiLink perlLabel Label
437 HiLink perlStatement Statement
438 HiLink perlConditional Conditional
439 HiLink perlRepeat Repeat
440 HiLink perlOperator Operator
441 HiLink perlFunction Function
442 HiLink perlFunctionPrototype perlFunction
443 HiLink perlComment Comment
445 if exists("perl_string_as_statement")
446 HiLink perlStringStartEnd perlStatement
448 HiLink perlStringStartEnd perlString
450 HiLink perlList perlStatement
451 HiLink perlMisc perlStatement
452 HiLink perlVarPlain perlIdentifier
453 HiLink perlVarPlain2 perlIdentifier
454 HiLink perlFiledescRead perlIdentifier
455 HiLink perlFiledescStatement perlIdentifier
456 HiLink perlVarSimpleMember perlIdentifier
457 HiLink perlVarSimpleMemberName perlString
458 HiLink perlVarNotInMatches perlIdentifier
459 HiLink perlVarSlash perlIdentifier
460 HiLink perlQQ perlString
462 HiLink perlHereDoc perlString
464 HiLink perlHereIdentifier perlStringStartEnd
465 HiLink perlUntilEOFDQ perlString
466 HiLink perlUntilEOFSQ perlString
467 HiLink perlUntilEmptyDQ perlString
468 HiLink perlUntilEmptySQ perlString
469 HiLink perlUntilEOF perlString
471 HiLink perlStringUnexpanded perlString
472 HiLink perlSubstitutionSQ perlString
473 HiLink perlSubstitutionDQ perlString
474 HiLink perlSubstitutionSlash perlString
475 HiLink perlSubstitutionHash perlString
476 HiLink perlSubstitutionBracket perlString
477 HiLink perlSubstitutionCurly perlString
478 HiLink perlSubstitutionPling perlString
479 HiLink perlTranslationSlash perlString
480 HiLink perlTranslationHash perlString
481 HiLink perlTranslationBracket perlString
482 HiLink perlTranslationCurly perlString
483 HiLink perlMatch perlString
484 HiLink perlMatchStartEnd perlStatement
485 HiLink perlFormatName perlIdentifier
486 HiLink perlFormatField perlString
487 HiLink perlPackageDecl perlType
488 HiLink perlStorageClass perlType
489 HiLink perlPackageRef perlType
490 HiLink perlStatementPackage perlStatement
491 HiLink perlStatementSub perlStatement
492 HiLink perlStatementStorage perlStatement
493 HiLink perlStatementControl perlStatement
494 HiLink perlStatementScalar perlStatement
495 HiLink perlStatementRegexp perlStatement
496 HiLink perlStatementNumeric perlStatement
497 HiLink perlStatementList perlStatement
498 HiLink perlStatementHash perlStatement
499 HiLink perlStatementIOfunc perlStatement
500 HiLink perlStatementFiledesc perlStatement
501 HiLink perlStatementVector perlStatement
502 HiLink perlStatementFiles perlStatement
503 HiLink perlStatementFlow perlStatement
504 HiLink perlStatementScope perlStatement
505 HiLink perlStatementInclude perlStatement
506 HiLink perlStatementProc perlStatement
507 HiLink perlStatementSocket perlStatement
508 HiLink perlStatementIPC perlStatement
509 HiLink perlStatementNetwork perlStatement
510 HiLink perlStatementPword perlStatement
511 HiLink perlStatementTime perlStatement
512 HiLink perlStatementMisc perlStatement
513 HiLink perlStatementNew perlStatement
514 HiLink perlFunctionName perlIdentifier
515 HiLink perlMethod perlIdentifier
516 HiLink perlFunctionPRef perlType
517 HiLink perlPOD perlComment
518 HiLink perlShellCommand perlString
519 HiLink perlSpecialAscii perlSpecial
520 HiLink perlSpecialDollar perlSpecial
521 HiLink perlSpecialString perlSpecial
522 HiLink perlSpecialStringU perlSpecial
523 HiLink perlSpecialMatch perlSpecial
524 HiLink perlSpecialBEOM perlSpecial
525 HiLink perlDATA perlComment
527 HiLink perlBrackets Error
530 HiLink perlNotEmptyLine Error
531 HiLink perlElseIfError Error
536 " Syncing to speed up processing
538 if !exists("perl_no_sync_on_sub")
539 syn sync match perlSync grouphere NONE "^\s*\<package\s"
540 syn sync match perlSync grouphere perlFunction "^\s*\<sub\s"
541 syn sync match perlSync grouphere NONE "^}"
544 if !exists("perl_no_sync_on_global_var")
545 syn sync match perlSync grouphere NONE "^$\I[[:alnum:]_:]+\s*=\s*{"
546 syn sync match perlSync grouphere NONE "^[@%]\I[[:alnum:]_:]+\s*=\s*("
549 if exists("perl_sync_dist")
550 execute "syn sync maxlines=" . perl_sync_dist
552 syn sync maxlines=100
555 syn sync match perlSyncPOD grouphere perlPOD "^=pod"
556 syn sync match perlSyncPOD grouphere perlPOD "^=head"
557 syn sync match perlSyncPOD grouphere perlPOD "^=item"
558 syn sync match perlSyncPOD grouphere NONE "^=cut"
560 let b:current_syntax = "perl"