shell.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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/shell/shell',["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. comments: {
  11. lineComment: '#'
  12. },
  13. brackets: [
  14. ['{', '}'],
  15. ['[', ']'],
  16. ['(', ')']
  17. ],
  18. autoClosingPairs: [
  19. { open: '{', close: '}' },
  20. { open: '[', close: ']' },
  21. { open: '(', close: ')' },
  22. { open: '"', close: '"' },
  23. { open: "'", close: "'" },
  24. { open: '`', close: '`' }
  25. ],
  26. surroundingPairs: [
  27. { open: '{', close: '}' },
  28. { open: '[', close: ']' },
  29. { open: '(', close: ')' },
  30. { open: '"', close: '"' },
  31. { open: "'", close: "'" },
  32. { open: '`', close: '`' }
  33. ]
  34. };
  35. exports.language = {
  36. defaultToken: '',
  37. ignoreCase: true,
  38. tokenPostfix: '.shell',
  39. brackets: [
  40. { token: 'delimiter.bracket', open: '{', close: '}' },
  41. { token: 'delimiter.parenthesis', open: '(', close: ')' },
  42. { token: 'delimiter.square', open: '[', close: ']' }
  43. ],
  44. keywords: [
  45. 'if',
  46. 'then',
  47. 'do',
  48. 'else',
  49. 'elif',
  50. 'while',
  51. 'until',
  52. 'for',
  53. 'in',
  54. 'esac',
  55. 'fi',
  56. 'fin',
  57. 'fil',
  58. 'done',
  59. 'exit',
  60. 'set',
  61. 'unset',
  62. 'export',
  63. 'function'
  64. ],
  65. builtins: [
  66. 'ab',
  67. 'awk',
  68. 'bash',
  69. 'beep',
  70. 'cat',
  71. 'cc',
  72. 'cd',
  73. 'chown',
  74. 'chmod',
  75. 'chroot',
  76. 'clear',
  77. 'cp',
  78. 'curl',
  79. 'cut',
  80. 'diff',
  81. 'echo',
  82. 'find',
  83. 'gawk',
  84. 'gcc',
  85. 'get',
  86. 'git',
  87. 'grep',
  88. 'hg',
  89. 'kill',
  90. 'killall',
  91. 'ln',
  92. 'ls',
  93. 'make',
  94. 'mkdir',
  95. 'openssl',
  96. 'mv',
  97. 'nc',
  98. 'node',
  99. 'npm',
  100. 'ping',
  101. 'ps',
  102. 'restart',
  103. 'rm',
  104. 'rmdir',
  105. 'sed',
  106. 'service',
  107. 'sh',
  108. 'shopt',
  109. 'shred',
  110. 'source',
  111. 'sort',
  112. 'sleep',
  113. 'ssh',
  114. 'start',
  115. 'stop',
  116. 'su',
  117. 'sudo',
  118. 'svn',
  119. 'tee',
  120. 'telnet',
  121. 'top',
  122. 'touch',
  123. 'vi',
  124. 'vim',
  125. 'wall',
  126. 'wc',
  127. 'wget',
  128. 'who',
  129. 'write',
  130. 'yes',
  131. 'zsh'
  132. ],
  133. // we include these common regular expressions
  134. symbols: /[=><!~?&|+\-*\/\^;\.,]+/,
  135. // The main tokenizer for our languages
  136. tokenizer: {
  137. root: [
  138. { include: '@whitespace' },
  139. [
  140. /[a-zA-Z]\w*/,
  141. {
  142. cases: {
  143. '@keywords': 'keyword',
  144. '@builtins': 'type.identifier',
  145. '@default': ''
  146. }
  147. }
  148. ],
  149. { include: '@strings' },
  150. { include: '@parameters' },
  151. { include: '@heredoc' },
  152. [/[{}\[\]()]/, '@brackets'],
  153. [/-+\w+/, 'attribute.name'],
  154. [/@symbols/, 'delimiter'],
  155. { include: '@numbers' },
  156. [/[,;]/, 'delimiter']
  157. ],
  158. whitespace: [
  159. [/\s+/, 'white'],
  160. [/(^#!.*$)/, 'metatag'],
  161. [/(^#.*$)/, 'comment']
  162. ],
  163. numbers: [
  164. [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
  165. [/0[xX][0-9a-fA-F_]*[0-9a-fA-F]/, 'number.hex'],
  166. [/\d+/, 'number']
  167. ],
  168. // Recognize strings, including those broken across lines
  169. strings: [
  170. [/'/, 'string', '@stringBody'],
  171. [/"/, 'string', '@dblStringBody']
  172. ],
  173. stringBody: [
  174. [/'/, 'string', '@popall'],
  175. [/./, 'string']
  176. ],
  177. dblStringBody: [
  178. [/"/, 'string', '@popall'],
  179. [/./, 'string']
  180. ],
  181. heredoc: [
  182. [
  183. /(<<[-<]?)(\s*)(['"`]?)([\w\-]+)(['"`]?)/,
  184. [
  185. 'constants',
  186. 'white',
  187. 'string.heredoc.delimiter',
  188. 'string.heredoc',
  189. 'string.heredoc.delimiter'
  190. ]
  191. ]
  192. ],
  193. parameters: [
  194. [/\$\d+/, 'variable.predefined'],
  195. [/\$\w+/, 'variable'],
  196. [/\$[*@#?\-$!0_]/, 'variable'],
  197. [/\$'/, 'variable', '@parameterBodyQuote'],
  198. [/\$"/, 'variable', '@parameterBodyDoubleQuote'],
  199. [/\$\(/, 'variable', '@parameterBodyParen'],
  200. [/\$\{/, 'variable', '@parameterBodyCurlyBrace']
  201. ],
  202. parameterBodyQuote: [
  203. [/[^#:%*@\-!_']+/, 'variable'],
  204. [/[#:%*@\-!_]/, 'delimiter'],
  205. [/[']/, 'variable', '@pop']
  206. ],
  207. parameterBodyDoubleQuote: [
  208. [/[^#:%*@\-!_"]+/, 'variable'],
  209. [/[#:%*@\-!_]/, 'delimiter'],
  210. [/["]/, 'variable', '@pop']
  211. ],
  212. parameterBodyParen: [
  213. [/[^#:%*@\-!_)]+/, 'variable'],
  214. [/[#:%*@\-!_]/, 'delimiter'],
  215. [/[)]/, 'variable', '@pop']
  216. ],
  217. parameterBodyCurlyBrace: [
  218. [/[^#:%*@\-!_}]+/, 'variable'],
  219. [/[#:%*@\-!_]/, 'delimiter'],
  220. [/[}]/, 'variable', '@pop']
  221. ]
  222. }
  223. };
  224. });