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 / mac / vim55rt.sit / runtime / syntax / dosbatch.vim < prev    next >
Encoding:
Text File  |  1999-09-25  |  5.3 KB  |  128 lines  |  [TEXT/VIM!]

  1. " Vim syntax file
  2. " Language:    MSDOS batch file (with NT command extensions)
  3. " Maintainer:    Mike Williams <mrw@netcomuk.co.uk>
  4. " Filenames:    *.bat
  5. " Last Change:    14th May 1999
  6. " Web Page:     N/A
  7.  
  8. " Remove any old syntax stuff hanging around
  9. syn clear
  10.  
  11. " DOS bat files are case insensitive but case preserving!
  12. syn case ignore
  13.  
  14. syn keyword dosbatchTodo contained    TODO
  15.  
  16. " Dosbat keywords
  17. syn keyword dosbatchStatement    goto call exit
  18. syn keyword dosbatchConditional    if else
  19. syn keyword dosbatchRepeat    for
  20.  
  21. " Some operators - first lot are case sensitive!
  22. syn case match
  23. syn keyword dosbatchOperator    EQU NEQ LSS LEQ GTR GEQ
  24. syn case ignore
  25. syn match dosbatchOperator      "\s[-+\*/%]\s"
  26. syn match dosbatchOperator      "="
  27. syn match dosbatchOperator      "[-+\*/%]="
  28. syn match dosbatchOperator      "\s\(&\||\|^\|<<\|>>\)=\=\s"
  29. syn match dosbatchIfOperator    "if\s\+\(\(not\)\=\s\+\)\=\(exist\|defined\|errorlevel\|cmdextversion\)\="lc=2
  30.  
  31. " String - using "'s is a convenience rather than a requirement outside of FOR
  32. syn match dosbatchString    "\"[^"]*\"" contains=dosbatchVariable,dosBatchArgument,@dosbatchNumber
  33. syn match dosbatchString        "\<echo[^)>|]*"lc=4 contains=dosbatchVariable,dosbatchArgument,@dosbatchNumber
  34. syn match dosbatchEchoOperator  "\<echo\s\+\(on\|off\)\s*$"lc=4
  35.  
  36. " For embedded commands
  37. syn match dosbatchCmd        "(\s*'[^']*'"lc=1 contains=dosbatchString,dosbatchVariable,dosBatchArgument,@dosbatchNumber,dosbatchImplicit,dosbatchStatement,dosbatchConditional,dosbatchRepeat,dosbatchOperator
  38.  
  39. " Numbers - surround with ws to not include in dir and filenames
  40. syn match dosbatchInteger       "[[:space:]=(/:]\d\+"lc=1
  41. syn match dosbatchHex           "[[:space:]=(/:]0x\x\+"lc=1
  42. syn match dosbatchBinary        "[[:space:]=(/:]0b[01]\+"lc=1
  43. syn match dosbatchOctal         "[[:space:]=(/:]0\o\+"lc=1
  44. syn cluster dosbatchNumber      contains=dosbatchInteger,dosbatchHex,dosbatchBinary,dosbatchOctal
  45.  
  46. " Command line switches
  47. syn match dosbatchSwitch        "/\(\a\+\|?\)"
  48.  
  49. " Various special escaped char formats
  50. syn match dosbatchSpecialChar   "\^[&|()<>^]"
  51. syn match dosbatchSpecialChar   "\$[a-hl-npqstv_$+]"
  52. syn match dosbatchSpecialChar   "%%"
  53.  
  54. " Environment variables
  55. syn match dosbatchIdentifier    contained "\s\h\w*\>"
  56. syn match dosbatchVariable    "%\h\w*%"
  57. syn match dosbatchVariable    "%\h\w*:\*\=[^=]*=[^%]*%"
  58. syn match dosbatchVariable    "%\h\w*:\~\d\+,\d\+%" contains=dosbatchInteger
  59. syn match dosbatchSet           "\s\h\w*[+-]\==\{-1}" contains=dosbatchIdentifier,dosbatchOperator
  60.  
  61. " Args to bat files and for loops, etc
  62. syn match dosbatchArgument    "%\(\d\|\*\)"
  63. syn match dosbatchArgument    "%%[a-z]\>"
  64. syn match dosbatchArgument    "%\~[fdpnxs]\+\(\($PATH:\)\=[a-z]\|\d\)\>"
  65.  
  66. " Line labels
  67. syn match dosbatchLabel         "^\s*:\s*\h\w*\>"
  68. syn match dosbatchLabel         "\<\(goto\|call\)\s\+:\h\w*\>"lc=4
  69. syn match dosbatchLabel         "\<goto\s\+\h\w*\>"lc=4
  70. syn match dosbatchLabel         ":\h\w*\>"
  71.  
  72. " Comments - usual rem but also two colons as first non-space is an idiom
  73. syn match dosbatchComment    "^rem\($\|\s.*$\)"lc=3 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument
  74. syn match dosbatchComment    "\srem\($\|\s.*$\)"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument
  75. syn match dosbatchComment    "\s*:\s*:.*$" contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument
  76.  
  77. " Comments in ()'s - still to handle spaces before rem
  78. syn match dosbatchComment    "(rem[^)]*"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument
  79.  
  80. syn keyword dosbatchImplicit    append assoc at attrib break cacls cd chcp chdir
  81. syn keyword dosbatchImplicit    chkdsk cls cmd color comp compact convert copy
  82. syn keyword dosbatchImplicit    date del dir diskcomp diskcopy doskey echo endlocal
  83. syn keyword dosbatchImplicit    erase fc find findstr format ftype
  84. syn keyword dosbatchImplicit    graftabl help keyb label md mkdir mode more move
  85. syn keyword dosbatchImplicit    path pause popd print prompt pushd rd recover rem
  86. syn keyword dosbatchImplicit    ren rename replace restore rmdir set setlocal shift
  87. syn keyword dosbatchImplicit    sort start subst time title tree type ver verify
  88. syn keyword dosbatchImplicit    vol xcopy
  89.  
  90. if !exists("did_dosbatch_syntax_inits")
  91.   let did_dosbatch_syntax_inits = 1
  92.   " The default methods for highlighting.  Can be overridden later
  93.   hi link dosbatchTodo            Todo
  94.  
  95.   hi link dosbatchStatement        Statement
  96.   hi link dosbatchCommands        dosbatchStatement
  97.   hi link dosbatchLabel            Label
  98.   hi link dosbatchConditional        Conditional
  99.   hi link dosbatchRepeat        Repeat
  100.  
  101.   hi link dosbatchOperator              Operator
  102.   hi link dosbatchEchoOperator          dosbatchOperator
  103.   hi link dosbatchIfOperator            dosbatchOperator
  104.  
  105.   hi link dosbatchArgument        Identifier
  106.   hi link dosbatchIdentifier            Identifier
  107.   hi link dosbatchVariable        dosbatchIdentifier
  108.  
  109.   hi link dosbatchSpecialChar        SpecialChar
  110.   hi link dosbatchString        String
  111.   hi link dosbatchNumber        Number
  112.   hi link dosbatchInteger        dosbatchNumber
  113.   hi link dosbatchHex            dosbatchNumber
  114.   hi link dosbatchBinary        dosbatchNumber
  115.   hi link dosbatchOctal            dosbatchNumber
  116.  
  117.   hi link dosbatchComment        Comment
  118.   hi link dosbatchImplicit        Function
  119.  
  120.   hi link dosbatchSwitch                Special
  121.  
  122.   hi link dosbatchCmd                   PreProc
  123. endif
  124.  
  125. let b:current_syntax = "dosbatch"
  126.  
  127. " vim: ts=8
  128.