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 / tcl.vim < prev    next >
Encoding:
Text File  |  1999-09-25  |  13.8 KB  |  216 lines  |  [TEXT/VIM!]

  1. " Vim syntax file
  2. " Language:    TCL/TK
  3. " Maintainer:    Allan Kelly <Allan.Kelly@ed.ac.uk>
  4. " Original:    Robin Becker <robin@jessikat.demon.co.uk>
  5. " Version:      5.1(synched), 1998 June 29
  6. "
  7. " Keywords TODO: format clock click anchor
  8.  
  9. " Remove any old syntax stuff hanging around
  10. syn clear
  11. set comments=:#
  12. " A bunch of useful keywords
  13. syn keyword tclStatement    proc global return lindex
  14. syn keyword tclStatement    llength lappend lreplace lrange list concat incr
  15. syn keyword tclStatement    upvar set
  16. syn keyword tclLabel        case default
  17. syn keyword tclConditional    if then else elseif switch
  18. syn keyword tclRepeat        while for foreach break continue
  19. syn keyword tcltkSwitch    contained    insert create polygon fill outline tag
  20.  
  21. " WIDGETS
  22. " commands associated with widgets
  23. syn keyword tcltkWidgetSwitch contained background highlightbackground insertontime cget
  24. syn keyword tcltkWidgetSwitch contained selectborderwidth borderwidth highlightcolor insertwidth
  25. syn keyword tcltkWidgetSwitch contained selectforeground cursor highlightthickness padx setgrid
  26. syn keyword tcltkWidgetSwitch contained exportselection insertbackground pady takefocus
  27. syn keyword tcltkWidgetSwitch contained font insertborderwidth relief xscrollcommand
  28. syn keyword tcltkWidgetSwitch contained foreground insertofftime selectbackground yscrollcommand
  29. syn keyword tcltkWidgetSwitch contained height spacing1 spacing2 spacing3
  30. syn keyword tcltkWidgetSwitch contained state tabs width wrap
  31. " button
  32. syn keyword tcltkWidgetSwitch contained command default
  33. " canvas
  34. syn keyword tcltkWidgetSwitch contained closeenough confine scrollregion xscrollincrement yscrollincrement orient
  35. " checkbutton, radiobutton
  36. syn keyword tcltkWidgetSwitch contained indicatoron offvalue onvalue selectcolor selectimage state variable
  37. " entry, frame
  38. syn keyword tcltkWidgetSwitch contained show class colormap container visual
  39. " listbox, menu
  40. syn keyword tcltkWidgetSwitch contained selectmode postcommand selectcolor tearoff tearoffcommand title type
  41. " menubutton, message
  42. syn keyword tcltkWidgetSwitch contained direction aspect justify
  43. " scale
  44. syn keyword tcltkWidgetSwitch contained bigincrement digits from length resolution showvalue sliderlength sliderrelief tickinterval to
  45. " scrollbar
  46. syn keyword tcltkWidgetSwitch contained activerelief elementborderwidth
  47. " image
  48. syn keyword tcltkWidgetSwitch contained delete names types create
  49. " variable reference
  50. syn match tclVarRef "$\a[a-zA-Z0-9_.]*"
  51. syn match tclVarRef "${\a[a-zA-Z0-9_.]*}"
  52. " menu, mane add
  53. syn keyword tcltkWidgetSwitch contained active end last none cascade checkbutton command radiobutton separator
  54. syn keyword tcltkWidgetSwitch contained activebackground actveforeground accelerator background bitmap columnbreak
  55. syn keyword tcltkWidgetSwitch contained font foreground hidemargin image indicatoron label menu offvalue onvalue
  56. syn keyword tcltkWidgetSwitch contained selectcolor selectimage state underline value variable
  57. syn keyword tcltkWidgetSwitch contained add clone configure delete entrycget entryconfigure index insert invoke
  58. syn keyword tcltkWidgetSwitch contained post postcascade type unpost yposition activate
  59. "syn keyword tcltkWidgetSwitch contained
  60. "syn match tcltkWidgetSwitch contained
  61. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<button\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  62. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scale\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  63.  
  64. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<canvas\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  65. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<checkbutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  66. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<entry\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  67. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<frame\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  68. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<image\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  69. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<listbox\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  70. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<menubutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  71. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<message\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  72. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<radiobutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  73. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scrollbar\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  74. " These words are dual purpose.
  75. " match switches
  76. syn match tcltkWidgetSwitch contained "-text"hs=s+1
  77. syn match tcltkWidgetSwitch contained "-menu"hs=s+1
  78. syn match tcltkWidgetSwitch contained "-label"hs=s+1
  79. " match commands - 2 lines for pretty match.
  80. "variable
  81. " Special case - If a number follows a variable region, it must be at the end of
  82. " the pattern, by definition. Therefore, (1) either include a number as the region
  83. " end and exclude tclNumber from the contains list, or (2) make variable
  84. " keepend. As (1) would put variable out of step with everything else, use (2).
  85. syn region tcltkCommand matchgroup=tcltkCommandColor start="^\<variable\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
  86. syn region tcltkCommand matchgroup=tcltkCommandColor start="\s\<variable\>\|\[\<variable\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
  87. " menu
  88. syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<menu\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  89. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<menu\>\|\[\<menu\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  90. " label
  91. syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<label\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  92. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<label\>\|\[\<label\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  93. " text
  94. syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<text\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tcltkSwitch,tclNumber,tclVarRef,tclString
  95. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<text\>\|\[\<text\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  96.  
  97. " This isn't contained (I don't think) so it's OK to just associate with the Color group.
  98. " TODO: This could be wrong.
  99. syn keyword tcltkWidgetColor    toplevel
  100.  
  101.  
  102. syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<configure\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef keepend
  103. syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<cget\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef
  104.  
  105.  
  106. " NAMESPACE
  107. " commands associated with namespace
  108. syn keyword tcltkNamespaceSwitch contained children code current delete eval
  109. syn keyword tcltkNamespaceSwitch contained export forget import inscope origin
  110. syn keyword tcltkNamespaceSwitch contained parent qualifiers tail which command variable
  111. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<namespace\>" matchgroup=NONE skip="^\s*$" end="{\|}\|]\|\"\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkNamespaceSwitch
  112.  
  113. " EXPR
  114. " commands associated with expr
  115. syn keyword tcltkMaths    contained    acos    cos    hypot    sinh
  116. syn keyword tcltkMaths    contained    asin    cosh    log    sqrt
  117. syn keyword tcltkMaths    contained    atan    exp    log10    tan
  118. syn keyword tcltkMaths    contained    atan2    floor    pow    tanh
  119. syn keyword tcltkMaths    contained    ceil    fmod    sin
  120. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<expr\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf
  121.  
  122. " format
  123. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<format\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf
  124.  
  125. " PACK
  126. " commands associated with pack
  127. syn keyword tcltkPackSwitch    contained    forget info propogate slaves
  128. syn keyword tcltkPackConfSwitch    contained    after anchor before expand fill in ipadx ipady padx pady side
  129. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<pack\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkPackSwitch,tcltkPackConf,tcltkPackConfSwitch,tclNumber,tclVarRef,tclString,tcltkCommand keepend
  130.  
  131. " STRING
  132. " commands associated with string
  133. syn keyword tcltkStringSwitch    contained    compare first index last length match range tolower toupper trim trimleft trimright wordstart wordend
  134. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<string\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkStringSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
  135.  
  136. " ARRAY
  137. " commands associated with array
  138. syn keyword tcltkArraySwitch    contained    anymore donesearch exists get names nextelement size startsearch set
  139. " match from command name to ] or EOL
  140. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<array\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkArraySwitch,tclNumber,tclVarRef,tclString,tcltkCommand
  141.  
  142. " LSORT
  143. " switches for lsort
  144. syn keyword tcltkLsortSwitch    contained    ascii dictionary integer real command increasing decreasing index
  145. " match from command name to ] or EOL
  146. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkLsortSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
  147.  
  148. syn keyword tclTodo contained    TODO
  149.  
  150.  
  151. " String and Character contstants
  152. " Highlight special characters (those which have a backslash) differently
  153. syn match   tclSpecial contained "\\\d\d\d\=\|\\."
  154. " A string needs the skip argument as it may legitimately contain \".
  155. " Match at start of line
  156. syn region  tclString          start=+^"+ end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
  157. "Match all other legal strings.
  158. syn region  tclString          start=+[^\\]"+ms=s+1  end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
  159.  
  160. syn match   tclLineContinue "\\\s*$"
  161.  
  162. "integer number, or floating point number without a dot and with "f".
  163. syn case ignore
  164. syn match  tclNumber        "\<\d\+\(u\=l\=\|lu\|f\)\>"
  165. "floating point number, with dot, optional exponent
  166. syn match  tclNumber        "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
  167. "floating point number, starting with a dot, optional exponent
  168. syn match  tclNumber        "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
  169. "floating point number, without dot, with exponent
  170. syn match  tclNumber        "\<\d\+e[-+]\=\d\+[fl]\=\>"
  171. "hex number
  172. syn match  tclNumber        "0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
  173. "syn match  tclIdentifier    "\<[a-z_][a-z0-9_]*\>"
  174. syn case match
  175.  
  176. syn region  tclComment        start="^\s*\#" end="$" contains=tclTodo
  177. syn region  tclComment        start=/;\s*\#/hs=s+1 end="$" contains=tclTodo
  178.  
  179. "syn sync ccomment tclComment
  180.  
  181. if !exists("did_tcl_syntax_inits")
  182.   let did_tcl_syntax_inits = 1
  183.   " The default methods for highlighting.  Can be overridden later
  184.   hi link tcltkSwitch        Special
  185.   hi link tclLabel        Label
  186.   hi link tclConditional    Conditional
  187.   hi link tclRepeat        Repeat
  188.   hi link tclNumber        Number
  189.   hi link tclError        Error
  190.   hi link tclStatement        Statement
  191.   " hi link tclStatementColor    Statement
  192.   hi link tclString        String
  193.   hi link tclComment        Comment
  194.   hi link tclSpecial        Special
  195.   hi link tclTodo        Todo
  196.   " Below here are the commands and their options.
  197.   hi link tcltkCommandColor    Statement
  198.   hi link tcltkWidgetColor      Structure
  199.   hi link tclLineContinue       WarningMsg
  200.   hi link tcltkStringSwitch    Special
  201.   hi link tcltkArraySwitch    Special
  202.   hi link tcltkLsortSwitch    Special
  203.   hi link tcltkPackSwitch    Special
  204.   hi link tcltkPackConfSwitch    Special
  205.   hi link tcltkMaths        Special
  206.   hi link tcltkNamespaceSwitch    Special
  207.   hi link tcltkWidgetSwitch    Special
  208.   hi link tcltkPackConfColor    Identifier
  209.   "hi link tcltkLsort        Statement
  210.   hi link tclVarRef             Identifier
  211. endif
  212.  
  213. let b:current_syntax = "tcl"
  214.  
  215. " vim: ts=8
  216.