python.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.38.0(0e330ae453813de4e6cf272460fb79c7117073d0)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. var __defProp = Object.defineProperty;
  8. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  9. var __getOwnPropNames = Object.getOwnPropertyNames;
  10. var __hasOwnProp = Object.prototype.hasOwnProperty;
  11. var __copyProps = (to, from, except, desc) => {
  12. if (from && typeof from === "object" || typeof from === "function") {
  13. for (let key of __getOwnPropNames(from))
  14. if (!__hasOwnProp.call(to, key) && key !== except)
  15. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  16. }
  17. return to;
  18. };
  19. var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
  20. // src/fillers/monaco-editor-core.ts
  21. var monaco_editor_core_exports = {};
  22. __reExport(monaco_editor_core_exports, monaco_editor_core_star);
  23. import * as monaco_editor_core_star from "../../editor/editor.api.js";
  24. // src/basic-languages/python/python.ts
  25. var conf = {
  26. comments: {
  27. lineComment: "#",
  28. blockComment: ["'''", "'''"]
  29. },
  30. brackets: [
  31. ["{", "}"],
  32. ["[", "]"],
  33. ["(", ")"]
  34. ],
  35. autoClosingPairs: [
  36. { open: "{", close: "}" },
  37. { open: "[", close: "]" },
  38. { open: "(", close: ")" },
  39. { open: '"', close: '"', notIn: ["string"] },
  40. { open: "'", close: "'", notIn: ["string", "comment"] }
  41. ],
  42. surroundingPairs: [
  43. { open: "{", close: "}" },
  44. { open: "[", close: "]" },
  45. { open: "(", close: ")" },
  46. { open: '"', close: '"' },
  47. { open: "'", close: "'" }
  48. ],
  49. onEnterRules: [
  50. {
  51. beforeText: new RegExp("^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async|match|case).*?:\\s*$"),
  52. action: { indentAction: monaco_editor_core_exports.languages.IndentAction.Indent }
  53. }
  54. ],
  55. folding: {
  56. offSide: true,
  57. markers: {
  58. start: new RegExp("^\\s*#region\\b"),
  59. end: new RegExp("^\\s*#endregion\\b")
  60. }
  61. }
  62. };
  63. var language = {
  64. defaultToken: "",
  65. tokenPostfix: ".python",
  66. keywords: [
  67. "False",
  68. "None",
  69. "True",
  70. "_",
  71. "and",
  72. "as",
  73. "assert",
  74. "async",
  75. "await",
  76. "break",
  77. "case",
  78. "class",
  79. "continue",
  80. "def",
  81. "del",
  82. "elif",
  83. "else",
  84. "except",
  85. "exec",
  86. "finally",
  87. "for",
  88. "from",
  89. "global",
  90. "if",
  91. "import",
  92. "in",
  93. "is",
  94. "lambda",
  95. "match",
  96. "nonlocal",
  97. "not",
  98. "or",
  99. "pass",
  100. "print",
  101. "raise",
  102. "return",
  103. "try",
  104. "while",
  105. "with",
  106. "yield",
  107. "int",
  108. "float",
  109. "long",
  110. "complex",
  111. "hex",
  112. "abs",
  113. "all",
  114. "any",
  115. "apply",
  116. "basestring",
  117. "bin",
  118. "bool",
  119. "buffer",
  120. "bytearray",
  121. "callable",
  122. "chr",
  123. "classmethod",
  124. "cmp",
  125. "coerce",
  126. "compile",
  127. "complex",
  128. "delattr",
  129. "dict",
  130. "dir",
  131. "divmod",
  132. "enumerate",
  133. "eval",
  134. "execfile",
  135. "file",
  136. "filter",
  137. "format",
  138. "frozenset",
  139. "getattr",
  140. "globals",
  141. "hasattr",
  142. "hash",
  143. "help",
  144. "id",
  145. "input",
  146. "intern",
  147. "isinstance",
  148. "issubclass",
  149. "iter",
  150. "len",
  151. "locals",
  152. "list",
  153. "map",
  154. "max",
  155. "memoryview",
  156. "min",
  157. "next",
  158. "object",
  159. "oct",
  160. "open",
  161. "ord",
  162. "pow",
  163. "print",
  164. "property",
  165. "reversed",
  166. "range",
  167. "raw_input",
  168. "reduce",
  169. "reload",
  170. "repr",
  171. "reversed",
  172. "round",
  173. "self",
  174. "set",
  175. "setattr",
  176. "slice",
  177. "sorted",
  178. "staticmethod",
  179. "str",
  180. "sum",
  181. "super",
  182. "tuple",
  183. "type",
  184. "unichr",
  185. "unicode",
  186. "vars",
  187. "xrange",
  188. "zip",
  189. "__dict__",
  190. "__methods__",
  191. "__members__",
  192. "__class__",
  193. "__bases__",
  194. "__name__",
  195. "__mro__",
  196. "__subclasses__",
  197. "__init__",
  198. "__import__"
  199. ],
  200. brackets: [
  201. { open: "{", close: "}", token: "delimiter.curly" },
  202. { open: "[", close: "]", token: "delimiter.bracket" },
  203. { open: "(", close: ")", token: "delimiter.parenthesis" }
  204. ],
  205. tokenizer: {
  206. root: [
  207. { include: "@whitespace" },
  208. { include: "@numbers" },
  209. { include: "@strings" },
  210. [/[,:;]/, "delimiter"],
  211. [/[{}\[\]()]/, "@brackets"],
  212. [/@[a-zA-Z_]\w*/, "tag"],
  213. [
  214. /[a-zA-Z_]\w*/,
  215. {
  216. cases: {
  217. "@keywords": "keyword",
  218. "@default": "identifier"
  219. }
  220. }
  221. ]
  222. ],
  223. whitespace: [
  224. [/\s+/, "white"],
  225. [/(^#.*$)/, "comment"],
  226. [/'''/, "string", "@endDocString"],
  227. [/"""/, "string", "@endDblDocString"]
  228. ],
  229. endDocString: [
  230. [/[^']+/, "string"],
  231. [/\\'/, "string"],
  232. [/'''/, "string", "@popall"],
  233. [/'/, "string"]
  234. ],
  235. endDblDocString: [
  236. [/[^"]+/, "string"],
  237. [/\\"/, "string"],
  238. [/"""/, "string", "@popall"],
  239. [/"/, "string"]
  240. ],
  241. numbers: [
  242. [/-?0x([abcdef]|[ABCDEF]|\d)+[lL]?/, "number.hex"],
  243. [/-?(\d*\.)?\d+([eE][+\-]?\d+)?[jJ]?[lL]?/, "number"]
  244. ],
  245. strings: [
  246. [/'$/, "string.escape", "@popall"],
  247. [/'/, "string.escape", "@stringBody"],
  248. [/"$/, "string.escape", "@popall"],
  249. [/"/, "string.escape", "@dblStringBody"]
  250. ],
  251. stringBody: [
  252. [/[^\\']+$/, "string", "@popall"],
  253. [/[^\\']+/, "string"],
  254. [/\\./, "string"],
  255. [/'/, "string.escape", "@popall"],
  256. [/\\$/, "string"]
  257. ],
  258. dblStringBody: [
  259. [/[^\\"]+$/, "string", "@popall"],
  260. [/[^\\"]+/, "string"],
  261. [/\\./, "string"],
  262. [/"/, "string.escape", "@popall"],
  263. [/\\$/, "string"]
  264. ]
  265. }
  266. };
  267. export {
  268. conf,
  269. language
  270. };