tcl.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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(["require", "exports"], function (require, exports) {
  6. 'use strict';
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.conf = {
  9. brackets: [
  10. ['{', '}'],
  11. ['[', ']'],
  12. ['(', ')']
  13. ],
  14. autoClosingPairs: [
  15. { open: '{', close: '}' },
  16. { open: '[', close: ']' },
  17. { open: '(', close: ')' },
  18. { open: '"', close: '"' },
  19. { open: '\'', close: '\'' },
  20. ],
  21. surroundingPairs: [
  22. { open: '{', close: '}' },
  23. { open: '[', close: ']' },
  24. { open: '(', close: ')' },
  25. { open: '"', close: '"' },
  26. { open: '\'', close: '\'' },
  27. ]
  28. };
  29. exports.language = {
  30. tokenPostfix: '.tcl',
  31. specialFunctions: [
  32. 'set', 'unset', 'rename', 'variable', 'proc', 'coroutine',
  33. 'foreach',
  34. 'incr', 'append',
  35. 'lappend', 'linsert', 'lreplace'
  36. ],
  37. mainFunctions: [
  38. 'if', 'then', 'elseif', 'else', 'case', 'switch', 'while', 'for',
  39. 'break', 'continue', 'return',
  40. 'package', 'namespace',
  41. 'catch', 'exit',
  42. 'eval', 'expr', 'uplevel', 'upvar'
  43. ],
  44. builtinFunctions: [
  45. 'file', 'info', 'concat', 'join', 'lindex',
  46. 'list', 'llength', 'lrange', 'lsearch', 'lsort', 'split',
  47. 'array', 'parray', 'binary', 'format', 'regexp', 'regsub', 'scan', 'string',
  48. 'subst', 'dict', 'cd', 'clock', 'exec', 'glob', 'pid', 'pwd', 'close', 'eof', 'fblocked',
  49. 'fconfigure', 'fcopy', 'fileevent', 'flush', 'gets', 'open', 'puts', 'read', 'seek',
  50. 'socket', 'tell', 'interp', 'after', 'auto_execok',
  51. 'auto_load', 'auto_mkindex', 'auto_reset', 'bgerror', 'error',
  52. 'global', 'history', 'load', 'source', 'time', 'trace',
  53. 'unknown', 'unset', 'update', 'vwait', 'winfo', 'wm', 'bind', 'event',
  54. 'pack', 'place', 'grid', 'font', 'bell', 'clipboard', 'destroy', 'focus', 'grab', 'lower',
  55. 'option', 'raise', 'selection', 'send', 'tk', 'tkwait', 'tk_bisque', 'tk_focusNext',
  56. 'tk_focusPrev', 'tk_focusFollowsMouse', 'tk_popup', 'tk_setPalette'
  57. ],
  58. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  59. brackets: [
  60. { open: '(', close: ')', token: 'delimiter.parenthesis' },
  61. { open: '{', close: '}', token: 'delimiter.curly' },
  62. { open: '[', close: ']', token: 'delimiter.square' }
  63. ],
  64. escapes: /\\(?:[abfnrtv\\"'\[\]\{\};\$]|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  65. variables: /(?:\$+(?:(?:\:\:?)?[a-zA-Z_]\w*)+)/,
  66. tokenizer: {
  67. root: [
  68. // identifiers and keywords
  69. [/[a-zA-Z_]\w*/, { cases: {
  70. '@specialFunctions': { token: 'keyword.flow', next: '@specialFunc' },
  71. '@mainFunctions': 'keyword',
  72. '@builtinFunctions': 'variable',
  73. '@default': 'operator.scss'
  74. } }],
  75. [/\s+\-+(?!\d|\.)\w*|{\*}/, 'metatag'],
  76. // whitespace
  77. { include: '@whitespace' },
  78. // delimiters and operators
  79. [/[{}()\[\]]/, '@brackets'],
  80. [/@symbols/, 'operator'],
  81. [/\$+(?:\:\:)?\{/, { token: 'identifier', next: '@nestedVariable' }],
  82. [/@variables/, 'type.identifier'],
  83. [/\.(?!\d|\.)[\w\-]*/, 'operator.sql'],
  84. // numbers
  85. [/\d+(\.\d+)?/, 'number'],
  86. [/\d+/, 'number'],
  87. // delimiter
  88. [/;/, 'delimiter'],
  89. // strings
  90. [/"/, { token: 'string.quote', bracket: '@open', next: '@dstring' }],
  91. [/'/, { token: 'string.quote', bracket: '@open', next: '@sstring' }]
  92. ],
  93. dstring: [
  94. [/\[/, { token: '@brackets', next: '@nestedCall' }],
  95. [/\$+(?:\:\:)?\{/, { token: 'identifier', next: '@nestedVariable' }],
  96. [/@variables/, 'type.identifier'],
  97. [/[^\\$\[\]"]+/, 'string'],
  98. [/@escapes/, 'string.escape'],
  99. [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }],
  100. ],
  101. sstring: [
  102. [/\[/, { token: '@brackets', next: '@nestedCall' }],
  103. [/\$+(?:\:\:)?\{/, { token: 'identifier', next: '@nestedVariable' }],
  104. [/@variables/, 'type.identifier'],
  105. [/[^\\$\[\]']+/, 'string'],
  106. [/@escapes/, 'string.escape'],
  107. [/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
  108. ],
  109. whitespace: [
  110. [/[ \t\r\n]+/, 'white'],
  111. [/#.*\\$/, { token: 'comment', next: '@newlineComment' }],
  112. [/#.*(?!\\)$/, 'comment']
  113. ],
  114. newlineComment: [
  115. [/.*\\$/, 'comment'],
  116. [/.*(?!\\)$/, { token: 'comment', next: '@pop' }]
  117. ],
  118. nestedVariable: [
  119. [/[^\{\}\$]+/, 'type.identifier'],
  120. [/\}/, { token: 'identifier', next: '@pop' }]
  121. ],
  122. nestedCall: [
  123. [/\[/, { token: '@brackets', next: '@nestedCall' }],
  124. [/\]/, { token: '@brackets', next: '@pop' }],
  125. { include: 'root' }
  126. ],
  127. specialFunc: [
  128. [/"/, { token: 'string', next: '@dstring' }],
  129. [/'/, { token: 'string', next: '@sstring' }],
  130. [/\S+/, { token: 'type', next: '@pop' }],
  131. ]
  132. }
  133. };
  134. });