home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / runtime / syntax / rexx.vim < prev    next >
Encoding:
Text File  |  2010-08-15  |  13.7 KB  |  299 lines

  1. " Vim syntax file
  2. " Language:    Rexx
  3. " Maintainer:    Thomas Geulig <geulig@nentec.de>
  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. "               2007 Oct 17, added support for new ooRexx 3.2 features
  8. "               Rony G. Flatscher <rony.flatscher@wu-wien.ac.at>
  9. "
  10. " URL:        http://www.geulig.de/vim/rexx.vim
  11. "
  12. " Special Thanks to Dan Sharp <dwsharp@hotmail.com> and Rony G. Flatscher
  13. " <Rony.Flatscher@wu-wien.ac.at> for comments and additions
  14.  
  15. " For version 5.x: Clear all syntax items
  16. " For version 6.x: Quit when a syntax file was already loaded
  17. if version < 600
  18.   syntax clear
  19. elseif exists("b:current_syntax")
  20.   finish
  21. endif
  22.  
  23. syn case ignore
  24.  
  25. " add to valid identifier chars
  26. setlocal iskeyword+=.
  27. setlocal iskeyword+=!
  28. setlocal iskeyword+=?
  29.  
  30. " ---rgf, position important: must be before comments etc. !
  31. syn match rexxOperator "[=|\/\\\+\*\[\],;:<>&\~%\-]"
  32.  
  33. " rgf syn match rexxIdentifier        "\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>"
  34. syn match rexxIdentifier        "\<\K\k*\>"
  35. syn match rexxEnvironmentSymbol "\<\.\k\+\>"
  36.  
  37. " A Keyword is the first symbol in a clause.  A clause begins at the start
  38. " of a line or after a semicolon.  THEN, ELSE, OTHERWISE, and colons are always
  39. " followed by an implied semicolon.
  40. syn match rexxClause "\(^\|;\|:\|then \|else \|when \|otherwise \)\s*\S*" contains=ALLBUT,rexxParse2,rexxRaise2,rexxForward2
  41.  
  42. " Considered keywords when used together in a phrase and begin a clause
  43. syn match rexxParse "\<parse\s*\(\(upper\|lower\|caseless\)\s*\)\?\(arg\|linein\|pull\|source\|var\|\<value\>\|version\)\>" containedin=rexxClause contains=rexxParse2
  44. syn match rexxParse2 "\<with\>" containedin=rexxParse
  45.  
  46. syn match rexxKeyword contained "\<numeric \(digits\|form \(scientific\|engineering\|value\)\|fuzz\)\>"
  47. syn match rexxKeyword contained "\<\(address\|trace\)\( value\)\?\>"
  48. syn match rexxKeyword contained "\<procedure\(\s*expose\)\?\>"
  49.  
  50. syn match rexxKeyword contained "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\(\s\+forever\)\?\>"
  51. syn match rexxKeyword contained "\<use\>\s*\(strict\s*\)\?\<arg\>"
  52.  
  53. " Another keyword phrase, separated to aid highlighting in rexxFunction
  54. syn match rexxRegularCallSignal contained "\<\(call\|signal\)\s\(\s*on\>\|\s*off\>\)\@!\(\k\+\ze\|\ze(\)\(\s*\|;\|$\|(\)"
  55. syn region rexxLabel contained start="\<\(call\|signal\)\>\s*\zs\(\k*\|(\)" end="\ze\(\s*\|;\|$\|(\)" containedin=rexxRegularCallSignal
  56.  
  57. syn match rexxExceptionHandling contained "\<\(call\|signal\)\>\s\+\<\(on\|off\)\>.*\(;\|$\)"
  58.  
  59. " hilite label given after keyword "name"
  60. syn match rexxLabel "name\s\+\zs\k\+\ze" containedin=rexxExceptionHandling
  61. " hilite condition name (serves as label)
  62. syn match rexxLabel "\<\(call\|signal\)\>\s\+\<\(on\|off\)\>\s*\zs\k\+\ze\s*\(;\|$\)" containedin=rexxExceptionHandling
  63. " user exception handling, hilite user defined name
  64. syn region rexxLabel contained start="user\s\+\zs\k" end="\ze\(\s\|;\|$\)" containedin=rexxExceptionHandling
  65.  
  66. " Considered keywords when they begin a clause
  67. syn match rexxKeywordStatements "\<\(arg\|catch\|do\|drop\|end\|exit\|expose\|finally\|forward\|if\|interpret\|iterate\|leave\|loop\|nop\)\>"
  68. syn match rexxKeywordStatements "\<\(options\|pull\|push\|queue\|raise\|reply\|return\|say\|select\|trace\)\>"
  69.  
  70. " Conditional keywords starting a new statement
  71. syn match rexxConditional "\<\(then\|else\|when\|otherwise\)\(\s*\|;\|\_$\|\)\>" contains=rexxKeywordStatements
  72.  
  73. " Conditional phrases
  74. syn match rexxLoopKeywords "\<\(to\|by\|for\|until\|while\|over\)\>" containedin=doLoopSelectLabelRegion
  75.  
  76. " must be after Conditional phrases!
  77. syn match doLoopSelectLabelRegion "\<\(do\|loop\|select\)\>\s\+\(label\s\+\)\?\(\s\+\k\+\s\+\zs\<over\>\)\?\k*\(\s\+forever\)\?\(\s\|;\|$\)" 
  78.  
  79. " color label's name
  80. syn match rexxLabel2 "\<\(do\|loop\|select\)\>\s\+label\s\+\zs\k*\ze" containedin=doLoopSelectLabelRegion
  81.  
  82. " make sure control variable is normal
  83. syn match rexxControlVariable        "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\s\+\zs.*\ze\s\+\<over\>" containedin=doLoopSelectLabelRegion
  84.  
  85. " make sure control variable assignment is normal
  86. syn match rexxStartValueAssignment       "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\s\+\zs.*\ze\(=.*\)\?\s\+\<to\>" containedin=doLoopSelectLabelRegion
  87.  
  88. " highlight label name
  89. syn match endIterateLeaveLabelRegion "\<\(end\|leave\|iterate\)\>\(\s\+\K\k*\)" contains=rexxLabel2
  90. syn match rexxLabel2 "\<\(end\|leave\|iterate\)\>\s\+\zs\k*\ze" containedin=endIterateLeaveLabelRegion
  91.  
  92. " Guard statement
  93. syn match rexxGuard "\(^\|;\|:\)\s*\<guard\>\s\+\<\(on\|off\)\>"
  94.  
  95. " Trace statement
  96. syn match rexxTrace "\(^\|;\|:\)\s*\<trace\>\s\+\<\K\k*\>"
  97.  
  98. " Raise statement
  99. syn match rexxRaise "\(^\|;\|:\)\s\+\<raise\>\s*\<\(propagate\|error\|failure\|syntax\|user\)\>\?" contains=rexxRaise2
  100. syn match rexxRaise2 "\<\(additional\|array\|description\|exit\|propagate\|return\)\>" containedin=rexxRaise
  101.  
  102. " Forward statement
  103. syn match rexxForward  "\(^\|;\|:\)\<forward\>\s*" contains=rexxForward2
  104. syn match rexxForward2 "\<\(arguments\|array\|continue\|message\|class\|to\)\>" contained
  105.  
  106. " Functions/Procedures
  107. syn match rexxFunction     "\<\<[a-zA-Z\!\?_]\k*\>("me=e-1
  108. syn match rexxFunction "[()]"
  109.  
  110. " String constants
  111. syn region rexxString    start=+"+ skip=+""+ end=+"\(x\|b\)\?+ oneline
  112. syn region rexxString    start=+'+ skip=+''+ end=+'\(x\|b\)\?+ oneline
  113.  
  114. syn region rexxParen transparent start='(' end=')' contains=ALLBUT,rexxParenError,rexxTodo,rexxLabel,rexxKeyword
  115. " Catch errors caused by wrong parenthesis
  116. syn match rexxParenError     ")"
  117. syn match rexxInParen        "[\\[\\]{}]"
  118.  
  119. " Comments
  120. syn region    rexxComment    start="/\*"    end="\*/" contains=rexxTodo,rexxComment
  121. syn match    rexxCommentError "\*/"
  122. syn region    rexxLineComment    start="--"    end="\_$" oneline
  123.  
  124. " Highlight User Labels
  125. " check for labels between comments, labels stated in a statement in the middle of a line
  126. syn match rexxLabel         "\(\_^\|;\)\s*\(\/\*.*\*\/\)*\s*\k\+\s*\(\/\*.*\*\/\)*\s*:"me=e-1 contains=rexxTodo,rexxComment
  127.  
  128. syn keyword rexxTodo contained    TODO FIXME XXX
  129.  
  130. " ooRexx messages
  131. syn region rexxMessageOperator start="\(\~\|\~\~\)" end="\(\S\|\s\)"me=e-1
  132. syn match rexxMessage "\(\~\|\~\~\)\s*\<\.*[a-zA-Z]\([a-zA-Z0-9._?!]\)*\>" contains=rexxMessageOperator
  133.  
  134. " line continuations, take care of (line-)comments after it
  135. syn match rexxLineContinue ",\ze\s*\(--.*\|\/\*.*\)*$"
  136.  
  137. " the following is necessary, otherwise three consecutive dashes will cause it to highlight the first one
  138. syn match rexxLineContinue "-\ze-\@!\s*\(--.*\|\s*\/\*.*\)\?$"
  139.  
  140. " Special Variables
  141. syn keyword rexxSpecialVariable  sigl rc result self super
  142. syn keyword rexxSpecialVariable  .environment .error .input .local .methods .output .rs .stderr .stdin .stdout .stdque
  143.  
  144. " Constants
  145. syn keyword rexxConst .true .false .nil .endOfLine .line
  146.  
  147. syn match rexxNumber "\(-\|+\)\?\s*\zs\<\(\d\+\.\?\|\d*\.\d\+\(E\(+\|-\)\d\{2,2}\)\?\)\?\>"
  148.  
  149. " ooRexx builtin classes (as of version 3.2.0, fall 2007), first define dot to be o.k. in keywords
  150. syn keyword rexxBuiltinClass .Alarm .ArgUtil .Array .Bag .CaselessColumnComparator
  151. syn keyword rexxBuiltinClass .CaselessComparator .CaselessDescendingComparator .CircularQueue
  152. syn keyword rexxBuiltinClass .Class .Collection .ColumnComparator .Comparable .Comparator
  153. syn keyword rexxBuiltinClass .DateTime .DescendingComparator .Directory .InputOutputStream
  154. syn keyword rexxBuiltinClass .InputStream .InvertingComparator .List .MapCollection
  155. syn keyword rexxBuiltinClass .Message .Method .Monitor .MutableBuffer .Object
  156. syn keyword rexxBuiltinClass .OrderedCollection .OutputStream .Properties .Queue
  157. syn keyword rexxBuiltinClass .Relation .RexxQueue .Set .SetCollection .Stem .Stream
  158. syn keyword rexxBuiltinClass .StreamSupplier .String .Supplier .Table .TimeSpan
  159.  
  160. " Windows-only classes
  161. syn keyword rexxBuiltinClass .AdvancedControls .AnimatedButton .BaseDialog .ButtonControl
  162. syn keyword rexxBuiltinClass .CategoryDialog .CheckBox .CheckList .ComboBox .DialogControl
  163. syn keyword rexxBuiltinClass .DialogExtensions .DlgArea .DlgAreaU .DynamicDialog
  164. syn keyword rexxBuiltinClass .EditControl .InputBox .IntegerBox .ListBox .ListChoice
  165. syn keyword rexxBuiltinClass .ListControl .MenuObject .MessageExtensions .MultiInputBox
  166. syn keyword rexxBuiltinClass .MultiListChoice .PasswordBox .PlainBaseDialog .PlainUserDialog
  167. syn keyword rexxBuiltinClass .ProgressBar .ProgressIndicator .PropertySheet .RadioButton
  168. syn keyword rexxBuiltinClass .RcDialog .ResDialog .ScrollBar .SingleSelection .SliderControl
  169. syn keyword rexxBuiltinClass .StateIndicator .StaticControl .TabControl .TimedMessage
  170. syn keyword rexxBuiltinClass .TreeControl .UserDialog .VirtualKeyCodes .WindowBase
  171. syn keyword rexxBuiltinClass .WindowExtensions .WindowObject .WindowsClassesBase .WindowsClipboard
  172. syn keyword rexxBuiltinClass .WindowsEventLog .WindowsManager .WindowsProgramManager .WindowsRegistry
  173.  
  174. " ooRexx directives, ---rgf location important, otherwise directives in top of file not matched!
  175. syn region rexxClassDirective     start="::\s*class\s*"ms=e+1    end="\ze\(\s\|;\|$\)"
  176. syn region rexxMethodDirective    start="::\s*method\s*"ms=e+1   end="\ze\(\s\|;\|$\)"
  177. syn region rexxRequiresDirective  start="::\s*requires\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
  178. syn region rexxRoutineDirective   start="::\s*routine\s*"ms=e+1  end="\ze\(\s\|;\|$\)"
  179. syn region rexxAttributeDirective start="::\s*attribute\s*"ms=e+1  end="\ze\(\s\|;\|$\)"
  180.  
  181. syn region rexxDirective start="\(^\|;\)\s*::\s*\w\+"  end="\($\|;\)" contains=rexxString,rexxComment,rexxLineComment,rexxClassDirective,rexxMethodDirective,rexxRoutineDirective,rexxRequiresDirective,rexxAttributeDirective keepend
  182.  
  183. syn region rexxVariable start="\zs\<\(\.\)\@!\K\k\+\>\ze\s*\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)" end="\(\_$\|.\)"me=e-1
  184. syn match rexxVariable "\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)\s*\zs\K\k*\ze" 
  185.  
  186. " rgf, 2007-07-22: unfortunately, the entire region is colored (not only the
  187. " patterns), hence useless (vim 7.0)! (syntax-docs hint that that should work)
  188. " attempt: just colorize the parenthesis in matching colors, keep content
  189. "          transparent to keep the formatting already done to it!
  190. " syn region par1 matchgroup=par1 start="(" matchgroup=par1 end=")" transparent contains=par2
  191. " syn region par2 matchgroup=par2 start="(" matchgroup=par2 end=")" transparent contains=par3 contained
  192. " syn region par3 matchgroup=par3 start="(" matchgroup=par3 end=")" transparent contains=par4 contained
  193. " syn region par4 matchgroup=par4 start="(" matchgroup=par4 end=")" transparent contains=par5 contained
  194. " syn region par5 matchgroup=par5 start="(" matchgroup=par5 end=")" transparent contains=par1 contained
  195.  
  196. " this will colorize the entire region, removing any colorizing already done!
  197. " syn region par1 matchgroup=par1 start="(" end=")" contains=par2
  198. " syn region par2 matchgroup=par2 start="(" end=")" contains=par3 contained
  199. " syn region par3 matchgroup=par3 start="(" end=")" contains=par4 contained
  200. " syn region par4 matchgroup=par4 start="(" end=")" contains=par5 contained
  201. " syn region par5 matchgroup=par5 start="(" end=")" contains=par1 contained
  202.  
  203. hi par1 ctermfg=red         guifg=red
  204. hi par2 ctermfg=blue         guifg=blue
  205. hi par3 ctermfg=darkgreen     guifg=darkgreen
  206. hi par4 ctermfg=darkyellow    guifg=darkyellow
  207. hi par5 ctermfg=darkgrey     guifg=darkgrey
  208.  
  209. " line continuation (trailing comma or single dash)
  210. syn sync linecont "\(,\|-\ze-\@!\)\ze\s*\(--.*\|\/\*.*\)*$"
  211.  
  212. " if !exists("rexx_minlines")
  213. "   let rexx_minlines = 500
  214. " endif
  215. " exec "syn sync ccomment rexxComment minlines=" . rexx_minlines
  216.  
  217. " always scan from start, PCs are powerful enough for that in 2007 !
  218. exec "syn sync fromstart"
  219.  
  220. " Define the default highlighting.
  221. " For version 5.7 and earlier: only when not done already
  222. " For version 5.8 and later: only when an item doesn't have highlighting yet
  223. if version >= 508 || !exists("did_rexx_syn_inits")
  224.   if version < 508
  225.     let did_rexx_syn_inits = 1
  226.     command -nargs=+ HiLink hi link <args>
  227.   else
  228.     command -nargs=+ HiLink hi def link <args>
  229.   endif
  230.  
  231.   " make binary and hex strings stand out
  232.   hi rexxStringConstant term=bold,underline ctermfg=5 cterm=bold guifg=darkMagenta gui=bold
  233.  
  234.   HiLink rexxLabel2        Function
  235.   HiLink doLoopSelectLabelRegion    rexxKeyword
  236.   HiLink endIterateLeaveLabelRegion    rexxKeyword
  237.   HiLink rexxLoopKeywords    rexxKeyword " Todo
  238.  
  239.   HiLink rexxNumber        Normal    
  240. "  HiLink rexxIdentifier        DiffChange
  241.  
  242.   HiLink rexxRegularCallSignal    Statement
  243.   HiLink rexxExceptionHandling    Statement
  244.  
  245.   HiLink rexxLabel        Function
  246.   HiLink rexxCharacter        Character
  247.   HiLink rexxParenError        rexxError
  248.   HiLink rexxInParen        rexxError
  249.   HiLink rexxCommentError    rexxError
  250.   HiLink rexxError        Error
  251.   HiLink rexxKeyword        Statement
  252.   HiLink rexxKeywordStatements    Statement  
  253.  
  254.   HiLink rexxFunction        Function
  255.   HiLink rexxString        String
  256.   HiLink rexxComment        Comment
  257.   HiLink rexxTodo        Todo
  258.   HiLink rexxSpecialVariable    Special
  259.   HiLink rexxConditional    rexxKeyword
  260.  
  261.   HiLink rexxOperator        Operator
  262.   HiLink rexxMessageOperator    rexxOperator
  263.   HiLink rexxLineComment    Comment
  264.  
  265.   HiLink rexxLineContinue    WildMenu
  266.  
  267.   HiLink rexxDirective        rexxKeyword
  268.   HiLink rexxClassDirective    Type
  269.   HiLink rexxMethodDirective    rexxFunction
  270.   HiLink rexxAttributeDirective    rexxFunction
  271.   HiLink rexxRequiresDirective    Include
  272.   HiLink rexxRoutineDirective    rexxFunction
  273.  
  274.   HiLink rexxConst        Constant
  275.   HiLink rexxTypeSpecifier    Type
  276.   HiLink rexxBuiltinClass    rexxTypeSpecifier
  277.  
  278.   HiLink rexxEnvironmentSymbol  rexxConst
  279.   HiLink rexxMessage        rexxFunction
  280.  
  281.   HiLink rexxParse              rexxKeyword
  282.   HiLink rexxParse2             rexxParse
  283.  
  284.   HiLink rexxGuard              rexxKeyword
  285.   HiLink rexxTrace              rexxKeyword
  286.  
  287.   HiLink rexxRaise              rexxKeyword
  288.   HiLink rexxRaise2             rexxRaise
  289.  
  290.   HiLink rexxForward            rexxKeyword
  291.   HiLink rexxForward2           rexxForward
  292.  
  293.   delcommand HiLink
  294. endif
  295.  
  296. let b:current_syntax = "rexx"
  297.  
  298. "vim: ts=8
  299.