shell.js 4.6 KB

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