tcl.js 7.4 KB

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