tcl.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. export var conf = {
  6. brackets: [
  7. ['{', '}'],
  8. ['[', ']'],
  9. ['(', ')']
  10. ],
  11. autoClosingPairs: [
  12. { open: '{', close: '}' },
  13. { open: '[', close: ']' },
  14. { open: '(', close: ')' },
  15. { open: '"', close: '"' },
  16. { open: "'", close: "'" }
  17. ],
  18. surroundingPairs: [
  19. { open: '{', close: '}' },
  20. { open: '[', close: ']' },
  21. { open: '(', close: ')' },
  22. { open: '"', close: '"' },
  23. { open: "'", close: "'" }
  24. ]
  25. };
  26. export var language = {
  27. tokenPostfix: '.tcl',
  28. specialFunctions: [
  29. 'set',
  30. 'unset',
  31. 'rename',
  32. 'variable',
  33. 'proc',
  34. 'coroutine',
  35. 'foreach',
  36. 'incr',
  37. 'append',
  38. 'lappend',
  39. 'linsert',
  40. 'lreplace'
  41. ],
  42. mainFunctions: [
  43. 'if',
  44. 'then',
  45. 'elseif',
  46. 'else',
  47. 'case',
  48. 'switch',
  49. 'while',
  50. 'for',
  51. 'break',
  52. 'continue',
  53. 'return',
  54. 'package',
  55. 'namespace',
  56. 'catch',
  57. 'exit',
  58. 'eval',
  59. 'expr',
  60. 'uplevel',
  61. 'upvar'
  62. ],
  63. builtinFunctions: [
  64. 'file',
  65. 'info',
  66. 'concat',
  67. 'join',
  68. 'lindex',
  69. 'list',
  70. 'llength',
  71. 'lrange',
  72. 'lsearch',
  73. 'lsort',
  74. 'split',
  75. 'array',
  76. 'parray',
  77. 'binary',
  78. 'format',
  79. 'regexp',
  80. 'regsub',
  81. 'scan',
  82. 'string',
  83. 'subst',
  84. 'dict',
  85. 'cd',
  86. 'clock',
  87. 'exec',
  88. 'glob',
  89. 'pid',
  90. 'pwd',
  91. 'close',
  92. 'eof',
  93. 'fblocked',
  94. 'fconfigure',
  95. 'fcopy',
  96. 'fileevent',
  97. 'flush',
  98. 'gets',
  99. 'open',
  100. 'puts',
  101. 'read',
  102. 'seek',
  103. 'socket',
  104. 'tell',
  105. 'interp',
  106. 'after',
  107. 'auto_execok',
  108. 'auto_load',
  109. 'auto_mkindex',
  110. 'auto_reset',
  111. 'bgerror',
  112. 'error',
  113. 'global',
  114. 'history',
  115. 'load',
  116. 'source',
  117. 'time',
  118. 'trace',
  119. 'unknown',
  120. 'unset',
  121. 'update',
  122. 'vwait',
  123. 'winfo',
  124. 'wm',
  125. 'bind',
  126. 'event',
  127. 'pack',
  128. 'place',
  129. 'grid',
  130. 'font',
  131. 'bell',
  132. 'clipboard',
  133. 'destroy',
  134. 'focus',
  135. 'grab',
  136. 'lower',
  137. 'option',
  138. 'raise',
  139. 'selection',
  140. 'send',
  141. 'tk',
  142. 'tkwait',
  143. 'tk_bisque',
  144. 'tk_focusNext',
  145. 'tk_focusPrev',
  146. 'tk_focusFollowsMouse',
  147. 'tk_popup',
  148. 'tk_setPalette'
  149. ],
  150. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  151. brackets: [
  152. { open: '(', close: ')', token: 'delimiter.parenthesis' },
  153. { open: '{', close: '}', token: 'delimiter.curly' },
  154. { open: '[', close: ']', token: 'delimiter.square' }
  155. ],
  156. escapes: /\\(?:[abfnrtv\\"'\[\]\{\};\$]|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  157. variables: /(?:\$+(?:(?:\:\:?)?[a-zA-Z_]\w*)+)/,
  158. tokenizer: {
  159. root: [
  160. // identifiers and keywords
  161. [
  162. /[a-zA-Z_]\w*/,
  163. {
  164. cases: {
  165. '@specialFunctions': {
  166. token: 'keyword.flow',
  167. next: '@specialFunc'
  168. },
  169. '@mainFunctions': 'keyword',
  170. '@builtinFunctions': 'variable',
  171. '@default': 'operator.scss'
  172. }
  173. }
  174. ],
  175. [/\s+\-+(?!\d|\.)\w*|{\*}/, 'metatag'],
  176. // whitespace
  177. { include: '@whitespace' },
  178. // delimiters and operators
  179. [/[{}()\[\]]/, '@brackets'],
  180. [/@symbols/, 'operator'],
  181. [/\$+(?:\:\:)?\{/, { token: 'identifier', next: '@nestedVariable' }],
  182. [/@variables/, 'type.identifier'],
  183. [/\.(?!\d|\.)[\w\-]*/, 'operator.sql'],
  184. // numbers
  185. [/\d+(\.\d+)?/, 'number'],
  186. [/\d+/, 'number'],
  187. // delimiter
  188. [/;/, 'delimiter'],
  189. // strings
  190. [/"/, { token: 'string.quote', bracket: '@open', next: '@dstring' }],
  191. [/'/, { token: 'string.quote', bracket: '@open', next: '@sstring' }]
  192. ],
  193. dstring: [
  194. [/\[/, { token: '@brackets', next: '@nestedCall' }],
  195. [/\$+(?:\:\:)?\{/, { token: 'identifier', next: '@nestedVariable' }],
  196. [/@variables/, 'type.identifier'],
  197. [/[^\\$\[\]"]+/, 'string'],
  198. [/@escapes/, 'string.escape'],
  199. [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
  200. ],
  201. sstring: [
  202. [/\[/, { token: '@brackets', next: '@nestedCall' }],
  203. [/\$+(?:\:\:)?\{/, { token: 'identifier', next: '@nestedVariable' }],
  204. [/@variables/, 'type.identifier'],
  205. [/[^\\$\[\]']+/, 'string'],
  206. [/@escapes/, 'string.escape'],
  207. [/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
  208. ],
  209. whitespace: [
  210. [/[ \t\r\n]+/, 'white'],
  211. [/#.*\\$/, { token: 'comment', next: '@newlineComment' }],
  212. [/#.*(?!\\)$/, 'comment']
  213. ],
  214. newlineComment: [
  215. [/.*\\$/, 'comment'],
  216. [/.*(?!\\)$/, { token: 'comment', next: '@pop' }]
  217. ],
  218. nestedVariable: [
  219. [/[^\{\}\$]+/, 'type.identifier'],
  220. [/\}/, { token: 'identifier', next: '@pop' }]
  221. ],
  222. nestedCall: [
  223. [/\[/, { token: '@brackets', next: '@nestedCall' }],
  224. [/\]/, { token: '@brackets', next: '@pop' }],
  225. { include: 'root' }
  226. ],
  227. specialFunc: [
  228. [/"/, { token: 'string', next: '@dstring' }],
  229. [/'/, { token: 'string', next: '@sstring' }],
  230. [/\S+/, { token: 'type', next: '@pop' }]
  231. ]
  232. }
  233. };