tads.vim 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. " Vim syntax file
  2. " Language: TADS
  3. " Maintainer: Amir Karger <karger@post.harvard.edu>
  4. " $Date: 2004/06/13 19:28:45 $
  5. " $Revision: 1.1 $
  6. " Stolen from: Bram Moolenaar's C language file
  7. " Newest version at: http://www.hec.utah.edu/~karger/vim/syntax/tads.vim
  8. " History info at the bottom of the file
  9. " TODO lots more keywords
  10. " global, self, etc. are special *objects*, not functions. They should
  11. " probably be a different color than the special functions
  12. " Actually, should cvtstr etc. be functions?! (change tadsFunction)
  13. " Make global etc. into Identifiers, since we don't have regular variables?
  14. " quit when a syntax file was already loaded
  15. if exists("b:current_syntax")
  16. finish
  17. endif
  18. " A bunch of useful keywords
  19. syn keyword tadsStatement goto break return continue pass
  20. syn keyword tadsLabel case default
  21. syn keyword tadsConditional if else switch
  22. syn keyword tadsRepeat while for do
  23. syn keyword tadsStorageClass local compoundWord formatstring specialWords
  24. syn keyword tadsBoolean nil true
  25. " TADS keywords
  26. syn keyword tadsKeyword replace modify
  27. syn keyword tadsKeyword global self inherited
  28. " builtin functions
  29. syn keyword tadsKeyword cvtstr cvtnum caps lower upper substr
  30. syn keyword tadsKeyword say length
  31. syn keyword tadsKeyword setit setscore
  32. syn keyword tadsKeyword datatype proptype
  33. syn keyword tadsKeyword car cdr
  34. syn keyword tadsKeyword defined isclass
  35. syn keyword tadsKeyword find firstobj nextobj
  36. syn keyword tadsKeyword getarg argcount
  37. syn keyword tadsKeyword input yorn askfile
  38. syn keyword tadsKeyword rand randomize
  39. syn keyword tadsKeyword restart restore quit save undo
  40. syn keyword tadsException abort exit exitobj
  41. syn keyword tadsTodo contained TODO FIXME XXX
  42. " String and Character constants
  43. " Highlight special characters (those which have a backslash) differently
  44. syn match tadsSpecial contained "\\."
  45. syn region tadsDoubleString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=tadsSpecial,tadsEmbedded
  46. syn region tadsSingleString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=tadsSpecial
  47. " Embedded expressions in strings
  48. syn region tadsEmbedded contained start="<<" end=">>" contains=tadsKeyword
  49. " TADS doesn't have \xxx, right?
  50. "syn match cSpecial contained "\\[0-7][0-7][0-7]\=\|\\."
  51. "syn match cSpecialCharacter "'\\[0-7][0-7]'"
  52. "syn match cSpecialCharacter "'\\[0-7][0-7][0-7]'"
  53. "catch errors caused by wrong parenthesis
  54. "syn region cParen transparent start='(' end=')' contains=ALLBUT,cParenError,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel
  55. "syn match cParenError ")"
  56. "syn match cInParen contained "[{}]"
  57. syn region tadsBrace transparent start='{' end='}' contains=ALLBUT,tadsBraceError,tadsIncluded,tadsSpecial,tadsTodo
  58. syn match tadsBraceError "}"
  59. "integer number (TADS has no floating point numbers)
  60. syn case ignore
  61. syn match tadsNumber "\<[0-9]\+\>"
  62. "hex number
  63. syn match tadsNumber "\<0x[0-9a-f]\+\>"
  64. syn match tadsIdentifier "\<[a-z][a-z0-9_$]*\>"
  65. syn case match
  66. " flag an octal number with wrong digits
  67. syn match tadsOctalError "\<0[0-7]*[89]"
  68. " Removed complicated c_comment_strings
  69. syn region tadsComment start="/\*" end="\*/" contains=tadsTodo
  70. syn match tadsComment "//.*" contains=tadsTodo
  71. syntax match tadsCommentError "\*/"
  72. syn region tadsPreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=tadsComment,tadsString,tadsNumber,tadsCommentError
  73. syn region tadsIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+
  74. syn match tadsIncluded contained "<[^>]*>"
  75. syn match tadsInclude "^\s*#\s*include\>\s*["<]" contains=tadsIncluded
  76. syn region tadsDefine start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInBrace,tadsIdentifier
  77. syn region tadsPreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,tadsPreCondit,tadsIncluded,tadsInclude,tadsDefine,tadsInParen,tadsIdentifier
  78. " Highlight User Labels
  79. " TODO labels for gotos?
  80. "syn region cMulti transparent start='?' end=':' contains=ALLBUT,cIncluded,cSpecial,cTodo,cUserCont,cUserLabel,cBitField
  81. " Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
  82. "syn match cUserCont "^\s*\I\i*\s*:$" contains=cUserLabel
  83. "syn match cUserCont ";\s*\I\i*\s*:$" contains=cUserLabel
  84. "syn match cUserCont "^\s*\I\i*\s*:[^:]" contains=cUserLabel
  85. "syn match cUserCont ";\s*\I\i*\s*:[^:]" contains=cUserLabel
  86. "syn match cUserLabel "\I\i*" contained
  87. " identifier: class-name [, class-name [...]] [property-list] ;
  88. " Don't highlight comment in class def
  89. syn match tadsClassDef "\<class\>[^/]*" contains=tadsObjectDef,tadsClass
  90. syn match tadsClass contained "\<class\>"
  91. syn match tadsObjectDef "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*[a-zA-Z0-9_$]\+\(\s*,\s*[a-zA-Z][a-zA-Z0-9_$]*\)*\(\s*;\)\="
  92. syn keyword tadsFunction contained function
  93. syn match tadsFunctionDef "\<[a-zA-Z][a-zA-Z0-9_$]*\s*:\s*function[^{]*" contains=tadsFunction
  94. "syn region tadsObject transparent start = '[a-zA-Z][\i$]\s*:\s*' end=";" contains=tadsBrace,tadsObjectDef
  95. " How far back do we go to find matching groups
  96. if !exists("tads_minlines")
  97. let tads_minlines = 15
  98. endif
  99. exec "syn sync ccomment tadsComment minlines=" . tads_minlines
  100. if !exists("tads_sync_dist")
  101. let tads_sync_dist = 100
  102. endif
  103. execute "syn sync maxlines=" . tads_sync_dist
  104. " Define the default highlighting.
  105. " Only when an item doesn't have highlighting yet
  106. " The default methods for highlighting. Can be overridden later
  107. hi def link tadsFunctionDef Function
  108. hi def link tadsFunction Structure
  109. hi def link tadsClass Structure
  110. hi def link tadsClassDef Identifier
  111. hi def link tadsObjectDef Identifier
  112. " no highlight for tadsEmbedded, so it prints as normal text w/in the string
  113. hi def link tadsOperator Operator
  114. hi def link tadsStructure Structure
  115. hi def link tadsTodo Todo
  116. hi def link tadsLabel Label
  117. hi def link tadsConditional Conditional
  118. hi def link tadsRepeat Repeat
  119. hi def link tadsException Exception
  120. hi def link tadsStatement Statement
  121. hi def link tadsStorageClass StorageClass
  122. hi def link tadsKeyWord Keyword
  123. hi def link tadsSpecial SpecialChar
  124. hi def link tadsNumber Number
  125. hi def link tadsBoolean Boolean
  126. hi def link tadsDoubleString tadsString
  127. hi def link tadsSingleString tadsString
  128. hi def link tadsOctalError tadsError
  129. hi def link tadsCommentError tadsError
  130. hi def link tadsBraceError tadsError
  131. hi def link tadsInBrace tadsError
  132. hi def link tadsError Error
  133. hi def link tadsInclude Include
  134. hi def link tadsPreProc PreProc
  135. hi def link tadsDefine Macro
  136. hi def link tadsIncluded tadsString
  137. hi def link tadsPreCondit PreCondit
  138. hi def link tadsString String
  139. hi def link tadsComment Comment
  140. let b:current_syntax = "tads"
  141. " Changes:
  142. " 11/18/99 Added a bunch of TADS functions, tadsException
  143. " 10/22/99 Misspelled Moolenaar (sorry!), c_minlines to tads_minlines
  144. "
  145. " vim: ts=8