Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Rexx |
| 3 | " Maintainer: Thomas Geulig <geulig@nentec.de> |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 4 | " Last Change: 2005 Dez 9, added some <http://www.ooRexx.org>-coloring, |
| 5 | " line comments, do *over*, messages, directives, |
| 6 | " highlighting classes, methods, routines and requires |
| 7 | " Rony G. Flatscher <rony.flatscher@wu-wien.ac.at> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8 | " |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 9 | " URL: http://www.geulig.de/vim/rexx.vim |
| 10 | " |
| 11 | " Special Thanks to Dan Sharp <dwsharp@hotmail.com> and Rony G. Flatscher |
| 12 | " <Rony.Flatscher@wu-wien.ac.at> for comments and additions |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 13 | |
| 14 | " For version 5.x: Clear all syntax items |
| 15 | " For version 6.x: Quit when a syntax file was already loaded |
| 16 | if version < 600 |
| 17 | syntax clear |
| 18 | elseif exists("b:current_syntax") |
| 19 | finish |
| 20 | endif |
| 21 | |
| 22 | syn case ignore |
| 23 | |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 24 | " add to valid identifier chars |
| 25 | setlocal iskeyword+=. |
| 26 | setlocal iskeyword+=! |
| 27 | setlocal iskeyword+=? |
| 28 | |
| 29 | " ---rgf, position important: must be before comments etc. ! |
| 30 | syn match rexxOperator "[-=|\/\\\+\*\[\],;<>&\~]" |
| 31 | |
| 32 | syn match rexxIdentifier "\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>" |
| 33 | syn match rexxEnvironmentSymbol "\<\.\+\([a-zA-Z0-9._?!]\)*\>" |
| 34 | |
| 35 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 36 | " A Keyword is the first symbol in a clause. A clause begins at the start |
| 37 | " of a line or after a semicolon. THEN, ELSE, OTHERWISE, and colons are always |
| 38 | " followed by an implied semicolon. |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 39 | syn match rexxClause "\(^\|;\|:\|then \|else \|otherwise \)\s*\w\+" contains=ALLBUT,rexxParse2,rexxRaise2 |
| 40 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 41 | |
| 42 | " Considered keywords when used together in a phrase and begin a clause |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 43 | syn match rexxParse "\<parse\s*\(\(upper\|lower\|caseless\)\s*\)\=\(arg\|linein\|pull\|source\|var\|\<value\>\|version\)\>" |
| 44 | syn match rexxParse2 "\<with\>" contained containedin=rexxParse |
| 45 | |
| 46 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 47 | syn match rexxKeyword contained "\<numeric \(digits\|form \(scientific\|engineering\|value\)\|fuzz\)\>" |
| 48 | syn match rexxKeyword contained "\<\(address\|trace\)\( value\)\=\>" |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 49 | syn match rexxKeyword contained "\<procedure\(\s*expose\)\=\>" |
| 50 | syn match rexxKeyword contained "\<do\>\(\s*forever\)\=\>" |
| 51 | syn match rexxKeyword contained "\<use\>\s*\<arg\>" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 52 | |
| 53 | " Another keyword phrase, separated to aid highlighting in rexxFunction |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 54 | syn match rexxKeyword contained "\<signal\(\s*\(on\|off\)\s*\(any\|error\|failure\|halt\|lostdigits\|nomethod\|nostring\|notready\|novalue\|syntax\|user\s*\k*\)\(\s\+name\)\=\)\=\>" |
| 55 | syn match rexxKeyword2 contained "\<call\(\s*\(on\|off\)\s*\(any\|error\|failure\|halt\|notready\|user\s*\k*\)\(\s\+name\)\=\)\=\>" |
| 56 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 57 | |
| 58 | " Considered keywords when they begin a clause |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 59 | syn match rexxKeyword contained "\<\(arg\|do\|drop\|end\|exit\|expose\|forward\|if\|interpret\|iterate\|leave\|nop\)\>" |
| 60 | syn match rexxKeyword contained "\<\(options\|pull\|push\|queue\|raise\|reply\|return\|say\|select\|trace\)\>" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 61 | |
| 62 | " Conditional phrases |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 63 | syn match rexxConditional "\(^\s*\| \)\(to\|by\|for\|until\|while\|then\|when\|otherwise\|else\|over\)\( \|\s*$\)" |
| 64 | syn match rexxConditional contained "\<\(to\|by\|for\|until\|while\|then\|when\|otherwise\|else\|over\)\>" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 65 | |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 66 | " must be after Conditional phrases! |
| 67 | syn match rexxKeyword ".*\<\(then\|else\)\s*\<do\>" |
| 68 | |
| 69 | " Raise statement |
| 70 | syn match rexxRaise "\(^\|;\|:\)\s\+\<raise\>\s*\<\(propagate\|error\|failure\|syntax\|user\)\>\=" |
| 71 | syn match rexxRaise2 "\<\(additional\|array\|description\|exit\|return\)\>" contained containedin=rexxRaise |
| 72 | |
| 73 | " Forward statement keywords |
| 74 | syn match rexxForward "\(^\|;\|:\)\<forward\>\s*" |
| 75 | syn match rexxForward2 "\<\(arguments\|array\|continue\|message\|class\|to\)\>" contained containedin=rexxForward |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 76 | |
| 77 | " Functions/Procedures |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 78 | syn match rexxFunction "\<\w*\(/\*\s*\*/\)*("me=e-1 contains=rexxComment,rexxConditional,rexxKeyword,rexxIdentifier |
| 79 | syn match rexxFunction "\<\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>("me=e-1 |
| 80 | syn match rexxFunction "\<call\s\+\k\+\>" contains=rexxKeyword2 |
| 81 | syn match rexxFunction "[()]" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 82 | |
| 83 | " String constants |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 84 | syn region rexxString start=+"+ skip=+""+ end=+"\(x\|b\)\=+ oneline |
| 85 | syn region rexxString start=+'+ skip=+''+ end=+'\(x\|b\)\=+ oneline |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 86 | |
| 87 | " Catch errors caused by wrong parenthesis |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 88 | syn region rexxParen transparent start='(' end=')' contains=ALLBUT,rexxParenError,rexxTodo,rexxLabel,rexxKeyword |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 89 | syn match rexxParenError ")" |
| 90 | syn match rexxInParen "[\\[\\]{}]" |
| 91 | |
| 92 | " Comments |
| 93 | syn region rexxComment start="/\*" end="\*/" contains=rexxTodo,rexxComment |
| 94 | syn match rexxCommentError "\*/" |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 95 | syn match rexxLineComment /--.*/ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 96 | |
| 97 | syn keyword rexxTodo contained TODO FIXME XXX |
| 98 | |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 99 | |
| 100 | " ooRexx messages |
| 101 | syn region rexxMessageOperator start="\(\~\|\~\~\)" end="\(\S\|\s\)"me=e-1 |
| 102 | syn match rexxMessage "\(\~\|\~\~\)\s*\<\.*[a-zA-Z]\([a-zA-Z0-9._?!]\)*\>" contains=rexxMessageOperator |
| 103 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 104 | " Highlight User Labels |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 105 | syn match rexxLabel "^\s*\k*\s*:"me=e-1 |
| 106 | |
| 107 | syn match rexxLineContinue ",\ze\s*\(--.*\|\/\*.*\)*$" |
| 108 | " the following is necessary, otherwise three consecutive dashes will cause it to highlight the first one |
| 109 | syn match rexxLineContinue "-\ze\(\s+--.*\|\s*\/\*.*\)*$" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 110 | |
| 111 | " Special Variables |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 112 | syn keyword rexxSpecialVariable sigl rc result self super |
| 113 | |
| 114 | " Constants |
| 115 | syn keyword rexxConst .true .false .nil |
| 116 | |
| 117 | " ooRexx builtin classes, first define dot to be o.k. in keywords |
| 118 | syn keyword rexxBuiltinClass .object .class .method .message |
| 119 | syn keyword rexxBuiltinClass .monitor .alarm |
| 120 | syn keyword rexxBuiltinClass .stem .stream .string |
| 121 | syn keyword rexxBuiltinClass .mutablebuffer |
| 122 | syn keyword rexxBuiltinClass .array .list .queue .directory .table .set |
| 123 | syn keyword rexxBuiltinClass .relation .bag .supplier .regularExpressions |
| 124 | |
| 125 | " Windows-only classes |
| 126 | syn keyword rexxBuiltinClass .OLEObject .MenuObject .WindowsClipboard .WindowsEventLog |
| 127 | syn keyword rexxBuiltinClass .WindowsManager .WindowObject .WindowsProgramManager |
| 128 | |
| 129 | |
| 130 | " ooRexx directives, ---rgf location important, otherwise directives in top of |
| 131 | " file not matched! |
| 132 | syn region rexxClass start="::\s*class\s*"ms=e+1 end="\ze\(\s\|;\|$\)" |
| 133 | syn region rexxMethod start="::\s*method\s*"ms=e+1 end="\ze\(\s\|;\|$\)" |
| 134 | syn region rexxRequires start="::\s*requires\s*"ms=e+1 end="\ze\(\s\|;\|$\)" |
| 135 | syn region rexxRoutine start="::\s*routine\s*"ms=e+1 end="\ze\(\s\|;\|$\)" |
| 136 | |
| 137 | syn region rexxDirective start="\(^\|;\)\s*::\s*\w\+" end="\($\|;\)" contains=rexxString,rexxComment,rexxLineComment,rexxClass,rexxMethod,rexxRoutine,rexxRequires keepend |
| 138 | |
| 139 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 140 | |
| 141 | if !exists("rexx_minlines") |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 142 | " let rexx_minlines = 10 |
| 143 | let rexx_minlines = 500 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 144 | endif |
| 145 | exec "syn sync ccomment rexxComment minlines=" . rexx_minlines |
| 146 | |
| 147 | " Define the default highlighting. |
| 148 | " For version 5.7 and earlier: only when not done already |
| 149 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 150 | if version >= 508 || !exists("did_rexx_syn_inits") |
| 151 | if version < 508 |
| 152 | let did_rexx_syn_inits = 1 |
| 153 | command -nargs=+ HiLink hi link <args> |
| 154 | else |
| 155 | command -nargs=+ HiLink hi def link <args> |
| 156 | endif |
| 157 | |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 158 | HiLink rexxLabel Function |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 159 | HiLink rexxCharacter Character |
| 160 | HiLink rexxParenError rexxError |
| 161 | HiLink rexxInParen rexxError |
| 162 | HiLink rexxCommentError rexxError |
| 163 | HiLink rexxError Error |
| 164 | HiLink rexxKeyword Statement |
| 165 | HiLink rexxKeyword2 rexxKeyword |
| 166 | HiLink rexxFunction Function |
| 167 | HiLink rexxString String |
| 168 | HiLink rexxComment Comment |
| 169 | HiLink rexxTodo Todo |
| 170 | HiLink rexxSpecialVariable Special |
| 171 | HiLink rexxConditional rexxKeyword |
| 172 | |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 173 | HiLink rexxOperator Operator |
| 174 | HiLink rexxMessageOperator rexxOperator |
| 175 | HiLink rexxLineComment RexxComment |
| 176 | |
| 177 | HiLink rexxLineContinue WildMenu |
| 178 | |
| 179 | HiLink rexxDirective rexxKeyword |
| 180 | HiLink rexxClass Type |
| 181 | HiLink rexxMethod rexxFunction |
| 182 | HiLink rexxRequires Include |
| 183 | HiLink rexxRoutine rexxFunction |
| 184 | |
| 185 | HiLink rexxConst Constant |
| 186 | HiLink rexxTypeSpecifier Type |
| 187 | HiLink rexxBuiltinClass rexxTypeSpecifier |
| 188 | |
| 189 | HiLink rexxEnvironmentSymbol rexxConst |
| 190 | HiLink rexxMessage rexxFunction |
| 191 | |
| 192 | HiLink rexxParse rexxKeyword |
| 193 | HiLink rexxParse2 rexxParse |
| 194 | |
| 195 | HiLink rexxRaise rexxKeyword |
| 196 | HiLink rexxRaise2 rexxRaise |
| 197 | |
| 198 | HiLink rexxForward rexxKeyword |
| 199 | HiLink rexxForward2 rexxForward |
| 200 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 201 | delcommand HiLink |
| 202 | endif |
| 203 | |
| 204 | let b:current_syntax = "rexx" |
| 205 | |
| 206 | "vim: ts=8 |