diff options
Diffstat (limited to 'runtime/syntax/perl.vim')
-rw-r--r-- | runtime/syntax/perl.vim | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/runtime/syntax/perl.vim b/runtime/syntax/perl.vim index 8cd40b493a..ff566e1687 100644 --- a/runtime/syntax/perl.vim +++ b/runtime/syntax/perl.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Perl " Maintainer: Nick Hibma <n_hibma@van-laarhoven.org> -" Last Change: 2005 Oct 06 +" Last Change: 2005 October 18 " Location: http://www.van-laarhoven.org/vim/syntax/perl.vim " " Please download most recent version first before mailing @@ -47,18 +47,18 @@ if exists("perl_include_pod") syn include @Pod syntax/pod.vim unlet b:current_syntax if exists("perl_fold") - syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,perlTodo keepend fold + syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend fold syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend fold else - syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,perlTodo keepend + syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,@Spell,perlTodo keepend syn region perlPOD start="^=cut" end="^=cut" contains=perlTodo keepend endif else " Use only the bare minimum of rules if exists("perl_fold") - syn region perlPOD start="^=[a-z]" end="^=cut" fold + syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Spell fold else - syn region perlPOD start="^=[a-z]" end="^=cut" + syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Spell endif endif @@ -87,8 +87,8 @@ else endif syn keyword perlOperator defined undef and or not bless ref if exists("perl_fold") - " if BEGIN/END would be a keyword the perlBEGINENDFold does not work - syn match perlControl "\<BEGIN\|CHECK\|INIT\|END\>" contained + " if BEGIN/END is a keyword the perlBEGINENDFold does not work + syn match perlControl "\<BEGIN\|END\|CHECK\|INIT\>" contained else syn keyword perlControl BEGIN END CHECK INIT endif @@ -108,8 +108,8 @@ syn keyword perlStatementFiles chdir chmod chown chroot glob link mkdir readlin syn match perlStatementFiles "-[rwxoRWXOezsfdlpSbctugkTBMAC]\>" syn keyword perlStatementFlow caller die dump eval exit wantarray syn keyword perlStatementInclude require -syn match perlStatementInclude "\(use\|no\)\s\+\(integer\>\|strict\>\|lib\>\|sigtrap\>\|subs\>\|vars\>\|warnings\>\|utf8\>\|byte\>\)\=" -syn keyword perlStatementScope import +syn match perlStatementInclude "\<\(use\|no\)\s\+\(\(attributes\|autouse\|base\|big\(int\|num\|rat\)\|blib\|bytes\|charnames\|constant\|diagnostics\|encoding\|fields\|filetest\|if\|integer\|less\|lib\|locale\|open\|ops\|overload\|re\|sigtrap\|sort\|strict\|subs\|threads\(::shared\)\=\|utf8\|vars\|vmsish\|warnings\(::register\)\=\)\>\)\=" + syn keyword perlStatementProc alarm exec fork getpgrp getppid getpriority kill pipe 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 @@ -118,8 +118,11 @@ syn keyword perlStatementPword getpwuid getpwnam getpwent setpwent endpwent get syn keyword perlStatementTime gmtime localtime time times syn keyword perlStatementMisc warn formline reset scalar delete prototype lock -syn keyword perlStatementNew new - +if !exists("perl_no_semi_keywords") + syn keyword perlStatementScope import + syn keyword perlStatementNew new + syn keyword perlStatementCarp carp confess croak +endif syn keyword perlTodo TODO TBD FIXME XXX contained " Perl Identifiers. @@ -134,14 +137,16 @@ syn keyword perlTodo TODO TBD FIXME XXX contained " Special variables first ($^A, ...) and ($|, $', ...) syn match perlVarPlain "$^[ADEFHILMOPSTWX]\=" -syn match perlVarPlain "$[\\\"\[\]'&`+*.,;=%~!?@$<>(-]" -syn match perlVarPlain "$\(0\|[1-9][0-9]*\)" +syn match perlVarPlain "$[\\\"\[\]'&`+*.,;=%~?@$<>(-]" +syn match perlVarPlain "$\(0\|[1-9]\d*\)" " Same as above, but avoids confusion in $::foo (equivalent to $main::foo) syn match perlVarPlain "$:[^:]" " These variables are not recognized within matches. syn match perlVarNotInMatches "$[|)]" -" This variable is not recognized within matches delimited by m//. +" This variable is not recognized within matches delimited by '/'. syn match perlVarSlash "$/" +" This variable is not recognized within matches delimited by '!'. +syn match perlVarBang "$!" " And plain identifiers syn match perlPackageRef "\(\h\w*\)\=\(::\|'\)\I"me=e-1 contained @@ -159,7 +164,7 @@ else endif if !exists("perl_no_extended_vars") - syn cluster perlExpr contains=perlStatementScalar,perlStatementRegexp,perlStatementNumeric,perlStatementList,perlStatementHash,perlStatementFiles,perlStatementTime,perlStatementMisc,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBlock,perlShellCommand,perlFloat,perlNumber,perlStringUnexpanded,perlString,perlQQ + syn cluster perlExpr contains=perlStatementScalar,perlStatementRegexp,perlStatementNumeric,perlStatementList,perlStatementHash,perlStatementFiles,perlStatementTime,perlStatementMisc,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBang,perlVarBlock,perlShellCommand,perlFloat,perlNumber,perlStringUnexpanded,perlString,perlQQ syn region perlVarBlock matchgroup=perlVarPlain start="\($#\|[@%$]\)\$*{" skip="\\}" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember syn region perlVarBlock matchgroup=perlVarPlain start="&\$*{" skip="\\}" end="}" contains=@perlExpr syn match perlVarPlain "\\\=\(\$#\|[@%&$]\)\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember @@ -174,17 +179,18 @@ endif syn match perlFiledescRead "[<]\h\w\+[>]" syn match perlFiledescStatementComma "(\=\s*\u\w*\s*,"me=e-1 transparent contained contains=perlFiledescStatement -syn match perlFiledescStatementNocomma "(\=\s*\u\w*\s*[^, \t]"me=e-1 transparent contained contains=perlFiledescStatement +syn match perlFiledescStatementNocomma "(\=\s*\u\w*\s*[^,[:space:]]"me=e-1 transparent contained contains=perlFiledescStatement syn match perlFiledescStatement "\u\w*" contained " Special characters in strings and matches syn match perlSpecialString "\\\(\d\+\|[xX]\x\+\|c\u\|.\)" contained syn match perlSpecialStringU "\\['\\]" contained -syn match perlSpecialMatch "{\d\+\(,\(\d\+\)\=\)\=}" contained +syn match perlSpecialMatch "{\d\+\(,\d*\)\=}" contained syn match perlSpecialMatch "\[\(\]\|-\)\=[^\[\]]*\(\[\|\-\)\=\]" contained syn match perlSpecialMatch "[+*()?.]" contained syn match perlSpecialMatch "(?[#:=!]" contained +syn match perlSpecialMatch "(?<[=!]" contained syn match perlSpecialMatch "(?[imsx]\+)" contained " FIXME the line below does not work. It should mark end of line and " begin of line as perlSpecial. @@ -201,13 +207,13 @@ syn match perlNotEmptyLine "^\s\+$" contained " Variable interpolation " " These items are interpolated inside "" strings and similar constructs. -syn cluster perlInterpDQ contains=perlSpecialString,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBlock +syn cluster perlInterpDQ contains=perlSpecialString,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBang,perlVarBlock " These items are interpolated inside '' strings and similar constructs. syn cluster perlInterpSQ contains=perlSpecialStringU " These items are interpolated inside m// matches and s/// substitutions. syn cluster perlInterpSlash contains=perlSpecialString,perlSpecialMatch,perlVarPlain,perlVarBlock,perlSpecialBEOM " These items are interpolated inside m## matches and s### substitutions. -syn cluster perlInterpMatch contains=@perlInterpSlash,perlVarSlash +syn cluster perlInterpMatch contains=@perlInterpSlash,perlVarSlash,perlVarBang " Shell commands syn region perlShellCommand matchgroup=perlMatchStartEnd start="`" end="`" contains=@perlInterpDQ @@ -233,8 +239,7 @@ syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]!+ end=+![cgimosx]* " Below some hacks to recognise the // variant. This is virtually impossible to catch in all " cases as the / is used in so many other ways, but these should be the most obvious ones. -"syn region perlMatch matchgroup=perlMatchStartEnd start=+^split /+lc=5 start=+[^$@%]\<split /+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 -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 +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/[^=[:space:][:digit:]$@%&]+lc=1,me=e-1,rs=e-1 start=+^/+ skip=+\\/+ end=+/[cgimosx]*+ contains=@perlInterpSlash " Substitutions @@ -253,7 +258,7 @@ syn region perlSubstitutionHash matchgroup=perlMatchStartEnd start=+#+ end=+#[ syn region perlSubstitutionBracket matchgroup=perlMatchStartEnd start=+\[+ end=+\][ecgimosx]*+ contained contains=@perlInterpDQ syn region perlSubstitutionCurly matchgroup=perlMatchStartEnd start=+{+ end=+}[ecgimosx]*+ contained contains=@perlInterpDQ -" A special case for m!!x which allows for comments and extra whitespace in the pattern +" A special case for s!!!x which allows for comments and extra whitespace in the pattern syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s!+ end=+!+me=e-1 contains=@perlInterpSlash,perlComment nextgroup=perlSubstitutionPling syn region perlSubstitutionPling matchgroup=perlMatchStartEnd start=+!+ end=+![ecgimosx]*+ contained contains=@perlInterpDQ @@ -280,24 +285,24 @@ syn match perlString "\<\I\i*\s*=>"me=e-2 " Strings and q, qq, qw and qr expressions -" Brackets in qq() -syn region perlBrackets start=+(+ end=+)+ contained transparent contains=perlBrackets,@perlStringSQ +" Parentheses in qq() +syn region perlParens start=+(+ end=+)+ contained transparent contains=perlParens,@perlStringSQ -syn region perlStringUnexpanded matchgroup=perlStringStartEnd start="'" end="'" contains=@perlInterpSQ -syn region perlString matchgroup=perlStringStartEnd start=+"+ end=+"+ contains=@perlInterpDQ +syn region perlStringUnexpanded matchgroup=perlStringStartEnd start="'" end="'" contains=@Spell,@perlInterpSQ +syn region perlString matchgroup=perlStringStartEnd start=+"+ end=+"+ contains=@Spell,@perlInterpDQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<q#+ end=+#+ contains=@perlInterpSQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<q|+ end=+|+ contains=@perlInterpSQ -syn region perlQQ matchgroup=perlStringStartEnd start=+\<q(+ end=+)+ contains=@perlInterpSQ,perlBrackets +syn region perlQQ matchgroup=perlStringStartEnd start=+\<q(+ end=+)+ contains=@perlInterpSQ,perlParens syn region perlQQ matchgroup=perlStringStartEnd start=+\<q{+ end=+}+ contains=@perlInterpSQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<q/+ end=+/+ contains=@perlInterpSQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]#+ end=+#+ contains=@perlInterpDQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]|+ end=+|+ contains=@perlInterpDQ -syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx](+ end=+)+ contains=@perlInterpDQ,perlBrackets +syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx](+ end=+)+ contains=@perlInterpDQ,perlParens syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]{+ end=+}+ contains=@perlInterpDQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]/+ end=+/+ contains=@perlInterpDQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw#+ end=+#+ contains=@perlInterpSQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw|+ end=+|+ contains=@perlInterpSQ -syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw(+ end=+)+ contains=@perlInterpSQ,perlBrackets +syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw(+ end=+)+ contains=@perlInterpSQ,perlParens syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw{+ end=+}+ contains=@perlInterpSQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw/+ end=+/+ contains=@perlInterpSQ syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr#+ end=+#[imosx]*+ contains=@perlInterpMatch @@ -362,7 +367,7 @@ endif " All other # are comments, except ^#! -syn match perlComment "#.*" contains=perlTodo +syn match perlComment "#.*" contains=@Spell,perlTodo syn match perlSharpBang "^#!.*" " Formats @@ -391,8 +396,8 @@ if exists("perl_fold") syn region perlBEGINENDFold start="^\z(\s*\)\<\(BEGIN\|END\|CHECK\|INIT\)\>.*[^};]$" end="^\z1}\s*$" transparent fold keepend if exists("perl_fold_blocks") - syn region perlIfFold start="^\z(\s*\)\(if\|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 - syn region perlIfFold start="^\z(\s*\)do\s*{\s*$" end="^\z1}\s*while" end="^\z1}\s*;\=$" transparent fold keepend + syn region perlIfFold start="^\z(\s*\)\(if\|unless\|for\|while\|until\)\s*(.*)\(\s*{\)\=\s*$" start="^\z(\s*\)foreach\s*\(\(my\|our\)\=\s*\S\+\s*\)\=(.*)\(\s*{\)\=\s*$" start="\z(\s*\)else\s*{\s*$" end="^\z1}\s*;\=$" transparent fold keepend + syn region perlIfFold start="^\z(\s*\)do\(\s*{\)\=\s*$" end="^\z1}\s*while" end="^\z1}\s*;\=$" transparent fold keepend endif setlocal foldmethod=syntax @@ -445,6 +450,7 @@ if version >= 508 || !exists("did_perl_syn_inits") HiLink perlVarSimpleMemberName perlString HiLink perlVarNotInMatches perlIdentifier HiLink perlVarSlash perlIdentifier + HiLink perlVarBang perlIdentifier HiLink perlQQ perlString if version >= 600 HiLink perlHereDoc perlString @@ -454,7 +460,7 @@ if version >= 508 || !exists("did_perl_syn_inits") HiLink perlUntilEOFSQ perlString HiLink perlUntilEmptyDQ perlString HiLink perlUntilEmptySQ perlString - HiLink perlUntilEOF perlString + HiLink perlUntilEOF perlString endif HiLink perlStringUnexpanded perlString HiLink perlSubstitutionSQ perlString @@ -490,7 +496,7 @@ if version >= 508 || !exists("did_perl_syn_inits") HiLink perlStatementFiles perlStatement HiLink perlStatementFlow perlStatement HiLink perlStatementScope perlStatement - HiLink perlStatementInclude perlStatement + HiLink perlStatementInclude perlInclude HiLink perlStatementProc perlStatement HiLink perlStatementSocket perlStatement HiLink perlStatementIPC perlStatement @@ -511,9 +517,9 @@ if version >= 508 || !exists("did_perl_syn_inits") HiLink perlSpecialMatch perlSpecial HiLink perlSpecialBEOM perlSpecial HiLink perlDATA perlComment - - HiLink perlBrackets Error - + + HiLink perlParens Error + " Possible errors HiLink perlNotEmptyLine Error HiLink perlElseIfError Error |